public final class LegType extends AbstractLazyEncodedNamedInteger<LegType.EncodedValue> implements FastSerializable
The API offered by this class is as if the type were specified in ASN.1 as follows.
LegType ::= SEQUENCE { encodedValue EncodedValue }
EncodedValue is a NamedInteger.
For each named value of the type, n
, the API defines three Java static fields:
a DataObject n
,
a NamedInteger EncodedValue.n
,
and an int EncodedValue._n
.
Modifier and Type | Class and Description |
---|---|
static class |
LegType.EncodedValue
Leg type constants.
|
Modifier and Type | Field and Description |
---|---|
static LegType |
CALLED_PARTY
Constant for called party.
|
static LegType |
CALLING_PARTY
Constant for calling party.
|
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
LegType()
Constructs a new LegType object with no fields set.
|
LegType(byte[] data)
Constructs a new LegType object from network-encoded data.
|
LegType(byte[] data,
int start,
int len)
Constructs a new LegType object from part of network-encoded data.
|
LegType(DataInput in)
Constructs a new LegType object from data deserialized from a stream that was written by
toStream(DataOutput) . |
LegType(int arg)
Constructs a new LegType object from the given int,
making it be read-only (immutable).
|
LegType(LegType.EncodedValue encodedValue)
Constructs a new LegType object from given values for all fields.
|
Modifier and Type | Method and Description |
---|---|
void |
checkFieldsSet()
Checks that all mandatory fields are present.
|
LegType |
clone()
Constructs a copy of this object and everything reachable from it.
|
static LegType |
copyOf(LegType from)
Creates a new object of this type, cloning the values of common fields from the given object of any subclass of the same base type.
|
protected void |
decode()
Computes the decoded form from the encoded form.
|
protected void |
encode()
Computes the encoded form from the decoded form.
|
protected boolean |
encodedIsInvalid()
Determines whether the encoded form is invalid.
|
protected LegType.EncodedValue |
fromValue(int value)
Converts an int to a NamedInteger.
|
byte[] |
getByteArrayForm()
Gets the byte array encoded form.
|
LegType.EncodedValue |
getEncodedForm()
Gets the encoded form.
|
LegType.EncodedValue |
getEncodedValue()
Gets the value of the leg type value.
|
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 for the fields of a sequence.
|
boolean |
hasEncodedValue()
Tests whether the field EncodedValue has a value.
|
LegType |
setEncodedValue(LegType.EncodedValue value)
Sets the value of the leg type value.
|
void |
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading by
LegType(DataInput) . |
checkDecode, checkModifyAndDecode
equals, hashCode, toString
checkModify, isReadOnly, setReadOnly
public static final LegType CALLING_PARTY
public static final LegType CALLED_PARTY
public LegType()
public LegType(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic LegType(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 LegType(LegType.EncodedValue encodedValue)
encodedValue
- the leg type valuepublic LegType(int arg)
arg
- intpublic LegType(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
LegType(DataInput)
.toStream
in interface FastSerializable
out
- the stream to write toIOException
- if an I/O error occurspublic boolean hasEncodedValue() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic void checkFieldsSet() throws EncodeException
checkFieldsSet
in class AbstractLazyEncodedDataObject<LegType.EncodedValue>
EncodeException
- if any mandatory field is not presentpublic LegType.EncodedValue getEncodedValue() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic LegType setEncodedValue(LegType.EncodedValue value) throws IllegalStateException
value
- EncodedValue representation of the leg type valueIllegalStateException
public static LegType copyOf(LegType from)
from
- the object from which to copypublic LegType clone()
clone
in interface DataObject
clone
in class AbstractDataObject
public static FieldAccessor[] getFieldAccessors()
public Map<String,Object> getFieldsMap(boolean withAbsents)
getFieldsMap
in class AbstractFieldsObject
withAbsents
- whether to put absent optional fields into Mapprotected boolean encodedIsInvalid()
public LegType.EncodedValue getEncodedForm() throws EncodeException
EncodeException
- if encoding failspublic byte[] getByteArrayForm() throws EncodeException
EncodeException
- if encoding failsprotected LegType.EncodedValue fromValue(int value)
fromValue
in class AbstractLazyEncodedNamedInteger<LegType.EncodedValue>
value
- intprotected void encode() throws EncodeException
encode
in class AbstractLazyEncodedDataObject<LegType.EncodedValue>
EncodeException
- if EncodedValue is not in range [0,255]protected void decode() throws DecodeException
decode
in class AbstractLazyEncodedDataObject<LegType.EncodedValue>
DecodeException
- if decoding fails