Class LCPString


  • public class LCPString
    extends java.lang.Object
    A holder for an array of bytes. Useful when a string contains illegal characters for the String class.
    • Constructor Summary

      Constructors 
      Constructor Description
      LCPString​(byte[] byteArray)
      Constructs a new LCPString instance from the specified byte array.
      LCPString​(byte[] byteArray, int offset, int length)
      Constructs a new LCPString instance.
      LCPString​(int value)
      Constructs a new LCPString instance.
      LCPString​(short value)
      Constructs a new LCPString instance.
      LCPString​(java.lang.String string)
      Constructs a new LCPString 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()  
      • Methods inherited from class java.lang.Object

        clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LCPString

        public LCPString​(java.lang.String string)
        Constructs a new LCPString instance from the specified string.
        Parameters:
        string - A string that will be converted into a ByteString object.
      • LCPString

        public LCPString​(byte[] byteArray)
        Constructs a new LCPString instance from the specified byte array.
        Parameters:
        byteArray - An array of bytes.
      • LCPString

        public LCPString​(byte[] byteArray,
                         int offset,
                         int length)
        Constructs a new LCPString instance.

        The new LCPString object will copy length number of bytes from the offset location.

        Parameters:
        byteArray - An array of bytes.
        offset - The offset in byteArray from where to copy.
        length - the number of bytes that will be copied from byteArray.
      • LCPString

        public LCPString​(int value)
        Constructs a new LCPString 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 in value will become the fourth byte in the array.

        Parameters:
        value - The integer value to convert into a ByteString object.
      • LCPString

        public LCPString​(short value)
        Constructs a new LCPString 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 in value will become the second byte in the array.

        Parameters:
        value - The short value to convert into a ByteString 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 class java.lang.Object
        See Also:
        Object.toString()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)