Class RPCause
- java.lang.Object
-
- com.opencloud.util.AbstractDataObject
-
- com.opencloud.util.AbstractFieldsObject
-
- AbstractEncodedDataObject<T>
-
- AbstractLazyEncodedDataObject<byte[]>
-
- AbstractLazyEncodedByteArray
-
- com.opencloud.slee.resources.in.datatypes.sms.RPCause
-
- All Implemented Interfaces:
DataObject
,FastSerializable
,Serializable
public final class RPCause extends AbstractLazyEncodedByteArray implements FastSerializable
Class RPCause represents the cause of a relay protocol error. It represents the ASN.1 OCTET STRING type CAP-datatypes.RPCause.The API offered by this class is as if the type were specified in ASN.1 as follows.
RPCause ::= SEQUENCE { causeValue CauseValue, diagnostic INTEGER (0..255) OPTIONAL }
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.011 V8.2.0 (2009-06) §8.2.5.4 pp39-41 8 7 6 5 4 3 2 1 1 octet Ext? Cause value 1 octet* Diagnostic if any
The octet numbering in the above table is that used in 3GPP TS 24.011 version 8.2.0 (2009-06). Field names ending in ? are booleans: 1 for true, 0 for false. The optional diagnostic is present iff the Ext bit is 1. (This is different from what the standard says about the Ext bit, because what the standard says is nonsense and google found some code here http://www.mail-archive.com/wireshark-dev@wireshark.org/msg00580.html that does make sense.)- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RPCause.CauseValue
Cause value constants.
-
Field Summary
-
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 RPCause()
Constructs a new RPCause object with no fields set.RPCause(byte[] data)
Constructs a new RPCause object from network-encoded data.RPCause(byte[] data, int start, int len)
Constructs a new RPCause object from part of network-encoded data.RPCause(RPCause.CauseValue causeValue)
Constructs a new RPCause object from the given argument, with no diagnostic.RPCause(RPCause.CauseValue causeValue, int diagnostic)
Constructs a new RPCause object from the given arguments.RPCause(DataInput in)
Constructs a new RPCause object from data deserialized from a stream that was written bytoStream(DataOutput)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkFieldsSet()
Checks that all mandatory fields are present.RPCause
clone()
Constructs a copy of this object and everything reachable from it.static RPCause
copyOf(RPCause 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.RPCause.CauseValue
getCauseValue()
Gets the value of the cause value.int
getDiagnostic()
Gets the value of any diagnostic.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.boolean
hasCauseValue()
Tests whether the field CauseValue has a value.boolean
hasDiagnostic()
Tests whether the field Diagnostic has a value.RPCause
setCauseValue(RPCause.CauseValue value)
Sets the value of the cause value.RPCause
setDiagnostic(int value)
Sets the value of any diagnostic.RPCause
setDiagnosticPresent(boolean flag)
Sets the presence or absence of the field Diagnostic.void
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading byRPCause(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
-
-
-
-
Constructor Detail
-
RPCause
public RPCause()
Constructs a new RPCause object with no fields set.
-
RPCause
public RPCause(byte[] data)
Constructs a new RPCause 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
-
RPCause
public RPCause(byte[] data, int start, int len)
Constructs a new RPCause 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
-
RPCause
public RPCause(DataInput in) throws IOException
Constructs a new RPCause 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
-
RPCause
public RPCause(RPCause.CauseValue causeValue)
Constructs a new RPCause object from the given argument, with no diagnostic.- Parameters:
causeValue
- the cause
-
RPCause
public RPCause(RPCause.CauseValue causeValue, int diagnostic)
Constructs a new RPCause object from the given arguments.- Parameters:
causeValue
- the causediagnostic
- the diagnostic associated with the cause. Not all causes permit and not all protocols support diagnostic information, in which case don't use this constructor.
-
-
Method Detail
-
toStream
public void toStream(DataOutput out) throws IOException
Serializes this object to a stream in a form suitable for reading byRPCause(DataInput)
.- Specified by:
toStream
in interfaceFastSerializable
- Parameters:
out
- the stream to write to- Throws:
IOException
- if an I/O error occurs
-
hasCauseValue
public boolean hasCauseValue() throws DecodeException
Tests whether the field CauseValue has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
hasDiagnostic
public boolean hasDiagnostic() throws DecodeException
Tests whether the field Diagnostic has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setDiagnosticPresent
public RPCause setDiagnosticPresent(boolean flag) throws IllegalStateException
Sets the presence or absence of the field Diagnostic.- 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
-
getCauseValue
public RPCause.CauseValue getCauseValue() throws DecodeException
Gets the value of the cause value.- Returns:
- CauseValue representation of the cause value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getDiagnostic
public int getDiagnostic() throws DecodeException
Gets the value of any diagnostic.- Returns:
- int representation of any diagnostic
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setCauseValue
public RPCause setCauseValue(RPCause.CauseValue value) throws IllegalStateException
Sets the value of the cause value.- Parameters:
value
- CauseValue representation of the cause value- Returns:
- this
- Throws:
IllegalStateException
-
setDiagnostic
public RPCause setDiagnostic(int value) throws IllegalStateException
Sets the value of any diagnostic.- Parameters:
value
- int representation of any diagnostic- Returns:
- this
- Throws:
IllegalStateException
-
copyOf
public static RPCause copyOf(RPCause 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:
- RPCause
-
clone
public RPCause 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
-
encode
protected void encode() throws EncodeException
Computes the encoded form from the decoded form.- Specified by:
encode
in classAbstractLazyEncodedDataObject<byte[]>
- Throws:
EncodeException
- if encoding fails
-
decode
protected void decode()
Computes the decoded form from the encoded form.- Specified by:
decode
in classAbstractLazyEncodedDataObject<byte[]>
-
-