com.cisco.provisioning.cpe.extensions.configuration
Class DHCPCmd

java.lang.Object
  extended by com.cisco.provisioning.cpe.extensions.configuration.DHCPCmd
All Implemented Interfaces:
com.cisco.csrc.encode.Encodable, Externalizable, Serializable

public class DHCPCmd
extends Object
implements Externalizable, com.cisco.csrc.encode.Encodable

The DHCPCmd encapsulates an operation to be performed by the BAC CNR extension point. The command consists of: extension point, dictionary, operation, option name, and (optionally) option value. The object is immutable.

See Also:
CNRExtPt, DHCPOper, DHCPDict, Serialized Form

Constructor Summary
DHCPCmd()
          No-arg constructor required by Exernalizable and Encodable
DHCPCmd(CNRExtPt extension, DHCPOper operation, DHCPDict dictionary, Object optionName)
          Constructor for command operations that do not support option values.
DHCPCmd(CNRExtPt extension, DHCPOper operation, DHCPDict dictionary, Object optionName, DHCPSpecialValue optionValue, String parameter)
          Constructor for command operations that support special option values.
DHCPCmd(CNRExtPt extension, DHCPOper operation, DHCPDict dictionary, Object optionName, Object optionValue)
          Constructor for command operations that support option values.
 
Method Summary
 void decode(ByteArrayInputStream in, com.cisco.csrc.encode.DataDecoder decoder)
          Decodes object's data and sets object's variables.
 void encode(ByteArrayOutputStream out, com.cisco.csrc.encode.DataEncoder encoder)
          Encodes object's data.
 boolean equals(Object object)
          Indicates whether some other object is "equal to" this one.
 boolean equalsOption(DHCPCmd cmd)
          Determines if another DHCPCmd object references the same dictionary and option name.
 DHCPDict getDictionary()
          Return the dictionary to which the command is to be applied.
 byte getDictionaryAsByte()
          Return the dictionary to which the command is to be applied.
 CNRExtPt getExtension()
          Return the extension to which the command is to be applied.
 byte getExtensionAsByte()
          Return the extension to which the command is to be applied.
 DHCPOper getOperation()
          Return the command operation.
 byte getOperationAsByte()
          Return the command operation.
 String getOptionName()
          Return the option name.
 CNROptionArgumentArray getOptionNameAsArgArray()
          Returns the option name as a CNROptionArgumentArray .
 CNRNames getOptionNameAsEnum()
          Return the option name as an enumeration constant.
 int getOptionNameAsEnumValue()
          Return the option name as an enumeration value.
 String getOptionValue()
          Return the singled-valued option value string.
 byte[] getOptionValueBytes()
          Return the singled-valued option value as bytes.
 String getSpecialParameter()
          Return the command special value parameter (null if none specified).
 DHCPSpecialValue getSpecialValue()
          Return the command special value (null if none specified).
 byte getSpecialValueAsByte()
          Return the command special value as byte (0 if none).
 int hashCode()
          Returns the hashcode for this DHCPData.
 boolean isOptionNameArgArray()
          Return true if the option name was specified as a CNROptionArgumentArray value.
 boolean isOptionNameEnumValue()
          Return true if the option name was specified as a CNRNames enum value.
 boolean isOptionValueBytes()
          Return true if the option value is a byte array.
 boolean isOptionValueString()
          Return true if the option value is a String.
 void readExternal(ObjectInput in)
          Externalizable interface.
 String toString()
          Return a string containing the contents of DHCPCmd in human-readable form.
 String toStringOptionValue()
          Return a string containing the DHCPCmd option value in human-readable form.
 void writeExternal(ObjectOutput out)
          Externalizable interface.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DHCPCmd

public DHCPCmd()
No-arg constructor required by Exernalizable and Encodable


DHCPCmd

public DHCPCmd(CNRExtPt extension,
               DHCPOper operation,
               DHCPDict dictionary,
               Object optionName)
Constructor for command operations that do not support option values.

Parameters:
extension - CNR extension point to perform the command
operation - CNR operation to be performed (only PUT_* allowed)
dictionary - CNR dictionary target for command
optionName - option name for command, can be string, CNRNames, or a CNROptionArgumentArray.
Throws:
IllegalArgumentException - if arguments are null or if arguments are invalid (e.g., operation not PUT_* or optionName not valid)

DHCPCmd

public DHCPCmd(CNRExtPt extension,
               DHCPOper operation,
               DHCPDict dictionary,
               Object optionName,
               Object optionValue)
Constructor for command operations that support option values. Use this constructor for single-valued option values expressed as a String or as a byte array.

Parameters:
extension - CNR extension point to perform the command
operation - CNR operation to be performed (only PUT_* allowed)
dictionary - CNR dictionary target for command
optionName - option name for command, can be string, CNRNames, or a CNROptionArgumentArray.
optionValue - option value of command, can be String or byte[], or DHCPSpecialValue
Throws:
IllegalArgumentException - if arguments are null or if arguments are invalid (e.g., operation not PUT_* or optionName not valid)

DHCPCmd

public DHCPCmd(CNRExtPt extension,
               DHCPOper operation,
               DHCPDict dictionary,
               Object optionName,
               DHCPSpecialValue optionValue,
               String parameter)
Constructor for command operations that support special option values. Use this constructor for DHCPSpecialValue option values.

