Class LocationAreaId
- java.lang.Object
-
- com.opencloud.util.AbstractDataObject
-
- com.opencloud.util.AbstractFieldsObject
-
- AbstractEncodedDataObject<T>
-
- AbstractLazyEncodedDataObject<byte[]>
-
- AbstractLazyEncodedByteArray
-
- com.opencloud.slee.resources.in.datatypes.cc.LocationAreaId
-
- All Implemented Interfaces:
DataObject
,FastSerializable
,Serializable
public final class LocationAreaId extends AbstractLazyEncodedByteArray implements FastSerializable
Class LocationAreaId represents an unambiguous identification of a location area within the area covered by the GPRS system. It represents the ASN.1 OCTET STRING type MAP-CommonDataTypes.LAIFixedLength.The API offered by this class is as if the type were specified in ASN.1 as follows.
LocationAreaId ::= SEQUENCE { mobileCountryCode DigitString, mobileNetworkCode DigitString, locationAreaCode 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 24.008 V10.1.0 (2010-12) §10.5.1.3 p383 8 7 6 5 4 3 2 1 Octet 2 Mobile country code digit 2 Mobile country code digit 1 Octet 3 Mobile network code digit 3 if exists, else 1111 Mobile country code digit 3 Octet 4 Mobile network code digit 2 Mobile network code digit 1 Octet 5 Location area code MSB Octet 6 Location area code LSB
The octet numbering in the above table is that used in the cited standard for the octets encoded here.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 - See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static BCDStringCodec<LocationAreaId>
MOBILECOUNTRYCODE_CODEC
BCD string codec for field MobileCountryCode.static BCDStringCodec<LocationAreaId>
MOBILENETWORKCODE_CODEC
BCD string codec for field MobileNetworkCode.-
Fields inherited from class com.opencloud.slee.resources.cgin.AbstractLazyEncodedDataObject
isDecoded
-
Fields inherited from class com.opencloud.slee.resources.cgin.AbstractEncodedDataObject
encoded
-
Fields inherited from class com.opencloud.util.AbstractFieldsObject
FIELD_ABSENT, FIELD_UNINITIALISED
-
-
Constructor Summary
Constructors Constructor Description LocationAreaId()
Constructs a new LocationAreaId object with no fields set.LocationAreaId(byte[] data)
Constructs a new LocationAreaId object from network-encoded data.LocationAreaId(byte[] data, int start, int len)
Constructs a new LocationAreaId object from part of network-encoded data.LocationAreaId(DataInput in)
Constructs a new LocationAreaId object from data deserialized from a stream that was written bytoStream(DataOutput)
.LocationAreaId(String mobileCountryCode, String mobileNetworkCode, int locationAreaCode)
Constructs a new LocationAreaId object from given values for all fields.LocationAreaId(String mobileCountryCode, String mobileNetworkCode, int locationAreaCode, StringCodec<LocationAreaId> MobileCountryCode_codec, StringCodec<LocationAreaId> MobileNetworkCode_codec)
Constructs a new LocationAreaId object from given arguments, using the given codecs for encoding fields of type String.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkFieldsSet()
Checks that all mandatory fields are present.LocationAreaId
clone()
Constructs a copy of this object and everything reachable from it.static LocationAreaId
copyOf(LocationAreaId 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.static int
getContainedLength(byte[] data, int start, int len)
Determines the length of the encoded value that commences at offsetstart
in the givendata
.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<LocationAreaId> codec)
Gets the value of the mobile country code (MCC) using the given codec.StringCodec<LocationAreaId>
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<LocationAreaId> codec)
Gets the value of the mobile network code (MNC) using the given codec.StringCodec<LocationAreaId>
getMobileNetworkCodeCodec()
Gets the codec used for field MobileNetworkCode.byte[]
getMobileNetworkCodeEncoded()
Gets a clone of the encoded value of the mobile network code (MNC).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.LocationAreaId
setLocationAreaCode(int value)
Sets the value of the location area code (LAC).LocationAreaId
setLocationAreaCodePresent(boolean flag)
Sets the presence or absence of the field LocationAreaCode.LocationAreaId
setMobileCountryCode(String value)
Sets the value of the mobile country code (MCC).LocationAreaId
setMobileCountryCode(String value, StringCodec<LocationAreaId> codec)
Sets the value of the mobile country code (MCC) using the given codec.LocationAreaId
setMobileCountryCodeEncoded(byte[] encoded)
Sets the encoded value of the mobile country code (MCC) to a clone of the given byte array.LocationAreaId
setMobileNetworkCode(String value)
Sets the value of the mobile network code (MNC).LocationAreaId
setMobileNetworkCode(String value, StringCodec<LocationAreaId> codec)
Sets the value of the mobile network code (MNC) using the given codec.LocationAreaId
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 byLocationAreaId(DataInput)
.-
Methods inherited from class com.opencloud.slee.resources.cgin.AbstractLazyEncodedDataObject
checkDecode, checkModifyAndDecode
-
Methods inherited from class com.opencloud.util.AbstractFieldsObject
equals, hashCode, toString
-
Methods inherited from class com.opencloud.util.AbstractDataObject
checkModify, isReadOnly, setReadOnly
-
-
-
-
Field Detail
-
MOBILECOUNTRYCODE_CODEC
public static final BCDStringCodec<LocationAreaId> MOBILECOUNTRYCODE_CODEC
BCD string codec for field MobileCountryCode.
-
MOBILENETWORKCODE_CODEC
public static final BCDStringCodec<LocationAreaId> MOBILENETWORKCODE_CODEC
BCD string codec for field MobileNetworkCode.
-
-
Constructor Detail
-
LocationAreaId
public LocationAreaId()
Constructs a new LocationAreaId object with no fields set.
-
LocationAreaId
public LocationAreaId(byte[] data)
Constructs a new LocationAreaId object from network-encoded data. The data is not decoded and might not be decodable.- Parameters:
data
- network-encoded data- Throws:
NullPointerException
- if data is null
-
LocationAreaId
public LocationAreaId(byte[] data, int start, int len)
Constructs a new LocationAreaId object from part of network-encoded data. The part starts at indexstart
and islen
bytes long. The data is not decoded and might not be decodable.- Parameters:
data
- network-encoded datastart
- starting offset of network-encoded data in byte arraylen
- default length if not predictable- Throws:
NullPointerException
- if data is nullIllegalArgumentException
- if len is negative
-
LocationAreaId
public LocationAreaId(String mobileCountryCode, String mobileNetworkCode, int locationAreaCode)
Constructs a new LocationAreaId object from given values for all fields.- Parameters:
mobileCountryCode
- the mobile country code (MCC)mobileNetworkCode
- the mobile network code (MNC)locationAreaCode
- the location area code (LAC)
-
LocationAreaId
public LocationAreaId(String mobileCountryCode, String mobileNetworkCode, int locationAreaCode, StringCodec<LocationAreaId> MobileCountryCode_codec, StringCodec<LocationAreaId> MobileNetworkCode_codec)
Constructs a new LocationAreaId object from given arguments, using the given codecs for encoding fields of type String.- Parameters:
mobileCountryCode
- the mobile country code (MCC)mobileNetworkCode
- the mobile network code (MNC)locationAreaCode
- the location area code (LAC)MobileCountryCode_codec
- StringCodec for mobileCountryCodeMobileNetworkCode_codec
- StringCodec for mobileNetworkCode
-
LocationAreaId
public LocationAreaId(DataInput in) throws IOException
Constructs a new LocationAreaId object from data deserialized from a stream that was written bytoStream(DataOutput)
.- Parameters:
in
- the stream to read from- Throws:
EOFException
- if reading is pre-empted by end-of-fileIOException
- if the data cannot be read
-
-
Method Detail
-
toStream
public void toStream(DataOutput out) throws IOException
Serializes this object to a stream in a form suitable for reading byLocationAreaId(DataInput)
.- Specified by:
toStream
in interfaceFastSerializable
- Parameters:
out
- the stream to write to- Throws:
IOException
- if an I/O error occurs
-
hasMobileCountryCode
public boolean hasMobileCountryCode() throws DecodeException
Tests whether the field MobileCountryCode has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
hasMobileNetworkCode
public boolean hasMobileNetworkCode() throws DecodeException
Tests whether the field MobileNetworkCode has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
hasLocationAreaCode
public boolean hasLocationAreaCode() throws DecodeException
Tests whether the field LocationAreaCode has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setLocationAreaCodePresent
public LocationAreaId setLocationAreaCodePresent(boolean flag) throws IllegalStateException
Sets the presence or absence of the field LocationAreaCode.- Parameters:
flag
- whether the field should be marked as present- Returns:
- this
- Throws:
IllegalStateException
- if this instance has been marked as read-only
-
checkFieldsSet
public void checkFieldsSet() throws EncodeException
Checks that all mandatory fields are present. Should be called immediately before all calls to encode().- Specified by:
checkFieldsSet
in classAbstractLazyEncodedDataObject<byte[]>
- Throws:
EncodeException
- if any mandatory field is not present
-
getMobileCountryCode
public String getMobileCountryCode() throws DecodeException
Gets the value of the mobile country code (MCC). Equivalent togetMobileCountryCode(null)
.- Returns:
- String representation of the mobile country code (MCC)
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getMobileNetworkCode
public String getMobileNetworkCode() throws DecodeException
Gets the value of the mobile network code (MNC). Equivalent togetMobileNetworkCode(null)
.- Returns:
- String representation of the mobile network code (MNC)
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getLocationAreaCode
public int getLocationAreaCode() throws DecodeException
Gets the value of the location area code (LAC).- Returns:
- int representation of the location area code (LAC)
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setMobileCountryCode
public LocationAreaId setMobileCountryCode(String value) throws IllegalStateException
Sets the value of the mobile country code (MCC).- Parameters:
value
- String representation of the mobile country code (MCC)- Returns:
- this
- Throws:
IllegalStateException
-
setMobileNetworkCode
public LocationAreaId setMobileNetworkCode(String value) throws IllegalStateException
Sets the value of the mobile network code (MNC).- Parameters:
value
- String representation of the mobile network code (MNC)- Returns:
- this
- Throws:
IllegalStateException
-
setLocationAreaCode
public LocationAreaId setLocationAreaCode(int value) throws IllegalStateException
Sets the value of the location area code (LAC).- Parameters:
value
- int representation of the location area code (LAC)- Returns:
- this
- Throws:
IllegalStateException
-
getMobileCountryCode
public String getMobileCountryCode(StringCodec<LocationAreaId> codec) throws DecodeException
Gets the value of the mobile country code (MCC) using the given codec. If the field MobileCountryCode is not set, returns null. If the given codec is null, then uses the standard codec for this field.- Parameters:
codec
- StringCodec to use for decoding- Returns:
- String representation of the mobile country code (MCC)
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getMobileCountryCodeEncoded
public byte[] getMobileCountryCodeEncoded()
Gets a clone of the encoded value of the mobile country code (MCC).- Returns:
- byte[] representation of the mobile country code (MCC)
-
setMobileCountryCode
public LocationAreaId setMobileCountryCode(String value, StringCodec<LocationAreaId> codec) throws IllegalArgumentException
Sets the value of the mobile country code (MCC) using the given codec. If the given codec is null, uses the standard codec.- Parameters:
value
- String representation of the mobile country code (MCC)codec
- StringCodec to use for encoding- Returns:
- this
- Throws:
IllegalArgumentException
-
setMobileCountryCodeEncoded
public LocationAreaId setMobileCountryCodeEncoded(byte[] encoded)
Sets the encoded value of the mobile country code (MCC) to a clone of the given byte array.- Parameters:
encoded
- byte[] representation of the mobile country code (MCC)- Returns:
- this
-
getMobileNetworkCode
public String getMobileNetworkCode(StringCodec<LocationAreaId> codec) throws DecodeException
Gets the value of the mobile network code (MNC) using the given codec. If the field MobileNetworkCode is not set, returns null. If the given codec is null, then uses the standard codec for this field.- Parameters:
codec
- StringCodec to use for decoding- Returns:
- String representation of the mobile network code (MNC)
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getMobileNetworkCodeEncoded
public byte[] getMobileNetworkCodeEncoded()
Gets a clone of the encoded value of the mobile network code (MNC).- Returns:
- byte[] representation of the mobile network code (MNC)
-
setMobileNetworkCode
public LocationAreaId setMobileNetworkCode(String value, StringCodec<LocationAreaId> codec) throws IllegalArgumentException
Sets the value of the mobile network code (MNC) using the given codec. If the given codec is null, uses the standard codec.- Parameters:
value
- String representation of the mobile network code (MNC)codec
- StringCodec to use for encoding- Returns:
- this
- Throws:
IllegalArgumentException
-
setMobileNetworkCodeEncoded
public LocationAreaId setMobileNetworkCodeEncoded(byte[] encoded)
Sets the encoded value of the mobile network code (MNC) to a clone of the given byte array.- Parameters:
encoded
- byte[] representation of the mobile network code (MNC)- Returns:
- this
-
copyOf
public static LocationAreaId copyOf(LocationAreaId 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.- Parameters:
from
- the object from which to copy- Returns:
- LocationAreaId
-
clone
public LocationAreaId clone()
Constructs a copy of this object and everything reachable from it.- Specified by:
clone
in interfaceDataObject
- Specified by:
clone
in classAbstractDataObject
- Returns:
- copy of object
-
getFieldAccessors
public static FieldAccessor[] getFieldAccessors()
Gets a new array of the accessors for fields of this type.- Returns:
- FieldAccessor[]
-
getFieldsMap
public Map<String,Object> getFieldsMap(boolean withAbsents)
Gets a Map from field-name to field-value for the fields of a sequence. For a field of primitive type, the field-value is boxed. For an absent optional field, the field-value is AbstractFieldsObject.FIELD_ABSENT. For an uninitialised mandatory field, the field-value is AbstractFieldsObject.FIELD_UNINITIALISED. For a field of String type, the encoded form is used if the String cannot be decoded. For a type that represents an OCTET STRING that cannot be decoded, a map from "encodedValue" to the byte array value is returned.- Specified by:
getFieldsMap
in classAbstractFieldsObject
- Parameters:
withAbsents
- whether to put absent optional fields into Map- Returns:
- Map from field-name to field-value
-
encodedIsInvalid
protected boolean encodedIsInvalid()
Determines whether the encoded form is invalid.- Returns:
- boolean
-
getEncodedForm
public byte[] getEncodedForm() throws EncodeException
Gets the encoded form.- Returns:
- encoded form
- Throws:
EncodeException
- if encoding fails
-
getContainedLength
public static int getContainedLength(byte[] data, int start, int len)
Determines the length of the encoded value that commences at offsetstart
in the givendata
. 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.- Parameters:
data
- network-encoded datastart
- index into data where value commenceslen
- length in data to be considered- Returns:
- 5, or 0 if encoded value is not long enough
-
getMobileCountryCodeCodec
public StringCodec<LocationAreaId> getMobileCountryCodeCodec()
Gets the codec used for field MobileCountryCode.- Returns:
- StringCodec
-
getMobileNetworkCodeCodec
public StringCodec<LocationAreaId> getMobileNetworkCodeCodec()
Gets the codec used for field MobileNetworkCode.- Returns:
- StringCodec
-
encode
protected void encode() throws EncodeException
Computes the encoded form from the decoded form. throws EncodeException if MobileCountryCode is not 3 digits, or MobileNetworkCode is not 2 or 3 digits, or LocationAreaCode is not in range [0,65535]- Specified by:
encode
in classAbstractLazyEncodedDataObject<byte[]>
- Throws:
EncodeException
- if encoding fails
-
decode
protected void decode() throws DecodeException
Computes the decoded form from the encoded form.- Specified by:
decode
in classAbstractLazyEncodedDataObject<byte[]>
- Throws:
DecodeException
- if less or more than 5 octets to be decoded
-
-