Class LCPString
- java.lang.Object
-
- com.portwise.core.lcp.LCPString
-
public class LCPString extends java.lang.Object
A holder for an array of bytes. Useful when a string contains illegal characters for theString
class.
-
-
Constructor Summary
Constructors Constructor Description LCPString(byte[] byteArray)
Constructs a newLCPString
instance from the specified byte array.LCPString(byte[] byteArray, int offset, int length)
Constructs a newLCPString
instance.LCPString(int value)
Constructs a newLCPString
instance.LCPString(short value)
Constructs a newLCPString
instance.LCPString(java.lang.String string)
Constructs a newLCPString
instance from the specified string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
byte[]
getBytes()
Returns this object as an array of bytes.int
getInt()
Returns the value of this object as an integer.int
getShort()
Returns the value of this object as a short.int
length()
Returns the number of bytes in this object's byte array.java.lang.String
toString()
-
-
-
Constructor Detail
-
LCPString
public LCPString(java.lang.String string)
Constructs a newLCPString
instance from the specified string.- Parameters:
string
- A string that will be converted into aByteString
object.
-
LCPString
public LCPString(byte[] byteArray)
Constructs a newLCPString
instance from the specified byte array.- Parameters:
byteArray
- An array of bytes.
-
LCPString
public LCPString(byte[] byteArray, int offset, int length)
Constructs a newLCPString
instance.The new
LCPString
object will copylength
number of bytes from theoffset
location.- Parameters:
byteArray
- An array of bytes.offset
- The offset inbyteArray
from where to copy.length
- the number of bytes that will be copied frombyteArray
.
-
LCPString
public LCPString(int value)
Constructs a newLCPString
instance.The specified integer value will be converted to a byte array, where the most significant byte in
value
will become the first byte in the array, and the least significant byte invalue
will become the fourth byte in the array.- Parameters:
value
- The integer value to convert into aByteString
object.
-
LCPString
public LCPString(short value)
Constructs a newLCPString
instance.The specified short value will be converted to a byte array, where the most significant byte in
value
will become the first byte in the array, and the least significant byte invalue
will become the second byte in the array.- Parameters:
value
- The short value to convert into aByteString
object.
-
-
Method Detail
-
getInt
public int getInt()
Returns the value of this object as an integer.The first byte in this object's byte array will become the most significant byte in the returned integer, and the fourth byte in the byte array will become the least significant byte.
If the number of bytes in this object's byte array is something else than 4, then -1 is returned.
- Returns:
- The value of this object as an integer, or -1.
-
getShort
public int getShort()
Returns the value of this object as a short.The first byte in this object's byte array will become the most significant byte in the returned short, and the second byte in the byte array will become the least significant byte.
If the number of bytes in this object's byte array is something else than 2, then -1 is returned.
- Returns:
- The value of this object as a short, or -1.
-
getBytes
public byte[] getBytes()
Returns this object as an array of bytes.- Returns:
- A array of bytes.
-
length
public int length()
Returns the number of bytes in this object's byte array.- Returns:
- The size in bytes of this object.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
-