public final class ISDNSubaddress extends AbstractLazyEncodedByteArray implements FastSerializable
The API offered by this class is as if the type were specified in ASN.1 as follows.
ISDNSubaddress ::= CHOICE { nsap NSAPAddress, user DigitOrCharString }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 - based on comment in ASN.1 module MAP-CommonDataTypes in 3GPP TS 29.002 V10.0.0 (2010-09) p420 | |||||||||
---|---|---|---|---|---|---|---|---|---|
8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | ||
1 octet | 1 (ext) | Nature of address discriminates... | Odd? | 0 | 0 | 0 | |||
≤20 octets | case 0 (NSAP) | Network Service Access Point (NSAP) address | |||||||
case 2 (USER_SPECIFIED) | User-specified address |
nsap
and 010 for choice user
.
The value of Odd? is set only for the choice user
and only if that's encoding uses BCD.
If the user field is encoded using BCD,
then each digit of the user field is encoded into a semi-octet,
and if there is an odd number of digits then the last semi-octet is assigned a filler.
Unless overridden by a particular StringCodec
,
the filler is 0 and the encoding to semi-octets is as tabulated below.
Decoded character | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Encoded hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
Modifier and Type | Class and Description |
---|---|
static class |
ISDNSubaddress.Choice
Enumeration of discriminating values.
|
Modifier and Type | Field and Description |
---|---|
static BCDStringCodec<ISDNSubaddress> |
USER_CODEC
BCD string codec for field User.
|
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
ISDNSubaddress()
Constructs a new ISDNSubaddress object with no fields set.
|
ISDNSubaddress(byte[] data)
Constructs a new ISDNSubaddress object from network-encoded data.
|
ISDNSubaddress(byte[] data,
int start,
int len)
Constructs a new ISDNSubaddress object from part of network-encoded data.
|
ISDNSubaddress(DataInput in)
Constructs a new ISDNSubaddress 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.
|
ISDNSubaddress |
clone()
Constructs a copy of this object and everything reachable from it.
|
static ISDNSubaddress |
copyOf(ISDNSubaddress 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.
|
ISDNSubaddress.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.
|
NSAPAddress |
getNsap()
Gets the value of the number digits.
|
String |
getUser()
Gets the value of the number digits.
|
String |
getUser(StringCodec<ISDNSubaddress> codec)
Gets the value of the number digits using the given codec.
|
StringCodec<ISDNSubaddress> |
getUserCodec()
Gets the codec used for field User.
|
EncodedStringWithIndicators |
getUserEncoded()
Gets a clone of the encoded value of the number digits.
|
boolean |
isNsapChosen()
Tests whether the choice is nsap.
|
boolean |
isUserChosen()
Tests whether the choice is user.
|
ISDNSubaddress |
setNsap(NSAPAddress value)
Sets the value of the number digits.
|
void |
setReadOnly()
Sets this and all its fields to be immutable.
|
ISDNSubaddress |
setUser(String value)
Sets the value of the number digits.
|
ISDNSubaddress |
setUser(String value,
StringCodec<ISDNSubaddress> codec)
Sets the value of the number digits using the given codec.
|
ISDNSubaddress |
setUserEncoded(EncodedStringWithIndicators encoded)
Sets the encoded value of the number digits to a clone of the given EncodedStringIndicators.
|
void |
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading by
ISDNSubaddress(DataInput) . |
checkDecode, checkModifyAndDecode
equals, hashCode, toString
checkModify, isReadOnly
public static final BCDStringCodec<ISDNSubaddress> USER_CODEC
public ISDNSubaddress()
public ISDNSubaddress(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic ISDNSubaddress(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 ISDNSubaddress(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
ISDNSubaddress(DataInput)
.toStream
in interface FastSerializable
out
- the stream to write toIOException
- if an I/O error occurspublic ISDNSubaddress.Choice getChoice() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean isNsapChosen() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean isUserChosen() 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 NSAPAddress getNsap() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic String getUser() throws DecodeException
getUser(null)
.DecodeException
- if encoded state cannot be decodedpublic ISDNSubaddress setNsap(NSAPAddress value) throws IllegalStateException
value
- NSAPAddress representation of the number digitsIllegalStateException
public ISDNSubaddress setUser(String value) throws IllegalStateException
value
- String representation of the number digitsIllegalStateException
public String getUser(StringCodec<ISDNSubaddress> codec) throws DecodeException
codec
- StringCodec to use for decodingDecodeException
- if encoded state cannot be decodedpublic EncodedStringWithIndicators getUserEncoded()
public ISDNSubaddress setUser(String value, StringCodec<ISDNSubaddress> codec) throws IllegalArgumentException
value
- String representation of the number digitscodec
- StringCodec to use for encodingIllegalArgumentException
public ISDNSubaddress setUserEncoded(EncodedStringWithIndicators encoded)
encoded
- EncodedStringWithIndicators representation of the number digitspublic static ISDNSubaddress copyOf(ISDNSubaddress from)
from
- the object from which to copypublic ISDNSubaddress clone()
clone
in interface DataObject
clone
in class AbstractDataObject
public void setReadOnly()
setReadOnly
in interface DataObject
setReadOnly
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 StringCodec<ISDNSubaddress> getUserCodec()
protected void encode() throws EncodeException
encode
in class AbstractLazyEncodedDataObject<byte[]>
EncodeException
- if address not setprotected void decode() throws DecodeException
decode
in class AbstractLazyEncodedDataObject<byte[]>
DecodeException
- if less than one octet to be decoded