Top Description Fields Constructors Methods
org.apache.poi.hpsf

public Class ClassID

extends Object
implements Duplicatable, GenericRecord
Class Inheritance
All Implemented Interfaces
org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.common.Duplicatable
Imports
java.nio.ByteBuffer, java.util.Arrays, .Locale, .Map, .UUID, java.util.function.Supplier, org.apache.poi.common.Duplicatable, org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.util.GenericRecordUtil, .LittleEndianInput, .LittleEndianOutput

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

Modifier and TypeField and Description
private final byte[]
bytes

The bytes making out the class ID in correct order, i.e. big-endian.

public static final int
LENGTH

The number of bytes occupied by this object in the byte stream.

Constructor Summary

AccessConstructor and Description
public
ClassID(final byte[]
The byte array to read from.
src
,
final int
The offset of the first byte to read.
offset
)

Creates a ClassID and reads its value from a byte array.

public
ClassID()

Creates a ClassID and initializes its value with 0x00 bytes.

public
ClassID(ClassID
The ClassID to use a base for creating this one
other
)

Clones the given ClassID

public
ClassID(String
representation of the Class ID represented by this object.
externalForm
)

Creates a ClassID from a human-readable representation of the Class ID in standard format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}".

public
ClassID(LittleEndianInput
the input (stream)
lei
)

Reads the ClassID from the input

Method Summary

Modifier and TypeMethod and Description
public ClassID
public boolean

Returns:

true if the objects are equal, else false.
equals
(final Object
the object to compare this ClassID with
o
)

Overrides java.lang.Object.equals.

Checks whether this ClassID is equal to another object.

public boolean

Returns:

true if the objects are equal, else false.
equalsInverted
(ClassID
the object to compare this ClassID with
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.

public byte[]

Returns:

the bytes making out the class ID.
getBytes
()

Gets the bytes making out the class ID. They are returned in correct order, i.e. big-endian.

public Map<String, Supplier<?>>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public int

Returns:

The number of bytes occupied by this object in the byte stream.
length
()

public byte[]

Returns:

A byte array containing the class ID.
read
(final byte[]
The byte array to read from
src
,
final int
The offset within the src byte array
offset
)

Reads the class ID's value from a byte array by turning little-endian into big-endian.

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

Sets the bytes making out the class ID.

public String

Returns:

String representation of the Class ID represented by this object.
toString
()

Overrides java.lang.Object.toString.

Returns a human-readable representation of the Class ID in standard format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}".

public UUID

Returns:

the ClassID as UUID
toUUID
()

Converts the ClassID to an UUID

public String

Returns:

UUID String representation of the Class ID represented by this object.
toUUIDString
()

Returns a human-readable representation of the Class ID in UUID format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".

public void
write(final byte[]
The byte array to write to.
dst
,
final int
The offset within the dst byte array.
offset
)

Writes the class ID to a byte array in the little-endian format.

public void
write(LittleEndianOutput
the output
leo
)

Write the class ID to a LittleEndianOutput (stream)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

bytesback to summary
private final byte[] bytes

The bytes making out the class ID in correct order, i.e. big-endian.

LENGTHback to summary
public static final int LENGTH

The number of bytes occupied by this object in the byte stream.

Constructor Detail

ClassIDback to summary
public ClassID(final byte[] src, final int offset)

Creates a ClassID and reads its value from a byte array.

Parameters
src:byte[]

The byte array to read from.

offset:int

The offset of the first byte to read.

ClassIDback to summary
public ClassID()

Creates a ClassID and initializes its value with 0x00 bytes.

ClassIDback to summary
public ClassID(ClassID other)

Clones the given ClassID

Parameters
other:ClassID

The ClassID to use a base for creating this one

ClassIDback to summary
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:String

representation of the Class ID represented by this object.

ClassIDback to summary
public ClassID(LittleEndianInput lei)

Reads the ClassID from the input

Parameters
lei:LittleEndianInput

the input (stream)

Method Detail

copyback to summary
public ClassID copy()

Implements org.apache.poi.common.Duplicatable.copy.

Returns:ClassID

Doc from org.apache.poi.common.Duplicatable.copy.

a deep copy of the implementing class / instance

Annotations
@Override
equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Checks whether this ClassID is equal to another object.

Parameters
o:Object

the object to compare this ClassID with

Returns:boolean

true if the objects are equal, else false.

Annotations
@Override
equalsInvertedback to summary
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:ClassID

the object to compare this ClassID with

Returns:boolean

true if the objects are equal, else false.

getBytesback to summary
public byte[] getBytes()

Gets the bytes making out the class ID. They are returned in correct order, i.e. big-endian.

Returns:byte[]

the bytes making out the class ID.

getGenericPropertiesback to summary
public Map<String, Supplier<?>> getGenericProperties()

Implements org.apache.poi.common.usermodel.GenericRecord.getGenericProperties.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
lengthback to summary
public int length()
Returns:int

The number of bytes occupied by this object in the byte stream.

Annotations
@SuppressWarnings:java:S1845
readback to summary
public byte[] read(final byte[] src, final int offset)

Reads the class ID's value from a byte array by turning little-endian into big-endian.

Parameters
src:byte[]

The byte array to read from

offset:int

The offset within the src byte array

Returns:byte[]

A byte array containing the class ID.

Annotations
@SuppressWarnings:PointlessArithmeticExpression
setBytesback to summary
public void setBytes(final byte[] bytes)

Sets the bytes making out the class ID.

Parameters
bytes:byte[]

The bytes making out the class ID in big-endian format. They are copied without their order being changed.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a human-readable representation of the Class ID in standard format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}".

Returns:String

String representation of the Class ID represented by this object.

Annotations
@Override
toUUIDback to summary
public UUID toUUID()

Converts the ClassID to an UUID

Returns:UUID

the ClassID as UUID

Since
POI 5.0.0
toUUIDStringback to summary
public String toUUIDString()

Returns a human-readable representation of the Class ID in UUID format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".

Returns:String

UUID String representation of the Class ID represented by this object.

writeback to summary
public void write(final byte[] dst, final int offset) throws ArrayStoreException

Writes the class ID to a byte array in the little-endian format.

Parameters
dst:byte[]

The byte array to write to.

offset:int

The offset within the dst byte array.

Annotations
@SuppressWarnings:PointlessArithmeticExpression
Exceptions
ArrayStoreException:
if there is not enough room for the class ID 16 bytes in the byte array after the offset position.
writeback to summary
public void write(LittleEndianOutput leo)

Write the class ID to a LittleEndianOutput (stream)

Parameters
leo:LittleEndianOutput

the output