public final class Cause extends AbstractLazyEncodedByteArray implements FastSerializable
The API offered by this class is as if the type were specified in ASN.1 as follows.
Cause ::= SEQUENCE { codingStandard CodingStandard, location Location, recommendation Recommendation OPTIONAL, causeValue CauseValue, diagnostics OCTET STRING }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 ITU-T Q.763 (12/1999) §3.12 p26, ITU-T Q.850 (05/98) §2.1 p1, and 3GPP TS 24.008 V4.17.0 (2007-09) §10.5.4.11 pp368-373 | ||||||||
---|---|---|---|---|---|---|---|---|
8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | |
Octet 3 | ext. 0/1 | Coding standard | Spare 0 | Location | ||||
Octet 3a* | ext. 1 | Recommendation | ||||||
Octet 4 | ext. 1 | Cause value | ||||||
Octet 5.. | Diagnostic(s) if any |
Modifier and Type | Class and Description |
---|---|
static class |
Cause.CauseValue
Class CauseValue represents cause value constants.
|
static class |
Cause.CodingStandard
Enumeration of Coding Standard constants.
|
static class |
Cause.Location
Enumeration of Location constants.
|
static class |
Cause.Recommendation
Recommendation constants.
|
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and Description |
---|
Cause()
Constructs a new Cause object with no fields set.
|
Cause(byte[] data)
Constructs a new Cause object from network-encoded data.
|
Cause(byte[] data,
int start,
int len)
Constructs a new Cause object from part of network-encoded data.
|
Cause(Cause.CauseValue causeValue)
Constructs a new Cause object from the given argument,
with a CodingStandard of ITU_T, a Location of USER, a null Recommendation, and no diagnostics.
|
Cause(Cause.CodingStandard codingStandard,
Cause.Location location,
Cause.Recommendation recommendation,
Cause.CauseValue causeValue,
byte[] diagnostics)
Constructs a new Cause object from the given arguments.
|
Cause(DataInput in)
Constructs a new Cause 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.
|
Cause |
clone()
Constructs a copy of this object and everything reachable from it.
|
static Cause |
copyOf(Cause 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.
|
Cause.CauseValue |
getCauseValue()
Gets the value of the cause value.
|
Cause.CodingStandard |
getCodingStandard()
Gets the value of the coding standard.
|
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[] |
getDiagnostics()
Gets the value of the diagnostics.
|
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.
|
Cause.Location |
getLocation()
Gets the value of the location.
|
Cause.Recommendation |
getRecommendation()
Gets the value of the recommendation.
|
boolean |
hasCauseValue()
Tests whether the field CauseValue has a value.
|
boolean |
hasCodingStandard()
Tests whether the field CodingStandard has a value.
|
boolean |
hasDiagnostics()
Tests whether the field Diagnostics has a value.
|
boolean |
hasLocation()
Tests whether the field Location has a value.
|
boolean |
hasRecommendation()
Tests whether the field Recommendation has a value.
|
Cause |
setCauseValue(Cause.CauseValue value)
Sets the value of the cause value.
|
Cause |
setCodingStandard(Cause.CodingStandard value)
Sets the value of the coding standard.
|
Cause |
setDiagnostics(byte[] value)
Sets the value of the diagnostics.
|
Cause |
setLocation(Cause.Location value)
Sets the value of the location.
|
Cause |
setRecommendation(Cause.Recommendation value)
Sets the value of the recommendation.
|
void |
toStream(DataOutput out)
Serializes this object to a stream in a form suitable for reading by
Cause(DataInput) . |
checkDecode, checkModifyAndDecode
equals, hashCode, toString
checkModify, isReadOnly, setReadOnly
public Cause()
public Cause(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic Cause(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 Cause(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 Cause(Cause.CauseValue causeValue)
causeValue
- the cause. The value should be taken from one of the constants
defined in this class if the coding standard is Cause.CodingStandard.ITU_T
.NullPointerException
- if causeValue is null
public Cause(Cause.CodingStandard codingStandard, Cause.Location location, Cause.Recommendation recommendation, Cause.CauseValue causeValue, byte[] diagnostics)
codingStandard
- the coding standard by which the cause indicator is encodedlocation
- the location of the causerecommendation
- the recommendation of the causecauseValue
- the causediagnostics
- any diagnostics associated with the cause. Refer ITU-T Q.850 for encoding
of diagnostic information. Not all causes permit and not all protocols support
diagnostic information, in which case null
is an acceptable parameter
value, and is treated as if a zero-length byte array had been supplied.public void toStream(DataOutput out) throws IOException
Cause(DataInput)
.toStream
in interface FastSerializable
out
- the stream to write toIOException
- if an I/O error occurspublic boolean hasCodingStandard() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasLocation() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasRecommendation() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasCauseValue() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasDiagnostics() 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 Cause.CodingStandard getCodingStandard() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic Cause.Location getLocation() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic Cause.Recommendation getRecommendation() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic Cause.CauseValue getCauseValue() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic byte[] getDiagnostics() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic Cause setCodingStandard(Cause.CodingStandard value) throws IllegalStateException
value
- CodingStandard representation of the coding standardIllegalStateException
public Cause setLocation(Cause.Location value) throws IllegalStateException
value
- Location representation of the locationIllegalStateException
public Cause setRecommendation(Cause.Recommendation value) throws IllegalStateException
value
- Recommendation representation of the recommendationIllegalStateException
public Cause setCauseValue(Cause.CauseValue value) throws IllegalStateException
value
- CauseValue representation of the cause valueIllegalStateException
public Cause setDiagnostics(byte[] value) throws IllegalStateException
value
- byte[] representation of the diagnosticsIllegalStateException
public static Cause copyOf(Cause from)
from
- the object from which to copypublic Cause 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 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 consideredprotected void encode()
encode
in class AbstractLazyEncodedDataObject<byte[]>
protected void decode() throws DecodeException
decode
in class AbstractLazyEncodedDataObject<byte[]>
DecodeException
- if less than 2 octets to be decoded