PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://mobicents.googlecode.com/
Java | 104 lines | 36 code | 15 blank | 53 comment | 7 complexity | 2b24c95224a91dc86771faa5200f6614 MD5 | raw file
  1package javax.megaco.message.descriptor;
  2
  3import java.io.Serializable;
  4
  5
  6import javax.megaco.MethodInvocationException;
  7import javax.megaco.message.Descriptor;
  8
  9/**
 10 * The class ModemParam shall be used to set the Modem Type in the Modem
 11 * Descriptor. This also takes the extension string if the modem type is set to
 12 * extension parameter.
 13 */
 14public class ModemParam implements Serializable {
 15
 16	private ModemType modemType = null;
 17	private String extModem;
 18
 19	/**
 20	 * Constructs a object of class ModemParam with ModemType. This constructor
 21	 * can take all values of modem type except {@link ModemType.EXT}.
 22	 * 
 23	 * @param modemType
 24	 * @throws IllegalArgumentException
 25	 *             - If the object of class ModemType is set to NULL or the
 26	 *             modem type is set to {@link ModemType.EXT}.
 27	 */
 28	public ModemParam(ModemType modemType)
 29
 30	throws IllegalArgumentException {
 31		if (modemType == null) {
 32			throw new IllegalArgumentException("ModemType must not be null");
 33		}
 34
 35		this.modemType = modemType;
 36	}
 37
 38	/**
 39	 * 
 40	 * Constructs a object of class ModemParam with extension string. This
 41	 * implicitly sets the modem type to {@link ModemType.EXT}.
 42	 * 
 43	 * @param extModem
 44	 *            - Sets the string for the extension of the modem type. The
 45	 *            extension string should be prefixed with "X-" or "X+". The
 46	 *            extension characters following the prefix should be at most of
 47	 *            6 characters. The extension string would be set only when the
 48	 *            modem type specifies {@link ModemType.EXT}.
 49	 * @throws IllegalArgumentException
 50	 *             - If the extension string passed to this method is NULL or if
 51	 *             the extension string is not in proper format. It should be
 52	 *             prefixed with either "X+" or "X-" followed by at most 6
 53	 *             characters.
 54	 */
 55	public ModemParam(java.lang.String extModem)
 56
 57	throws IllegalArgumentException {
 58		modemType = ModemType.EXT;
 59
 60		if (extModem == null) {
 61			throw new IllegalArgumentException("ExtModem must not be null");
 62		}
 63		// FIXME??
 64		DescriptorUtils.checkMethodExtensionRules(extModem);
 65		if (extModem.length() > 8) {
 66			throw new IllegalArgumentException("ExtModem length must nto exceed 8 characters");
 67		}
 68		this.extModem = extModem;
 69
 70	}
 71
 72	/**
 73	 * This method returns the identity of the modem type. The constants for the
 74	 * modem type are defined in ModemType.
 75	 * 
 76	 * @return Returns an integer value that identifies Modem type. It returns
 77	 *         one of the values defined in, ModemType.
 78	 */
 79	public ModemType getModemType() {
 80		return this.modemType;
 81	}
 82
 83	/**
 84	 * This method returns the extension string of the modem type. The extension
 85	 * string should be prefixed with "X-" or "X+". The extension characters
 86	 * following the prefix should be at most of 6 characters. The extension
 87	 * string would be set only when the modem type specifies
 88	 * MODEM_TYPE_EXTENSION.
 89	 * 
 90	 * @return Gets the string for the extension of the modem type. The
 91	 *         extension string would be set only when the modem type specifies
 92	 *         MODEM_TYPE_EXTENSION.
 93	 * @throws IllegalStateException
 94	 *             if the method has been called when the modem type denotes
 95	 *             anything other than MODEM_TYPE_EXT
 96	 */
 97	public java.lang.String getExtensionString() throws IllegalStateException {
 98		if (this.modemType.getModemType() != ModemType.M_EXT) {
 99			throw new IllegalStateException("ModemType must be: EXT");
100		}
101		return this.extModem;
102	}
103
104}