PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/descriptor/ErrorDescriptor.java

http://mobicents.googlecode.com/
Java | 82 lines | 25 code | 11 blank | 46 comment | 1 complexity | f08b1301b5adae9c4aeb35cc4e870540 MD5 | raw file
 1package javax.megaco.message.descriptor;
 2
 3import java.io.Serializable;
 4
 5
 6import javax.megaco.message.Descriptor;
 7
 8/**
 9 * The class extends JAIN MEGACO Descriptor. This class describes the error
10 * descriptor.
11 */
12public class ErrorDescriptor extends Descriptor implements Serializable {
13
14	private int protErrorCode = -1;
15	private String errorString = null;
16
17	/**
18	 * Constructs a Error Descriptor. This contains the protocol specified error
19	 * code and optionally the error string qualifying the error code.
20	 * 
21	 * @param errorCode
22	 * @throws IllegalArgumentException
23	 *             - Thrown if an invalid error code is set.
24	 */
25	public ErrorDescriptor(int errorCode) throws IllegalArgumentException {
26		// FIXME: section 13.2 ... does not clear this...
27		this.protErrorCode = errorCode;
28	}
29
30	/**
31	 * This method cannot be overridden by the derived class. This method
32	 * returns that the descriptor identifier is of type Error descriptor. This
33	 * method overrides the corresponding method of the base class Descriptor.
34	 * 
35	 * @return Returns an integer value that identifies this object as the type
36	 *         of Error descriptor. It returns that it is Error Descriptor i.e.,
37	 *         M_ERROR_DESC.
38	 */
39	public int getDescriptorId() {
40		return super.descriptorId;
41	}
42
43	/**
44	 * This method cannot be overridden by the derived class. This method
45	 * returns the error code spcified by the Megaco protocol.
46	 * 
47	 * @return Returns an integer value that identifies the error code.
48	 */
49	public final int getProtErrorCode() {
50		return this.protErrorCode;
51	}
52
53	/**
54	 * This method cannot be overridden by the derived class. This method sets
55	 * the error string corresponding to the error code as specified by the
56	 * Megaco protocol.
57	 * 
58	 * @param errorStr
59	 *            Returns the string corresponding to the error code.
60	 * @throws IllegalArgumentException
61	 *             - Thrown if an invalid string is set.
62	 */
63	public final void setErrorString(java.lang.String errorStr) throws IllegalArgumentException {
64		if (errorStr.length() > 80) {
65			throw new IllegalArgumentException("Error String must nto be longer than 80 chars, see section 13.2 of RFC 3525");
66		}
67		this.errorString = errorStr;
68	}
69
70	/**
71	 * This method cannot be overridden by the derived class. This method
72	 * returns the error string corresponding to the error code as specified by
73	 * the Megaco protocol.
74	 * 
75	 * @return Returns the string corresponding to the error code. If the error
76	 *         string is not set then this method would return NULL.
77	 */
78	public final java.lang.String getErrorString() {
79		return this.errorString;
80	}
81
82}