com.voytechs.jnetstream.primitive
Class AbstractStringPrimitive
java.lang.Object
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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
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
AbstractStringPrimitive
public AbstractStringPrimitive(int size)
AbstractStringPrimitive
public AbstractStringPrimitive(int size,
int byteOrder)
- Parameters:
-
- Throws:
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