Class IMEIAddress

  • All Implemented Interfaces:
    DataObject, FastSerializable, Serializable

    public final class IMEIAddress
    extends AbstractLazyEncodedByteArray
    implements FastSerializable
    Class IMEIAddress represents both the IMEI and IMEISV types as defined in 3GPP TS 23.003. An IMEI address is 15 or 16 digits, comprising:
    • type allocation code (TAC), which is 8 digits;
    • serial number (SNR), which is 6 digits;
    • IMEISV: software version number (SVN), which is 2 digits
    • IMEI: check digit (CD)/spare digit (SD)

    The API offered by this class is as if the type were specified in ASN.1 as follows.

     IMEI ::= SEQUENCE {
        address DigitString
     }
    (The TAC, SNR and SVN/SD/CD are not separated in this class.) The class takes care of encoding the field values into a byte-array and decoding the 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) §6.2 p26-27
    87654321
    Octet 0TAC digit 2TAC digit 1
    Octet 1TAC digit 4TAC digit 3
    Octet 2TAC digit 6TAC digit 5
    Octet 3TAC digit 8TAC digit 7
    Octet 4SNR digit 2SNR digit 1
    Octet 5SNR digit 4SNR digit 3
    Octet 6SNR digit 6SNR digit 5
    Octet 7SVN digit 2/FillerSVN digit 1/Check Digit

    The length of the data encoding is 8 octets.

    Each digit of the address fields is encoded into a semi-octet. Unless overridden by a particular StringCodec, the filler is 0xF and the encoding to semi-octets is as tabulated below.

    Decoded character0123456789
    Encoded hexadecimal0123456789ABCDEF
    See Also:
    Serialized Form
    • Constructor Detail

      • IMEIAddress

        public IMEIAddress()
        Constructs a new IMEIAddress object with no fields set.
      • IMEIAddress

        public IMEIAddress​(byte[] data)
        Constructs a new IMEIAddress 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
      • IMEIAddress

        public IMEIAddress​(byte[] data,
                           int start,
                           int len)
        Constructs a new IMEIAddress object from part of network-encoded data. The part starts at index start and is len bytes long. The data is not decoded and might not be decodable.
        Parameters:
        data - network-encoded data
        start - starting offset of network-encoded data in byte array
        len - default length if not predictable
        Throws:
        NullPointerException - if data is null
        IllegalArgumentException - if len is negative
      • IMEIAddress

        public IMEIAddress​(String address)
        Constructs a new IMEIAddress object from given values for all fields.
        Parameters:
        address - the IMEI address
      • IMEIAddress

        public IMEIAddress​(String address,
                           StringCodec<IMEIAddress> Address_codec)
        Constructs a new IMEIAddress object from given arguments, using the given codecs for encoding fields of type String.
        Parameters:
        address - the IMEI address
        Address_codec - StringCodec for address
      • IMEIAddress

        public IMEIAddress​(DataInput in)
                    throws IOException
        Constructs a new IMEIAddress object from data deserialized from a stream that was written by toStream(DataOutput).
        Parameters:
        in - the stream to read from
        Throws:
        EOFException - if reading is pre-empted by end-of-file
        IOException - if the data cannot be read
    • Method Detail

      • hasAddress

        public boolean hasAddress()
                           throws DecodeException
        Tests whether the field Address has a value.
        Returns:
        whether the field has a value
        Throws:
        DecodeException - if encoded state cannot be decoded
      • getAddress

        public String getAddress​(StringCodec<IMEIAddress> codec)
                          throws DecodeException
        Gets the value of the IMEI address using the given codec. If the field Address 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 IMEI address
        Throws:
        DecodeException - if encoded state cannot be decoded
      • getAddressEncoded

        public byte[] getAddressEncoded()
        Gets a clone of the encoded value of the IMEI address.
        Returns:
        byte[] representation of the IMEI address
      • setAddressEncoded

        public IMEIAddress setAddressEncoded​(byte[] encoded)
        Sets the encoded value of the IMEI address to a clone of the given byte array.
        Parameters:
        encoded - byte[] representation of the IMEI address
        Returns:
        this
      • copyOf

        public static IMEIAddress copyOf​(IMEIAddress 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:
        IMEIAddress
      • 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 class AbstractFieldsObject
        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
      • getAddressCodec

        public StringCodec<IMEIAddress> getAddressCodec()
        Gets the codec used for field Address.
        Returns:
        StringCodec