org.jnetpcap.packet.structure
Class JField

java.lang.Object
  extended by org.jnetpcap.packet.structure.JField
Direct Known Subclasses:
DefaultField

public class JField
extends java.lang.Object

A field within a header. Field objects are used to describe the structure of a header to a formatter. The formatter iterates through all the fields it receives from a header and using formatting information stored in these fields, creates formatted output.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
protected  JFormatter.Style style
          The style.
protected  JField[] subFields
          The sub fields.
 
Constructor Summary
JField(AnnotatedField afield, JField[] children)
          Instantiates a new j field.
 
Method Summary
 java.lang.String getDisplay(JHeader header)
          Gets the display.
 int getLength(JHeader header)
          Gets the length.
 long getMask(JHeader header)
          Gets the mask.
 java.lang.String getName()
          Gets the full name of this field
 java.lang.String getNicname()
          Gets the nicname of this field.
 int getOffset(JHeader header)
          Gets the offset.
 JField getParent()
          If this field is a sub-field, this method returns a reference to the parent field.
 JFormatter.Priority getPriority()
          Gets the current field's priority.
 JFormatter.Style getStyle()
          Formatting style for this field.
 JField[] getSubFields()
          Gets the sub-fields.
 java.lang.String getUnits(JHeader header)
          Gets the units.
<T> T
getValue(java.lang.Class<T> c, JHeader header)
          Gets the value.
 java.lang.Object getValue(JHeader header)
          Gets the value.
 java.lang.String getValueDescription(JHeader header)
          Gets the value description.
 boolean hasField(JHeader header)
          Checks for field.
 boolean hasSubFields()
          Does this field have subfields.
 long longValue(JHeader header)
          Long value.
 void setParent(JField parent)
          Sets the parent of this sub-field and only when this field is a sub-field.
 void setStyle(JFormatter.Style style)
          Sets the style.
static void sortFieldByOffset(JField[] fields, JHeader header, boolean ascending)
          Sort field by offset.
 java.lang.String toString()
          To string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subFields

protected JField[] subFields
The sub fields.


style

protected JFormatter.Style style
The style.

Constructor Detail

JField

public JField(AnnotatedField afield,
              JField[] children)
Instantiates a new j field.

Parameters:
afield - the afield
children - the children
Method Detail

sortFieldByOffset

public static void sortFieldByOffset(JField[] fields,
                                     JHeader header,
                                     boolean ascending)
Sort field by offset.

Parameters:
fields - the fields
header - the header
ascending - the ascending

toString

public java.lang.String toString()
To string.

Overrides:
toString in class java.lang.Object
Returns:
the string
See Also:
Object.toString()

getSubFields

public JField[] getSubFields()
Gets the sub-fields.

Returns:
array of subfields

getName

public final java.lang.String getName()
Gets the full name of this field

Returns:
the name

getNicname

public java.lang.String getNicname()
Gets the nicname of this field.

Returns:
the nicname

getParent

public final JField getParent()
If this field is a sub-field, this method returns a reference to the parent field.

Returns:
the parent

getPriority

public JFormatter.Priority getPriority()
Gets the current field's priority. Formatters determine if fields should be included in the output based on priorities

Returns:
the priority

getStyle

public JFormatter.Style getStyle()
Formatting style for this field.

Returns:
the style

hasSubFields

public boolean hasSubFields()
Does this field have subfields.

Returns:
true means has sub-fields, otherwise false

setParent

public final void setParent(JField parent)
Sets the parent of this sub-field and only when this field is a sub-field.

Parameters:
parent - the parent to set

setStyle

public void setStyle(JFormatter.Style style)
Sets the style.

Parameters:
style - the new style

getUnits

public java.lang.String getUnits(JHeader header)
Gets the units.

Parameters:
header - the header
Returns:
the units

hasField

public boolean hasField(JHeader header)
Checks for field.

Parameters:
header - the header
Returns:
true, if successful

getDisplay

public java.lang.String getDisplay(JHeader header)
Gets the display.

Parameters:
header - the header
Returns:
the display

getLength

public int getLength(JHeader header)
Gets the length.

Parameters:
header - the header
Returns:
the length

getMask

public long getMask(JHeader header)
Gets the mask.

Parameters:
header - the header
Returns:
the mask

getOffset

public int getOffset(JHeader header)
Gets the offset.

Parameters:
header - the header
Returns:
the offset

getValueDescription

public java.lang.String getValueDescription(JHeader header)
Gets the value description.

Parameters:
header - the header
Returns:
the value description

getValue

public <T> T getValue(java.lang.Class<T> c,
                      JHeader header)
Gets the value.

Type Parameters:
T - the generic type
Parameters:
c - the c
header - the header
Returns:
the value

getValue

public java.lang.Object getValue(JHeader header)
Gets the value.

Parameters:
header - the header
Returns:
the value

longValue

public long longValue(JHeader header)
Long value.

Parameters:
header - the header
Returns:
the long