public final class Code extends AbstractLazyEncodedByteArray implements FastSerializable, Immutable
The ITU cases are specified in ASN.1 as follows from X.880 module Remote-Operations-Information-Objects {joint-iso-itu-t remote-operations(4) informationObjects(5) version1(0)}.
Code ::= CHOICE { local INTEGER, global OBJECT IDENTIFIER }
The ANSI cases are specified in ASN.1 as follows from T1.114 p3-26.
OperationCode ::= CHOICE { national [PRIVATE 16] IMPLICIT INTEGER -32768..32767, private [PRIVATE 17] IMPLICIT INTEGER } ErrorCode ::= CHOICE { national [PRIVATE 19] INTEGER -128..127, private [PRIVATE 20] INTEGER }
Modifier and Type | Class and Description |
---|---|
static class |
Code.Choice
Enumeration of discriminating values.
|
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
Code()
Constructs a new Code object with no fields set.
|
Code(byte[] data)
Constructs a new Code object from network-encoded data.
|
Code(byte[] data,
int start,
int len)
Constructs a new Code object from part of network-encoded data.
|
Code(DataInput in)
Constructs a new Code 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.
|
Code |
clone()
Constructs a copy of this object and everything reachable from it.
|
static Code |
copyOf(Code 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.
|
void |
decode()
Computes the decoded form of the state from the encoded form.
|
void |
encode()
Computes the encoded form of the state from the decoded form.
|
protected boolean |
encodedIsInvalid()
Determines whether the encoded form is invalid.
|
Code.Choice |
getChoice()
Gets the discriminant for which choice is chosen.
|
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 :discriminant-name to field-value.
|
ObjectID |
getGlobal()
Gets the value of the ITU global object identifier alternative.
|
int |
getLocal()
Gets the value of the ITU local integer alternative.
|
int |
getNational()
Gets the value of the ANSI national integer alternative.
|
int |
getPrivate()
Gets the value of the ANSI private integer alternative.
|
boolean |
isGlobalChosen()
Tests whether the choice is global.
|
boolean |
isLocalChosen()
Tests whether the choice is local.
|
boolean |
isNationalChosen()
Tests whether the choice is national.
|
boolean |
isPrivateChosen()
Tests whether the choice is private.
|
Code |
setGlobal(ObjectID value)
Sets the value of the ITU global object identifier alternative.
|
Code |
setLocal(int value)
Sets the value of the ITU local integer alternative.
|
Code |
setNational(int value)
Sets the value of the ANSI national integer alternative.
|
Code |
setPrivate(int value)
Sets the value of the ANSI private integer alternative.
|
void |
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading by
Code(DataInput) . |
checkDecode, checkModifyAndDecode
equals, hashCode, toString
checkModify, isReadOnly, setReadOnly
public Code()
public Code(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic Code(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 Code(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
Code(DataInput)
.toStream
in interface FastSerializable
out
- the stream to write toIOException
- if an I/O error occurspublic Code.Choice getChoice() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean isLocalChosen() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean isGlobalChosen() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean isNationalChosen() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean isPrivateChosen() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic void checkFieldsSet() throws EncodeException
checkFieldsSet
in class AbstractLazyEncodedDataObject<byte[]>
EncodeException
- if any mandatory field is not presentpublic int getLocal() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic ObjectID getGlobal() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic int getNational() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic int getPrivate() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic Code setLocal(int value) throws IllegalStateException
value
- int representation of the ITU local integer alternativeIllegalStateException
public Code setGlobal(ObjectID value) throws IllegalStateException
value
- ObjectID representation of the ITU global object identifier alternativeIllegalStateException
public Code setNational(int value) throws IllegalStateException
value
- int representation of the ANSI national integer alternativeIllegalStateException
public Code setPrivate(int value) throws IllegalStateException
value
- int representation of the ANSI private integer alternativeIllegalStateException
public static Code copyOf(Code from)
from
- the object from which to copypublic Code 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
- the value of this parameter is ignoredprotected 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 variable length, so the given 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 consideredpublic void encode()
AbstractLazyEncodedDataObject
encode
in class AbstractLazyEncodedDataObject<byte[]>
UnsupportedOperationException
- as encoding is to TCAP representation, not byte[]; see ASN1Utilspublic void decode()
AbstractLazyEncodedDataObject
isDecoded
to true.decode
in class AbstractLazyEncodedDataObject<byte[]>
UnsupportedOperationException
- as decoding is from TCAP representation, not byte[]; see ASN1Utils