public final class CellGlobalId extends AbstractLazyEncodedByteArray implements FastSerializable
The API offered by this class is as if the type were specified in ASN.1 as follows.
CellGlobalId ::= SEQUENCE { mobileCountryCode DigitString, mobileNetworkCode DigitString, locationAreaCode INTEGER, cellId INTEGER }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 3GPP TS 23-003 V10.0.0 (2010-12) §4.3.1 p23 | ||||||||
---|---|---|---|---|---|---|---|---|
8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | |
Octet 0 | Mobile country code digit 2 | Mobile country code digit 1 | ||||||
Octet 1 | Mobile network code digit 3 if exists, else 1111 | Mobile country code digit 3 | ||||||
Octet 2 | Mobile network code digit 2 | Mobile network code digit 1 | ||||||
Octet 3 | Location area code MSB | |||||||
Octet 4 | Location area code LSB | |||||||
Octet 5 | Cell Id MSB | |||||||
Octet 6 | Cell Id LSB |
Each digit of the Mobile Country Code (MCC) and Mobile Network Code (MNC) fields
is encoded into a semi-octet.
The length of the Mobile Network Code (MNC) depends on the Mobile Country Code (MCC).
If the MNC has only 2 digits,
then the filler (1111) value is used where the 3rd digit would have been encoded.
Unless overridden by a particular StringCodec
,
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 | Field and Description |
---|---|
static BCDStringCodec<CellGlobalId> |
MOBILECOUNTRYCODE_CODEC
BCD string codec for field MobileCountryCode.
|
static BCDStringCodec<CellGlobalId> |
MOBILENETWORKCODE_CODEC
BCD string codec for field MobileNetworkCode.
|
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
CellGlobalId()
Constructs a new CellGlobalId object with no fields set.
|
CellGlobalId(byte[] data)
Constructs a new CellGlobalId object from network-encoded data.
|
CellGlobalId(byte[] data,
int start,
int len)
Constructs a new CellGlobalId object from part of network-encoded data.
|
CellGlobalId(DataInput in)
Constructs a new CellGlobalId object from data deserialized from a stream that was written by
toStream(DataOutput) . |
CellGlobalId(String mobileCountryCode,
String mobileNetworkCode,
int locationAreaCode,
int cellId)
Constructs a new CellGlobalId object from given values for all fields.
|
CellGlobalId(String mobileCountryCode,
String mobileNetworkCode,
int locationAreaCode,
int cellId,
StringCodec<CellGlobalId> MobileCountryCode_codec,
StringCodec<CellGlobalId> MobileNetworkCode_codec)
Constructs a new CellGlobalId object from given arguments,
using the given codecs for encoding fields of type String.
|
Modifier and Type | Method and Description |
---|---|
void |
checkFieldsSet()
Checks that all mandatory fields are present.
|
CellGlobalId |
clone()
Constructs a copy of this object and everything reachable from it.
|
static CellGlobalId |
copyOf(CellGlobalId 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.
|
int |
getCellId()
Gets the value of the cell identification (CI).
|
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 for the fields of a sequence.
|
int |
getLocationAreaCode()
Gets the value of the location area code (LAC).
|
String |
getMobileCountryCode()
Gets the value of the mobile country code (MCC).
|
String |
getMobileCountryCode(StringCodec<CellGlobalId> codec)
Gets the value of the mobile country code (MCC) using the given codec.
|
StringCodec<CellGlobalId> |
getMobileCountryCodeCodec()
Gets the codec used for field MobileCountryCode.
|
byte[] |
getMobileCountryCodeEncoded()
Gets a clone of the encoded value of the mobile country code (MCC).
|
String |
getMobileNetworkCode()
Gets the value of the mobile network code (MNC).
|
String |
getMobileNetworkCode(StringCodec<CellGlobalId> codec)
Gets the value of the mobile network code (MNC) using the given codec.
|
StringCodec<CellGlobalId> |
getMobileNetworkCodeCodec()
Gets the codec used for field MobileNetworkCode.
|
byte[] |
getMobileNetworkCodeEncoded()
Gets a clone of the encoded value of the mobile network code (MNC).
|
boolean |
hasCellId()
Tests whether the field CellId has a value.
|
boolean |
hasLocationAreaCode()
Tests whether the field LocationAreaCode has a value.
|
boolean |
hasMobileCountryCode()
Tests whether the field MobileCountryCode has a value.
|
boolean |
hasMobileNetworkCode()
Tests whether the field MobileNetworkCode has a value.
|
CellGlobalId |
setCellId(int value)
Sets the value of the cell identification (CI).
|
CellGlobalId |
setCellIdPresent(boolean flag)
Sets the presence or absence of the field CellId.
|
CellGlobalId |
setLocationAreaCode(int value)
Sets the value of the location area code (LAC).
|
CellGlobalId |
setLocationAreaCodePresent(boolean flag)
Sets the presence or absence of the field LocationAreaCode.
|
CellGlobalId |
setMobileCountryCode(String value)
Sets the value of the mobile country code (MCC).
|
CellGlobalId |
setMobileCountryCode(String value,
StringCodec<CellGlobalId> codec)
Sets the value of the mobile country code (MCC) using the given codec.
|
CellGlobalId |
setMobileCountryCodeEncoded(byte[] encoded)
Sets the encoded value of the mobile country code (MCC) to a clone of the given byte array.
|
CellGlobalId |
setMobileNetworkCode(String value)
Sets the value of the mobile network code (MNC).
|
CellGlobalId |
setMobileNetworkCode(String value,
StringCodec<CellGlobalId> codec)
Sets the value of the mobile network code (MNC) using the given codec.
|
CellGlobalId |
setMobileNetworkCodeEncoded(byte[] encoded)
Sets the encoded value of the mobile network code (MNC) to a clone of the given byte array.
|
void |
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading by
CellGlobalId(DataInput) . |
checkDecode, checkModifyAndDecode
equals, hashCode, toString
checkModify, isReadOnly, setReadOnly
public static final BCDStringCodec<CellGlobalId> MOBILECOUNTRYCODE_CODEC
public static final BCDStringCodec<CellGlobalId> MOBILENETWORKCODE_CODEC
public CellGlobalId()
public CellGlobalId(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic CellGlobalId(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 CellGlobalId(String mobileCountryCode, String mobileNetworkCode, int locationAreaCode, int cellId)
mobileCountryCode
- the mobile country code (MCC)mobileNetworkCode
- the mobile network code (MNC)locationAreaCode
- the location area code (LAC)cellId
- the cell identification (CI)public CellGlobalId(String mobileCountryCode, String mobileNetworkCode, int locationAreaCode, int cellId, StringCodec<CellGlobalId> MobileCountryCode_codec, StringCodec<CellGlobalId> MobileNetworkCode_codec)
mobileCountryCode
- the mobile country code (MCC)mobileNetworkCode
- the mobile network code (MNC)locationAreaCode
- the location area code (LAC)cellId
- the cell identification (CI)MobileCountryCode_codec
- StringCodec for mobileCountryCodeMobileNetworkCode_codec
- StringCodec for mobileNetworkCodepublic CellGlobalId(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
CellGlobalId(DataInput)
.toStream
in interface FastSerializable
out
- the stream to write toIOException
- if an I/O error occurspublic boolean hasMobileCountryCode() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasMobileNetworkCode() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasLocationAreaCode() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic CellGlobalId setLocationAreaCodePresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasCellId() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic CellGlobalId setCellIdPresent(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 String getMobileCountryCode() throws DecodeException
getMobileCountryCode(null)
.DecodeException
- if encoded state cannot be decodedpublic String getMobileNetworkCode() throws DecodeException
getMobileNetworkCode(null)
.DecodeException
- if encoded state cannot be decodedpublic int getLocationAreaCode() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic int getCellId() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic CellGlobalId setMobileCountryCode(String value) throws IllegalStateException
value
- String representation of the mobile country code (MCC)IllegalStateException
public CellGlobalId setMobileNetworkCode(String value) throws IllegalStateException
value
- String representation of the mobile network code (MNC)IllegalStateException
public CellGlobalId setLocationAreaCode(int value) throws IllegalStateException
value
- int representation of the location area code (LAC)IllegalStateException
public CellGlobalId setCellId(int value) throws IllegalStateException
value
- int representation of the cell identification (CI)IllegalStateException
public String getMobileCountryCode(StringCodec<CellGlobalId> codec) throws DecodeException
codec
- StringCodec to use for decodingDecodeException
- if encoded state cannot be decodedpublic byte[] getMobileCountryCodeEncoded()
public CellGlobalId setMobileCountryCode(String value, StringCodec<CellGlobalId> codec) throws IllegalArgumentException
value
- String representation of the mobile country code (MCC)codec
- StringCodec to use for encodingIllegalArgumentException
public CellGlobalId setMobileCountryCodeEncoded(byte[] encoded)
encoded
- byte[] representation of the mobile country code (MCC)public String getMobileNetworkCode(StringCodec<CellGlobalId> codec) throws DecodeException
codec
- StringCodec to use for decodingDecodeException
- if encoded state cannot be decodedpublic byte[] getMobileNetworkCodeEncoded()
public CellGlobalId setMobileNetworkCode(String value, StringCodec<CellGlobalId> codec) throws IllegalArgumentException
value
- String representation of the mobile network code (MNC)codec
- StringCodec to use for encodingIllegalArgumentException
public CellGlobalId setMobileNetworkCodeEncoded(byte[] encoded)
encoded
- byte[] representation of the mobile network code (MNC)public static CellGlobalId copyOf(CellGlobalId from)
from
- the object from which to copypublic CellGlobalId 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 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 consideredpublic StringCodec<CellGlobalId> getMobileCountryCodeCodec()
public StringCodec<CellGlobalId> getMobileNetworkCodeCodec()
protected void encode() throws EncodeException
encode
in class AbstractLazyEncodedDataObject<byte[]>
EncodeException
- if MobileCountryCode is not 3 digits, or MobileNetworkCode is not 2 or 3 digits or LocationAreaCode is not in range [0,65535] or CellId is not in range [0,65535]protected void decode() throws DecodeException
decode
in class AbstractLazyEncodedDataObject<byte[]>
DecodeException
- if less or more than 7 octets to be decoded