Parameters:
extension - CNR extension point to perform the command
operation - CNR operation to be performed (only PUT_* allowed)
dictionary - CNR dictionary target for command
optionName - option name for command, can be string, CNRNames, or a CNROptionArgumentArray.
optionValue - option value of command
parameter - the parameter for the special value if needed
Throws:
IllegalArgumentException - if arguments are null or if arguments are invalid (e.g., operation not PUT_* or optionName not valid)
Method Detail

getExtension

public final CNRExtPt getExtension()
Return the extension to which the command is to be applied.

See Also:
CNRExtPt

getExtensionAsByte

public final byte getExtensionAsByte()
Return the extension to which the command is to be applied.

Returns:
byte The extension enumeration as a byte.
See Also:
DHCPDict

getDictionary

public final DHCPDict getDictionary()
Return the dictionary to which the command is to be applied.

See Also:
DHCPDict

getDictionaryAsByte

public final byte getDictionaryAsByte()
Return the dictionary to which the command is to be applied.

Returns:
byte The dictionary enumeration as a byte.
See Also:
DHCPDict

getOperation

public final DHCPOper getOperation()
Return the command operation.

See Also:
DHCPOper

getOperationAsByte

public final byte getOperationAsByte()
Return the command operation.

Returns:
byte The operation enumeration as a byte.
See Also:
DHCPOper

getSpecialValue

public final DHCPSpecialValue getSpecialValue()
Return the command special value (null if none specified).

See Also:
DHCPOper

getSpecialParameter

public final String getSpecialParameter()
Return the command special value parameter (null if none specified).

Returns:
String The special value parameter.
See Also:
DHCPSpecialValue

getSpecialValueAsByte

public final byte getSpecialValueAsByte()
Return the command special value as byte (0 if none).

Returns:
byte The operation enumeration as a byte.
See Also:
DHCPSpecialValue

getOptionName

public final String getOptionName()
Return the option name.


getOptionNameAsArgArray

public CNROptionArgumentArray getOptionNameAsArgArray()
Returns the option name as a CNROptionArgumentArray . Returns null if specified as a different type.

Returns:
the option name as a CNROptionArgumentArray . Returns null if specified as a different type.

getOptionNameAsEnum

public final CNRNames getOptionNameAsEnum()
Return the option name as an enumeration constant. If the option name was not specified as an enumeration constant when the command was constructed, null is returned.

Returns:
CNRNames The option name as an enumeration constant.
See Also:
CNRNames

getOptionNameAsEnumValue

public final int getOptionNameAsEnumValue()
Return the option name as an enumeration value. If the option name was not specified as an enumeration constant when the command was constructed, 0 is returned.

Returns:
int The option name as an enumeration value.
See Also:
CNRNames

getOptionValue

public final String getOptionValue()
Return the singled-valued option value string. If the option value was not specified as a string, then null is returned.


getOptionValueBytes

public final byte[] getOptionValueBytes()
Return the singled-valued option value as bytes. If the option value was not specified as bytes, then null is returned.


hashCode

public int hashCode()
Returns the hashcode for this DHCPData.

Overrides:
hashCode in class Object
Returns:
the hashcode for this DHCPData.

equals

public boolean equals(Object object)
Indicates whether some other object is "equal to" this one. We override this method to compare all the fields of DHCPCmd.

Overrides:
equals in class Object
Parameters:
object - to compare
Returns:
true if equal

equalsOption

public boolean equalsOption(DHCPCmd cmd)
Determines if another DHCPCmd object references the same dictionary and option name. This is support method for simplifying the iteration/comparison of DHCPCmd objects. This is identical to the equals() method except that it does not compare the option value.

Parameters:
cmd - the DHCPCmd object to compare
Returns:
true if DHCPCmd object refers to the same option

isOptionNameEnumValue

public boolean isOptionNameEnumValue()
Return true if the option name was specified as a CNRNames enum value.


isOptionNameArgArray

public boolean isOptionNameArgArray()
Return true if the option name was specified as a CNROptionArgumentArray value.

Returns:
true if the option name was specified as a CNROptionArgumentArray value, otherwise returns false.

isOptionValueBytes

public boolean isOptionValueBytes()
Return true if the option value is a byte array.


isOptionValueString

public boolean isOptionValueString()
Return true if the option value is a String.


toString

public String toString()
Return a string containing the contents of DHCPCmd in human-readable form. This is mainly a debugging tool.

Overrides:
toString in class Object
Returns:
String

toStringOptionValue

public String toStringOptionValue()
Return a string containing the DHCPCmd option value in human-readable form. This is used for logging and tracing where a human-readable form of the option value is more desirable. The string output is equivalent to the "value=" content of toString().

Returns:
String containing human-readable option value

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Externalizable interface. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - the stream to write the object to
Throws:
IOException - Includes any I/O exceptions that may occur

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Externalizable interface. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Specified by:
readExternal in interface Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
IOException - if I/O errors occur
ClassNotFoundException - If the class for an object being restored cannot be found.

encode

public void encode(ByteArrayOutputStream out,
                   com.cisco.csrc.encode.DataEncoder encoder)
Encodes object's data.

Specified by:
encode in interface com.cisco.csrc.encode.Encodable
Parameters:
out - the output stream to write to
encoder - the encoder to use

decode

public void decode(ByteArrayInputStream in,
                   com.cisco.csrc.encode.DataDecoder decoder)
Decodes object's data and sets object's variables.

Specified by:
decode in interface com.cisco.csrc.encode.Encodable
Parameters:
in - the input stream to write to
decoder - the decoder to use