public final class StringIndicators extends AbstractLazyEncodedByteArray implements FastSerializable
The API offered by this class is as if the type were specified in ASN.1 as follows.
StringIndicators ::= SEQUENCE { odd BOOLEAN OPTIONAL, numSemiOctets INTEGER OPTIONAL }The class takes care of encoding the field values into a byte-array and decoding field values from a byte-array, the encoded representation being as tabulated below.
Data Encoding - made up by OpenCloud | ||||||||
---|---|---|---|---|---|---|---|---|
8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | |
Octet 1 | Spare | Odd | ||||||
Octet 2 | NumSemiOctets |
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
StringIndicators()
Constructs a new StringIndicators object with no fields set.
|
StringIndicators(byte[] data)
Constructs a new StringIndicators object from network-encoded data.
|
StringIndicators(byte[] data,
int start,
int len)
Constructs a new StringIndicators object from part of network-encoded data.
|
StringIndicators(DataInput in)
Constructs a new StringIndicators object from data deserialized from a stream that was written by
toStream(DataOutput) . |
Modifier and Type | Method and Description |
---|---|
void |
checkFieldsSet()
Checks that all mandatory fields are present.
|
StringIndicators |
clone()
Constructs a copy of this object and everything reachable from it.
|
static StringIndicators |
copyOf(StringIndicators from)
Creates a new object of this type, initialising its field values from those of the given object.
|
protected void |
decode()
Computes the decoded form of the state from the encoded form.
|
protected void |
encode()
Computes the encoded form of the state from the decoded form.
|
protected boolean |
encodedIsInvalid()
Determines whether the encoded form is invalid.
|
static int |
getContainedLength(byte[] data,
int start,
int len)
Determines the length of the encoded value that commences at offset
start in the given data . |
byte[] |
getEncodedForm()
Gets the encoded form.
|
static FieldAccessor[] |
getFieldAccessors()
Gets a new array of the accessors for fields of this type.
|
Map<String,Object> |
getFieldsMap(boolean withAbsents)
Gets a Map from field-name to field-value.
|
int |
getNumSemiOctets()
Gets the value of the numSemiOctets indicator.
|
boolean |
getOdd()
Gets the value of the odd indicator.
|
boolean |
hasNumSemiOctets()
Tests whether the field NumSemiOctets has a value.
|
boolean |
hasOdd()
Tests whether the field Odd has a value.
|
StringIndicators |
setNumSemiOctets(int value)
Sets the value of the numSemiOctets indicator.
|
StringIndicators |
setNumSemiOctetsPresent(boolean flag)
Sets the presence or absence of the field NumSemiOctets.
|
StringIndicators |
setOdd(boolean value)
Sets the value of the odd indicator.
|
StringIndicators |
setOddPresent(boolean flag)
Sets the presence or absence of the field Odd.
|
void |
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading by
StringIndicators(DataInput) . |
checkDecode, checkModifyAndDecode
equals, hashCode, toString
checkModify, isReadOnly, setReadOnly
public StringIndicators()
public StringIndicators(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic StringIndicators(byte[] data, int start, int len)
start
and is len
bytes long.
The data is not decoded and might not be decodable.data
- network-encoded datastart
- starting offset of network-encoded data in byte arraylen
- default length if not predictableNullPointerException
- if data is nullIllegalArgumentException
- if len is negativepublic StringIndicators(DataInput in) throws IOException
toStream(DataOutput)
.in
- the stream to read fromEOFException
- if reading is pre-empted by end-of-fileIOException
- if the data cannot be readpublic void toStream(DataOutput out) throws IOException
StringIndicators(DataInput)
.toStream
in interface FastSerializable
out
- the stream to write toIOException
- if an I/O error occurspublic boolean hasOdd() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic StringIndicators setOddPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasNumSemiOctets() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic StringIndicators setNumSemiOctetsPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic void checkFieldsSet() throws EncodeException
checkFieldsSet
in class AbstractLazyEncodedDataObject<byte[]>
EncodeException
- if any mandatory field is not presentpublic boolean getOdd() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic int getNumSemiOctets() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic StringIndicators setOdd(boolean value) throws IllegalStateException
value
- boolean representation of the odd indicatorIllegalStateException
public StringIndicators setNumSemiOctets(int value) throws IllegalStateException
value
- int representation of the numSemiOctets indicatorIllegalStateException
public StringIndicators clone()
clone
in interface DataObject
clone
in class AbstractDataObject
public static StringIndicators copyOf(StringIndicators from)
from
- the object from which to copypublic static FieldAccessor[] getFieldAccessors()
public Map<String,Object> getFieldsMap(boolean withAbsents)
getFieldsMap
in class AbstractFieldsObject
withAbsents
- whether to put unknown fields into Mapprotected boolean encodedIsInvalid()
public byte[] getEncodedForm() throws EncodeException
EncodeException
- if encoding failspublic static int getContainedLength(byte[] data, int start, int len)
start
in the given data
.
The value is not fully decoded and might not be decodable.
Values of this type are of a fixed length, so that length
is returned if the data is long enough, otherwise 0 is returned.data
- network-encoded datastart
- index into data where value commenceslen
- length in data to be consideredprotected void encode()
AbstractLazyEncodedDataObject
encode
in class AbstractLazyEncodedDataObject<byte[]>
protected void decode()
AbstractLazyEncodedDataObject
isDecoded
to true.decode
in class AbstractLazyEncodedDataObject<byte[]>