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

java.lang.Object
  extended by com.cisco.provisioning.cpe.extensions.configuration.AbstractTFTPFile
      extended by com.cisco.provisioning.cpe.extensions.configuration.SimpleTFTPFile
All Implemented Interfaces:
com.cisco.csrc.encode.Encodable, com.cisco.csrc.util.Displayable, TFTPFile, Externalizable, Serializable

public class SimpleTFTPFile
extends AbstractTFTPFile

Simple TFTP file. This class provides an implementation of a TFTPFile interface for named or unamed TFTP files that can be constructed from a byte[] array at creation time. No validation, generation, or mixing operations are required.

See Also:
AbstractTFTPFile, TFTPFile, Serialized Form

Constructor Summary
SimpleTFTPFile()
          No-arg constructor.
SimpleTFTPFile(byte[] fileBytes)
          Use this constructor when no filename tag is used and the configuration file bytes is known at construction time.
SimpleTFTPFile(String filename, byte[] fileBytes)
          Use this constructor when the filename and configuration file bytes are known at construction time.
 
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.
 void generate()
          Generate the TFTP file.
 void mix(String ipAddress, CSRCProperties properties)
          Perform DPE mixing.
 void readExternal(ObjectInput in)
          Externalizable interface.
 void validate()
          Validate the TFTP file.
 void writeExternal(ObjectOutput out)
          Externalizable interface.
 
Methods inherited from class com.cisco.provisioning.cpe.extensions.configuration.AbstractTFTPFile
display, equals, getFile, getFilename, getProperties, getProperty, hashCode, paramString, setProperty, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTFTPFile

public SimpleTFTPFile()
No-arg constructor. Not all TFTPFile objects will have a filename tag or know their configuration file data at construction time. It is expected that addtional methods will be provided by the subclass to create the configuration data.


SimpleTFTPFile

public SimpleTFTPFile(byte[] fileBytes)
Use this constructor when no filename tag is used and the configuration file bytes is known at construction time.

Parameters:
fileBytes -

SimpleTFTPFile

public SimpleTFTPFile(String filename,
                      byte[] fileBytes)
Use this constructor when the filename and configuration file bytes are known at construction time.

Parameters:
filename -
fileBytes -
Method Detail

validate

public void validate()
              throws InvalidConfigException
Validate the TFTP file. This method implements any validation of the TFTP file that is required during RDU configuration generation. Optional.

Specified by:
validate in interface TFTPFile
Specified by:
validate in class AbstractTFTPFile
Throws:
InvalidConfigException - if any errors are encountered during the validation.

generate

public void generate()
              throws InvalidConfigException
Generate the TFTP file. This method implements any post-processing of the TFTP file that is required during RDU configuration generation. Optional.

Specified by:
generate in interface TFTPFile
Specified by:
generate in class AbstractTFTPFile
Throws:
InvalidConfigException - if any errors are encountered during the generation.

mix

public void mix(String ipAddress,
                CSRCProperties properties)
         throws InvalidConfigException
Perform DPE mixing. This method is invoked prior to the file being sent to the device. Perform any mixing operations required. Optional.

Specified by:
mix in interface TFTPFile
Specified by:
mix in class AbstractTFTPFile
Parameters:
ipAddress - of the device requesting the TFTP file
properties - relevant to mixing operation
Throws:
InvalidConfigException - if any errors are encountered during the mixing.

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
Overrides:
readExternal in class AbstractTFTPFile
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.

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
Overrides:
writeExternal in class AbstractTFTPFile
Parameters:
out - the stream to write the object to
Throws:
IOException - Includes any I/O exceptions that may occur

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
Overrides:
encode in class AbstractTFTPFile
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
Overrides:
decode in class AbstractTFTPFile
Parameters:
in - the input stream to write to
decoder - the decoder to use