Package totalcross.net
Class ByteString
- java.lang.Object
-
- totalcross.net.ByteString
-
- Direct Known Subclasses:
URI.Path
public class ByteString extends java.lang.ObjectString of bytes. Used by the Network classes to avoid converting the byte array received from a Socket into Strings.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intconvertToInt(byte[] b, int start, int end)Convert the literal representation of an int to its int valueintconvertToInt(int start)Convert the literal representation of an int to its int valuestatic ByteStringcopy(ByteString source)Copy - if the source is null, this returns null.booleanequalsAtIgnoreCase(byte[] b, int at)Check if this ByteString equals the byte arrayb, for the length of the byte array, starting atatwithin this ByteString.booleanequalsIgnoreCase(byte[] b, int pos, int len)Check if this ByteString equals the value of the passed argumentsbooleanequalsIgnoreCase(ByteString c)Check if this ByteString is equal to the one passed in the argument.intindexOf(byte[] b, int start)Find the first byte arraybin this ByteString.intindexOf(byte b, int start)Find the first bytebin this ByteString.intlastIndexOf(byte b)Find the last bytebin this ByteString.ByteStringsubstring(int start, int end)Creates a ByteString substring.java.lang.StringtoString()Return a String representation of this ByteString
-
-
-
Method Detail
-
copy
public static ByteString copy(ByteString source)
Copy - if the source is null, this returns null. Otherwise, the ByteString is copied.- Parameters:
source- ByteString to be copied
-
substring
public ByteString substring(int start, int end)
Creates a ByteString substring.- Parameters:
start- the first character of the substringend- the character after the last character of the substring- Returns:
- the ByteString substring
-
equalsIgnoreCase
public final boolean equalsIgnoreCase(byte[] b, int pos, int len)Check if this ByteString equals the value of the passed arguments- Parameters:
b- byte array that holds the value to check againstpos- first byte in the byte arraylen- length of the value to check against- Returns:
- true if this ByteString matches, false otherwise
-
equalsIgnoreCase
public final boolean equalsIgnoreCase(ByteString c)
Check if this ByteString is equal to the one passed in the argument.- Parameters:
c- ByteString to check against- Returns:
- true if this ByteString is equal
to the
cByteString, false otherwise.
-
equalsAtIgnoreCase
public final boolean equalsAtIgnoreCase(byte[] b, int at)Check if this ByteString equals the byte arrayb, for the length of the byte array, starting atatwithin this ByteString.This extends, some how, startsWidth and endsWidth, avoiding substring.
- Parameters:
b- byte array that holds the value to check againstat- first byte in this ByteString- Returns:
- true if this ByteString matches, false otherwise
-
toString
public final java.lang.String toString()
Return a String representation of this ByteString- Overrides:
toStringin classjava.lang.Object- Returns:
- a String representation of this ByteString
-
indexOf
public final int indexOf(byte b, int start)Find the first bytebin this ByteString.- Parameters:
b- byte to findstart- where to start from- Returns:
- the offset of the byte, if found; -1 if not found
-
lastIndexOf
public final int lastIndexOf(byte b)
Find the last bytebin this ByteString.- Parameters:
b- byte to find- Returns:
- the offset of the byte, if found; -1 if not found
-
indexOf
public final int indexOf(byte[] b, int start)Find the first byte arraybin this ByteString.- Parameters:
b- byte array to findstart- where to start from- Returns:
- the offset of the byte array, if found; -1 if not found
-
convertToInt
public static int convertToInt(byte[] b, int start, int end)Convert the literal representation of an int to its int value- Parameters:
b- byte array that holds the literal representationstart- where it starts in the byte arrayend- where it ends- Returns:
- the integer value, or -1 if wrong representation.
-
convertToInt
public int convertToInt(int start)
Convert the literal representation of an int to its int value- Parameters:
start- where the int represenation starts in this ByteString- Returns:
- the integer value, or -1 if wrong representation.
-
-