com.voytechs.jnetstream.primitive
Class AbstractAddressPrimitive

java.lang.Object
  extended by com.voytechs.jnetstream.primitive.AbstractAddressPrimitive
All Implemented Interfaces:
MutablePrimitive, Primitive, PrimitiveDisplay, PrimitiveFactory, ProtocolPrimitive, ProtocolPrimitiveFactory
Direct Known Subclasses:
AddressPrimitive, HexdumpPrimitive, IpAddressPrimitive, IpNetmaskPrimitive, MacAddressPrimitive

public abstract class AbstractAddressPrimitive
extends java.lang.Object
implements ProtocolPrimitive, ProtocolPrimitiveFactory, PrimitiveDisplay, MutablePrimitive


Field Summary
protected  int byteOrder
           
protected  Primitive custom
           
protected  char[] format
           
protected  java.lang.String name
           
protected  int radix
           
protected  char separator
           
protected  boolean sign
           
protected  int size
           
protected  Address value
           
 
Fields inherited from interface com.voytechs.jnetstream.primitive.ProtocolPrimitive
BIG_ENDIAN, LITTLE_ENDIAN
 
Constructor Summary
AbstractAddressPrimitive(int size)
           
AbstractAddressPrimitive(int size, int byteOrder)
           
 
Method Summary
protected  void checkBoundaries(java.lang.String name)
           
 boolean equals(java.lang.Object v)
           
 int getByteOrder()
          Use the getByteOrder() method to get the byte order encoding of the data.
 int getRadix()
           
 boolean getSign()
           
 int getSize()
           
 java.lang.Object getValue()
           
 int hashCode()
          We need to override this method so that we can do Hashtable lookups on different Primitive object types.
 boolean isMultiLine()
           
static void main(java.lang.String[] args)
          Test function for AbstractAddressPrimitive
 void setCustom(Primitive custom)
           
 void setRadix(int radix)
           
 void setSeparator(char sep)
           
 void setSize(int size)
           
 void setValue(java.lang.Object value)
           
 java.lang.String toBin(byte[] a)
           
 java.lang.String toBinString()
           
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String prefix, boolean indentFirstLine)
           
 void write(PacketOutputStream out)
          Base implementation for Address based primtives which writes out the primitive value to PacketOutpuStream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.voytechs.jnetstream.primitive.ProtocolPrimitive
setValue
 
Methods inherited from interface com.voytechs.jnetstream.primitive.ProtocolPrimitiveFactory
buildProtocolPrimitive, getName
 
Methods inherited from interface com.voytechs.jnetstream.primitive.PrimitiveFactory
buildPrimitive
 

Field Detail

size

protected int size

sign

protected boolean sign

radix

protected int radix

byteOrder

protected int byteOrder

value

protected Address value

separator

protected char separator

format

protected char[] format

custom

protected Primitive custom

name

protected java.lang.String name
Constructor Detail

AbstractAddressPrimitive

public AbstractAddressPrimitive(int size)

AbstractAddressPrimitive

public AbstractAddressPrimitive(int size,
                                int byteOrder)
Parameters:
-
Throws:
Method Detail

getByteOrder

public int getByteOrder()
Description copied from interface: ProtocolPrimitive
Use the getByteOrder() method to get the byte order encoding of the data. Although internally all values are converted to Java network order (BIG Endian), this is more important for reading and writting to PacketStreams.

Specified by:
getByteOrder in interface ProtocolPrimitive

getSize

public int getSize()
Specified by:
getSize in interface Primitive

getSign

public boolean getSign()
Specified by:
getSign in interface Primitive

getRadix

public int getRadix()
Specified by:
getRadix in interface PrimitiveDisplay

setSeparator

public void setSeparator(char sep)

setCustom

public void setCustom(Primitive custom)
Specified by:
setCustom in interface MutablePrimitive

setRadix

public void setRadix(int radix)
Specified by:
setRadix in interface PrimitiveDisplay

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface Primitive

checkBoundaries

protected void checkBoundaries(java.lang.String name)
                        throws PrimitiveException
Throws:
PrimitiveException

setValue

public void setValue(java.lang.Object value)
Specified by:
setValue in interface MutablePrimitive

setSize

public void setSize(int size)
             throws PrimitiveException
Specified by:
setSize in interface MutablePrimitive
Throws:
PrimitiveException

isMultiLine

public boolean isMultiLine()
Specified by:
isMultiLine in interface PrimitiveDisplay

toString

public java.lang.String toString()
Specified by:
toString in interface PrimitiveDisplay
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String prefix,
                                 boolean indentFirstLine)
Specified by:
toString in interface PrimitiveDisplay

toBinString

public java.lang.String toBinString()
Specified by:
toBinString in interface PrimitiveDisplay

toBin

public java.lang.String toBin(byte[] a)

equals

public boolean equals(java.lang.Object v)
Overrides:
equals in class java.lang.Object

write

public void write(PacketOutputStream out)
           throws java.io.IOException,
                  PrimitiveException
Base implementation for Address based primtives which writes out the primitive value to PacketOutpuStream.

Specified by:
write in interface ProtocolPrimitive
Parameters:
out - OutputStream to write out the address primitive.
Throws:
java.io.IOException - If any I/O errors.
PrimitiveException - If any primitive incompatibilities araise.

hashCode

public int hashCode()
We need to override this method so that we can do Hashtable lookups on different Primitive object types.

Overrides:
hashCode in class java.lang.Object

main

public static void main(java.lang.String[] args)
Test function for AbstractAddressPrimitive

Parameters:
args - command line arguments