Package org.sblim.cimclient.internal.cim
Class CIMOctetString
- java.lang.Object
-
- org.sblim.cimclient.internal.cim.CIMOctetString
-
public class CIMOctetString extends java.lang.Object
This class represents a CIM octet string, or length-prefixed string, where the length is four octets (32 bits) AND includes the four octets it occupies. In other words, the length of the octet string is the number of characters in the string plus four. There are three possible representations:
1) Byte array - This is an array of UnsignedInteger8 (unit8) objects. The first four bytes contain the length, so the ASCII string "DEB" would be represented as { 0x00, 0x00, 0x00, 0x07, 0x44, 0x45, 0x42 }
2) Hexadecimal string - This is a string of hexadecimal digits. The four bytes after the initial "0x" contain the length, so the ASCII string "DEB" would be represented as "0x00000007444542".
3) ASCII string
One of these representations is passed into a constructor. The other representations are created on demand when a get() method is invoked or when the equals() method is invoked and the two octet strings have no representations in common.
-
-
Constructor Summary
Constructors Constructor Description CIMOctetString(java.lang.String pString, boolean pIsHex)
Constructs aCIMOctetString
from the given string.CIMOctetString(UnsignedInteger8[] pBytes)
Constructs aCIMOctetString
from the given byte array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object pObj)
Takes a CIM octet string and returnstrue
if it is equal to this CIM octet string.java.lang.String
getASCIIString(char pReplacementChar)
Returns ASCII string representation of octet string with non-printable characters replaced bypReplacementChar
.UnsignedInteger8[]
getBytes()
Returns byte array representation of octet string.java.lang.String
getHexString()
Returns hexadecimal string representation of octet string.int
hashCode()
Returns hash code value for octet string.int
length()
Returns length of octet string, where length is number of octets plus four.java.lang.String
toString()
Returns string representation of octet string.
-
-
-
Constructor Detail
-
CIMOctetString
public CIMOctetString(UnsignedInteger8[] pBytes) throws java.lang.IllegalArgumentException
Constructs aCIMOctetString
from the given byte array.- Parameters:
pBytes
- Byte array representation of octet string.- Throws:
java.lang.IllegalArgumentException
-
CIMOctetString
public CIMOctetString(java.lang.String pString, boolean pIsHex) throws java.lang.IllegalArgumentException
Constructs aCIMOctetString
from the given string.- Parameters:
pString
- String representation of octet string.pIsHex
-true
if string is hexadecimal string,false
if string is ASCII string.- Throws:
java.lang.IllegalArgumentException
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object pObj)
Takes a CIM octet string and returnstrue
if it is equal to this CIM octet string. Otherwise, it returnsfalse
. Two octet strings are considered equal if all of their common representations are equal. If the octet strings have no representations in common, this method will build the missing one, starting with byte array and then hexadecmial string. NOTE: The ASCII string representation is only considered if both octet strings were constructed with an ASCII string.- Overrides:
equals
in classjava.lang.Object
- Parameters:
pObj
- The object to be compared a CIM element.- Returns:
true
if the specified CIM octet string equals this CIM octet string,false
otherwise.
-
getASCIIString
public java.lang.String getASCIIString(char pReplacementChar)
Returns ASCII string representation of octet string with non-printable characters replaced bypReplacementChar
. If the ASCII string has not yet been created, it is created from the byte array or hexadecimal string.- Parameters:
pReplacementChar
- Replacement character for non-printable characters which must be between 0x20 and 0x7E, inclusive.- Returns:
- ASCII string representation of octet string.
-
getBytes
public UnsignedInteger8[] getBytes()
Returns byte array representation of octet string. If the byte array has not yet been created, it is created from the hexadecimal string or ASCII string.- Returns:
- Byte array representation of octet string.
-
getHexString
public java.lang.String getHexString()
Returns hexadecimal string representation of octet string. If the hexadecimal string has not yet been created, it is created from the byte array or ASCII string.- Returns:
- Hexadecimal string representation of octet string.
-
hashCode
public int hashCode()
Returns hash code value for octet string.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- Hash code value for octet string.
-
length
public int length()
Returns length of octet string, where length is number of octets plus four.- Returns:
- Length of octet string.
-
toString
public java.lang.String toString()
Returns string representation of octet string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representation of octet string.
-
-