Class ClassID

  • All Implemented Interfaces:
    Duplicatable, GenericRecord

    public class ClassID
    extends Object
    implements Duplicatable, GenericRecord
    Represents a class ID (16 bytes). Unlike other little-endian type the ClassID is not just 16 bytes stored in the wrong order. Instead, it is a double word (4 bytes) followed by two words (2 bytes each) followed by 8 bytes.

    The ClassID (or CLSID) is a UUID - see RFC 4122

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int LENGTH
      The number of bytes occupied by this object in the byte stream.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassID()
      Creates a ClassID and initializes its value with 0x00 bytes.
      ClassID​(byte[] src, int offset)
      Creates a ClassID and reads its value from a byte array.
      ClassID​(String externalForm)
      Creates a ClassID from a human-readable representation of the Class ID in standard format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}".
      ClassID​(ClassID other)
      Clones the given ClassID
      ClassID​(LittleEndianInput lei)
      Reads the ClassID from the input
    • Field Detail

      • LENGTH

        public static final int LENGTH
        The number of bytes occupied by this object in the byte stream.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ClassID

        public ClassID​(byte[] src,
                       int offset)
        Creates a ClassID and reads its value from a byte array.
        Parameters:
        src - The byte array to read from.
        offset - The offset of the first byte to read.
      • ClassID

        public ClassID()
        Creates a ClassID and initializes its value with 0x00 bytes.
      • ClassID

        public ClassID​(ClassID other)
        Clones the given ClassID
        Parameters:
        other - The ClassID to use a base for creating this one
      • ClassID

        public ClassID​(String externalForm)
        Creates a ClassID from a human-readable representation of the Class ID in standard format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}".
        Parameters:
        externalForm - representation of the Class ID represented by this object.
      • ClassID

        public ClassID​(LittleEndianInput lei)
        Reads the ClassID from the input
        Parameters:
        lei - the input (stream)
    • Method Detail

      • length

        public int length()
        Returns:
        The number of bytes occupied by this object in the byte stream.
      • getBytes

        public byte[] getBytes()
        Gets the bytes making out the class ID. They are returned in correct order, i.e. big-endian.
        Returns:
        the bytes making out the class ID.
      • setBytes

        public void setBytes​(byte[] bytes)
        Sets the bytes making out the class ID.
        Parameters:
        bytes - The bytes making out the class ID in big-endian format. They are copied without their order being changed.
      • read

        public byte[] read​(byte[] src,
                           int offset)
        Reads the class ID's value from a byte array by turning little-endian into big-endian.
        Parameters:
        src - The byte array to read from
        offset - The offset within the src byte array
        Returns:
        A byte array containing the class ID.
      • write

        public void write​(byte[] dst,
                          int offset)
                   throws ArrayStoreException
        Writes the class ID to a byte array in the little-endian format.
        Parameters:
        dst - The byte array to write to.
        offset - The offset within the dst byte array.
        Throws:
        ArrayStoreException - if there is not enough room for the class ID 16 bytes in the byte array after the offset position.
      • write

        public void write​(LittleEndianOutput leo)
        Write the class ID to a LittleEndianOutput (stream)
        Parameters:
        leo - the output
      • equals

        public boolean equals​(Object o)
        Checks whether this ClassID is equal to another object.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare this ClassID with
        Returns:
        true if the objects are equal, else false.
      • equalsInverted

        public boolean equalsInverted​(ClassID o)
        Checks whether this ClassID is equal to another ClassID with inverted endianess, because there are apparently not only version 1 GUIDs (aka "network" with big-endian encoding), but also version 2 GUIDs (aka "native" with little-endian encoding) out there.
        Parameters:
        o - the object to compare this ClassID with
        Returns:
        true if the objects are equal, else false.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Returns a human-readable representation of the Class ID in standard format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}".
        Overrides:
        toString in class Object
        Returns:
        String representation of the Class ID represented by this object.
      • toUUIDString

        public String toUUIDString()
        Returns a human-readable representation of the Class ID in UUID format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
        Returns:
        UUID String representation of the Class ID represented by this object.
      • toUUID

        public UUID toUUID()
        Converts the ClassID to an UUID
        Returns:
        the ClassID as UUID
        Since:
        POI 5.0.0
      • copy

        public ClassID copy()
        Specified by:
        copy in interface Duplicatable
        Returns:
        a deep copy of the implementing class / instance