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
           
protected  JField[] subFields
           
 
Constructor Summary
JField(AnnotatedField afield, JField[] children)
           
 
Method Summary
 java.lang.String getDisplay(JHeader header)
           
 int getLength(JHeader header)
           
 long getMask(JHeader header)
           
 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)
           
 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)
           
<T> T
getValue(java.lang.Class<T> c, JHeader header)
           
 java.lang.Object getValue(JHeader header)
           
 java.lang.String getValueDescription(JHeader header)
           
 boolean hasField(JHeader header)
           
 boolean hasSubFields()
          Does this field have subfields
 long longValue(JHeader header)
           
 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)
           
static void sortFieldByOffset(JField[] fields, JHeader header, boolean ascending)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subFields

protected JField[] subFields

style

protected JFormatter.Style style
Constructor Detail

JField

public JField(AnnotatedField afield,
              JField[] children)
Method Detail

sortFieldByOffset

public static void sortFieldByOffset(JField[] fields,
                                     JHeader header,
                                     boolean ascending)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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)
Parameters:
style -

getUnits

public java.lang.String getUnits(JHeader header)

hasField

public boolean hasField(JHeader header)

getDisplay

public java.lang.String getDisplay(JHeader header)

getLength

public int getLength(JHeader header)

getMask

public long getMask(JHeader header)

getOffset

public int getOffset(JHeader header)

getValueDescription

public java.lang.String getValueDescription(JHeader header)

getValue

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

getValue

public java.lang.Object getValue(JHeader header)

longValue

public long longValue(JHeader header)
Parameters:
header -
Returns: