hypercast
Class Extension

java.lang.Object
  |
  +--hypercast.Extension
Direct Known Subclasses:
FSM_Extension, PayloadExtension, RouteRecord, SecurityExtension

public abstract class Extension
extends java.lang.Object

This class defines the function of OL_Message extension header. It contains extension type information and provides method to create an extension. Each concrete extension extends this class and implements the abstract methods defined in this class.


Field Summary
static byte FSM
           
static byte HEADER_NONE
          Extension type values.
static byte RAW_DATA
           
static byte ROUTE_RECORD
           
static byte SECURITY
           
 
Constructor Summary
Extension()
           
 
Method Summary
abstract  hypercast.Extension Clone()
          Return a new extension instance by cloning this extension.
static hypercast.Extension createExtension(byte extensiontype, byte[] contents)
          Constructs an Extension header object.
static hypercast.Extension createExtension(byte extensiontype, byte[] contents, hypercast.I_Node node)
          Constructs an Extension header object.
static hypercast.Extension createExtension(byte extensiontype, byte[] contents, hypercast.I_Node node, hypercast.KeyVault kv)
          Constructs an Extension header object.
static hypercast.Extension createExtension(byte extensiontype, byte[] contents, hypercast.I_Node node, hypercast.KeyVault kv, boolean isEncryptedFlag)
          Constructs an Extension header object.
static hypercast.Extension createExtension(byte extensiontype, byte[] contents, hypercast.KeyVault kv)
          Constructs an Extension header object.
abstract  byte getExtensionType()
          Return the value of the extension type field.
abstract  int getSize()
          Return the length of the byte array of this extension.
static boolean isValidHeader(byte extensiontype)
          Check a specified extension type is a valid one.
abstract  byte[] toByteArray()
          Convert this extension to a byte array.
 java.lang.String toString()
           
static java.lang.String typeToString(byte type)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEADER_NONE

public static final byte HEADER_NONE
Extension type values. These are essentially types, but the extension already has a type field (that should probably be called "sub-type")

See Also:
Constant Field Values

FSM

public static final byte FSM
See Also:
Constant Field Values

RAW_DATA

public static final byte RAW_DATA
See Also:
Constant Field Values

ROUTE_RECORD

public static final byte ROUTE_RECORD
See Also:
Constant Field Values

SECURITY

public static final byte SECURITY
See Also:
Constant Field Values
Constructor Detail

Extension

public Extension()
Method Detail

typeToString

public static java.lang.String typeToString(byte type)

createExtension

public static hypercast.Extension createExtension(byte extensiontype,
                                                  byte[] contents)
Constructs an Extension header object.

Parameters:
extensiontype - type of the extension to be created.
contents - byte array used to creat the extension.

createExtension

public static hypercast.Extension createExtension(byte extensiontype,
                                                  byte[] contents,
                                                  hypercast.I_Node node)
Constructs an Extension header object.

Parameters:
extensiontype - type of the extension to be created.
contents - byte array used to creat the extension.
node - I_Node object needed to construct logical address when an extension is created.

createExtension

public static hypercast.Extension createExtension(byte extensiontype,
                                                  byte[] contents,
                                                  hypercast.KeyVault kv)
Constructs an Extension header object.

Parameters:
extensiontype - type of the extension to be created.
contents - byte array used to creat the extension.
kv - key vault for security computation.

createExtension

public static hypercast.Extension createExtension(byte extensiontype,
                                                  byte[] contents,
                                                  hypercast.I_Node node,
                                                  hypercast.KeyVault kv)
Constructs an Extension header object.

Parameters:
extensiontype - type of the extension to be created.
contents - byte array used to creat the extension.
node - I_Node object needed to construct logical address when an extension is created.
kv - key vault for security computation.

createExtension

public static hypercast.Extension createExtension(byte extensiontype,
                                                  byte[] contents,
                                                  hypercast.I_Node node,
                                                  hypercast.KeyVault kv,
                                                  boolean isEncryptedFlag)
Constructs an Extension header object.

Parameters:
extensiontype - type of the extension to be created.
contents - byte array used to creat the extension.
node - I_Node object needed to construct logical address when an extension is created.
kv - key vault for security computation.
isEncryptedFlag - flag showing the given byte array is encrypted or plaintext. True means encrypted, false means plaintext.

isValidHeader

public static boolean isValidHeader(byte extensiontype)
Check a specified extension type is a valid one.

Parameters:
extensiontype - extension type to be checked.

getExtensionType

public abstract byte getExtensionType()
Return the value of the extension type field. TODO: this should be "getType" saying "getExtensionType" is redundant; obviously this is an extension object...


toByteArray

public abstract byte[] toByteArray()
Convert this extension to a byte array.


getSize

public abstract int getSize()
Return the length of the byte array of this extension.


Clone

public abstract hypercast.Extension Clone()
Return a new extension instance by cloning this extension.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object