/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

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