com.voytechs.jnetstream.primitive
Class AddressPrimitive

java.lang.Object
  extended by com.voytechs.jnetstream.primitive.AbstractAddressPrimitive
      extended by com.voytechs.jnetstream.primitive.AddressPrimitive
All Implemented Interfaces:
MutablePrimitive, NumberPrimitive, Primitive, PrimitiveDisplay, PrimitiveFactory, ProtocolPrimitive, ProtocolPrimitiveFactory

public class AddressPrimitive
extends AbstractAddressPrimitive
implements NumberPrimitive


Field Summary
static int BYTE_ORDER
           
static int DEFAULT_SIZE
           
static java.lang.String NAME
           
 
Fields inherited from class com.voytechs.jnetstream.primitive.AbstractAddressPrimitive
byteOrder, custom, format, name, radix, separator, sign, size, value
 
Fields inherited from interface com.voytechs.jnetstream.primitive.ProtocolPrimitive
BIG_ENDIAN, LITTLE_ENDIAN
 
Constructor Summary
AddressPrimitive()
           
AddressPrimitive(int size, boolean sign)
           
AddressPrimitive(int size, boolean sign, int byteOrder)
           
AddressPrimitive(PacketInputStream in)
           
 
Method Summary
 Primitive buildPrimitive(int size, boolean sign)
           
 ProtocolPrimitive buildProtocolPrimitive(int size, boolean sign, int byteOrder)
           
 java.lang.String getName()
           
 int hashCode()
          We need to override this method so that we can do Hashtable lookups on different Primitive object types.
 long longValue()
           
static void main(java.lang.String[] args)
          Test function for AddressPrimitive
 void setValue(PacketInputStream in)
          Sets the value of the primitive from packet stream.
static java.lang.String toString(PacketInputStream in)
           
 
Methods inherited from class com.voytechs.jnetstream.primitive.AbstractAddressPrimitive
checkBoundaries, equals, getByteOrder, getRadix, getSign, getSize, getValue, isMultiLine, setCustom, setRadix, setSeparator, setSize, setValue, toBin, toBinString, toString, toString, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

DEFAULT_SIZE

public static final int DEFAULT_SIZE
See Also:
Constant Field Values

BYTE_ORDER

public static final int BYTE_ORDER
See Also:
Constant Field Values
Constructor Detail

AddressPrimitive

public AddressPrimitive()
Parameters:
-
Throws:

AddressPrimitive

public AddressPrimitive(int size,
                        boolean sign)
                 throws PrimitiveException
Throws:
PrimitiveException

AddressPrimitive

public AddressPrimitive(int size,
                        boolean sign,
                        int byteOrder)
                 throws PrimitiveException
Throws:
PrimitiveException

AddressPrimitive

public AddressPrimitive(PacketInputStream in)
                 throws java.io.IOException,
                        EOPacket,
                        EOPacketStream,
                        PrimitiveException
Throws:
java.io.IOException
EOPacket
EOPacketStream
PrimitiveException
Method Detail

setValue

public void setValue(PacketInputStream in)
              throws java.io.IOException,
                     EOPacket,
                     EOPacketStream,
                     PrimitiveException
Sets the value of the primitive from packet stream. Data is extracted according to the byte order specified. Also size number of bits are extracted. Note: Current implementation does not support non standard bit size in Little endian mode. That is sizes other then 32, 16, or 8 bits in little endian mode will throw an exception. This should be corrected in future releases. (Its hard to read bits in non big-endian order, but not impossible.)

Specified by:
setValue in interface ProtocolPrimitive
Throws:
PrimitiveException
java.io.IOException
EOPacket
EOPacketStream

buildPrimitive

public Primitive buildPrimitive(int size,
                                boolean sign)
                         throws PrimitiveException
Specified by:
buildPrimitive in interface PrimitiveFactory
Throws:
PrimitiveException

buildProtocolPrimitive

public ProtocolPrimitive buildProtocolPrimitive(int size,
                                                boolean sign,
                                                int byteOrder)
                                         throws PrimitiveException
Specified by:
buildProtocolPrimitive in interface ProtocolPrimitiveFactory
Throws:
PrimitiveException

toString

public static java.lang.String toString(PacketInputStream in)
                                 throws java.io.IOException,
                                        EOPacket,
                                        EOPacketStream
Throws:
java.io.IOException
EOPacket
EOPacketStream

longValue

public long longValue()
Specified by:
longValue in interface NumberPrimitive

hashCode

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

Overrides:
hashCode in class AbstractAddressPrimitive

main

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

Parameters:
args - command line arguments

getName

public java.lang.String getName()
Specified by:
getName in interface ProtocolPrimitiveFactory