org.opcfoundation.ua.builtintypes
Class ByteString

java.lang.Object
  extended by org.opcfoundation.ua.builtintypes.ByteString
All Implemented Interfaces:
Comparable<ByteString>

public final class ByteString
extends Object
implements Comparable<ByteString>

This primitive DataType specifies a ByteString, similar as String but for bytes. Class is final because it is an immutable value object. Also the constructor is private to avoid situations where the given value would be null, now the static factory methods returns null if given ByteString Null equivalent byte[].


Field Summary
static ByteString EMPTY
          ByteString instance that models empty ByteString.
 
Method Summary
static byte[] asByteArray(ByteString byteString)
          A null-safe way to convert ByteString to byte[].
 int compareTo(ByteString o)
           
 boolean equals(Object obj)
           
 int getLength()
          Return the length of this ByteString.
 byte[] getValue()
          Get a copy of the value of this ByteString as byte array.
 int hashCode()
           
 String toString()
           
static ByteString valueOf(byte... byteArray)
          Creates a ByteString from byte array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final ByteString EMPTY
ByteString instance that models empty ByteString.

Method Detail

asByteArray

public static byte[] asByteArray(ByteString byteString)
A null-safe way to convert ByteString to byte[]. The given array is copied for value.

Parameters:
byteString - a ByteString or null
Returns:
byte[] or null if given null

valueOf

public static ByteString valueOf(byte... byteArray)
Creates a ByteString from byte array.

Parameters:
byteArray - the byte array
Returns:
new ByteString or null if given null array

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getValue

public byte[] getValue()
Get a copy of the value of this ByteString as byte array.

Returns:
copy of the value as byte array. Not null.

getLength

public int getLength()
Return the length of this ByteString.

Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(ByteString o)
Specified by:
compareTo in interface Comparable<ByteString>


Copyright © 2018. All rights reserved.