com.voytechs.jnetstream.primitive
Class AbstractStringPrimitive

java.lang.Object
  extended by com.voytechs.jnetstream.primitive.AbstractStringPrimitive
All Implemented Interfaces:
MutablePrimitive, Primitive, PrimitiveDisplay, PrimitiveFactory, ProtocolPrimitive, ProtocolPrimitiveFactory
Direct Known Subclasses:
DNSNamePrimitive, StringPrimitive

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


Field Summary
protected  int byteOrder
           
protected  Primitive custom
           
protected  java.lang.String name
           
protected  int radix
           
protected  boolean sign
           
static boolean SIGN
           
protected  int size
           
protected  java.lang.String value
           
 
Fields inherited from interface com.voytechs.jnetstream.primitive.ProtocolPrimitive
BIG_ENDIAN, LITTLE_ENDIAN
 
Constructor Summary
AbstractStringPrimitive(int size)
           
AbstractStringPrimitive(int size, int byteOrder)
           
 
Method Summary
protected  void checkBoundaries(java.lang.String name)
           
 int compareTo(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 AbstractStringPrimitive
static java.lang.String prefixWithZeros(long v, int size)
           
 void setCustom(Primitive custom)
           
 void setRadix(int radix)
           
 void setSize(int size)
           
 void setValue(java.lang.Object value)
           
 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 String based primtives which writes out the primitive value to PacketOutpuStream.
 
Methods inherited from class java.lang.Object
clone, equals, 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

SIGN

public static final boolean SIGN
See Also:
Constant Field Values

name

protected java.lang.String name

size

protected int size

byteOrder

protected int byteOrder

sign

protected boolean sign

radix

protected int radix

custom

protected Primitive custom

value

protected java.lang.String value
Constructor Detail

AbstractStringPrimitive

public AbstractStringPrimitive(int size)

AbstractStringPrimitive

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

setSize

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

setValue

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

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

setRadix

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

getValue

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

setCustom

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

checkBoundaries

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

toString

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

toBinString

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

prefixWithZeros

public static java.lang.String prefixWithZeros(long v,
                                               int size)

compareTo

public int compareTo(java.lang.Object v)

write

public void write(PacketOutputStream out)
           throws java.io.IOException,
                  PrimitiveException
Base implementation for String 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

isMultiLine

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

toString

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

main

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

Parameters:
args - command line arguments