org.jnetpcap.packet.annotate
Annotation Type Field


@Target(value={METHOD,TYPE,FIELD})
@Documented
@Retention(value=RUNTIME)
public @interface Field

Defines a header field's getter method. Any method annotated with Field annotation will be included in JFormatter output. The field annotation allows a number of constant properties about the field to be declared. By default, the method's name becomes the field name as well.

The Field annotation provides a way to set any of the field's properties statically. The value set using this annotation will be set permanently as a constant for that property. If the property is ommited, its default value will be used or if a instance method is defined that is marked with Dynamic annotation, then than method will be used at runtime to obtain the value for the property it generating values for. For example, the display field property which is used as text to display whenever a textual name for the field is needed, can be set statically using this annotation:

 @Field(display = "more descriptive name of the field")
 public int fieldA() {
        return 0;
 }
 
or the same property can be generated dynamically at runtime by ommiting the the annotation parameter "display" in this annotation and supplying a separate instance method which generates the value:
 @Dynamic(Property.DISPLAY)
 public String fieldADisplay() {
        return (fieldA() == 0) ? "FIELD_A" : "fieldA";
 }
 
Both Field.display and the runtime method can not be set at the same time. Again by default the name of the field is used as display of the field's name.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Optional Element Summary
 java.lang.String description
          A short description of the field's value.
 java.lang.String display
          Name of the field that will be displayed.
 java.lang.String format
          A formatting string for the value of the field.
 int length
          Static length of this field within the header in bits.
 long mask
          Sets which bits within the field are significant.
 java.lang.String name
          Name of the field.
 java.lang.String nicname
          A short name of the field to display.
 int offset
          Static offset of this field into the header in bits.
 java.lang.String parent
          Sets the parent field's name and implicitely declares this field to be a subfield of the parent.
 JFormatter.Priority priority
          A priority this field is assigned which is used in determining which field to include in output depending on what JFormat.Detail level the user has selected.
 java.lang.String units
          Units associated with the value of the field.
 

offset

public abstract int offset
Static offset of this field into the header in bits. This parameter specifies in bits, the exact offset of the annotated field within the current header. The value is constant. If offset of the field is not constant but varies and can only be determined at runtime, then this parameter should not be used. Instead use a method and mark it with @Dynamic(Property.OFFSET) annotation.

Returns:
offset into the header in bits
Default:
-1

length

public abstract int length
Static length of this field within the header in bits. This parameter specifies in bits, the exact length of the annotated field within the current header. The value is constant. If length of the field is not constant but varies and can only be determined at runtime, then this parameter should not be used. Instead use a method and mark it with @Dynamic(Property.LENGTH) annotation.

Returns:
length of the field in bits
Default:
-1

name

public abstract java.lang.String name
Name of the field. By default, the name of the field is determined implicitely by using the name of the method. This parameter allows the name of the field to be explicitely specified. The name of the field, must be unique within the same header and acts as a unique ID of the field.

Returns:
name of the field
Default:
""

display

public abstract java.lang.String display
Name of the field that will be displayed. The name is used by defaul if display parameter is not set. Display is only a text string that gets displayed as the name of the field. The actual content of this parameter have no baring on the name of the field.

Returns:
display string to use as a display for field name
Default:
""

nicname

public abstract java.lang.String nicname
A short name of the field to display. Nicname is similar to display parameter. It does not affect the name of the field and is only used for display purposes where appropriate.

Returns:
short name of the filed
Default:
""

format

public abstract java.lang.String format
A formatting string for the value of the field. Default is "%s".

Returns:
field's formatting string
Default:
"%s"

units

public abstract java.lang.String units
Units associated with the value of the field.

Returns:
string with the name of the units
Default:
""

description

public abstract java.lang.String description
A short description of the field's value.

Returns:
a string with value description
Default:
""

parent

public abstract java.lang.String parent
Sets the parent field's name and implicitely declares this field to be a subfield of the parent.

Returns:
name of the parent field this sub field is appart of
Default:
""

mask

public abstract long mask
Sets which bits within the field are significant. The mask is also used in displaying bitfields, where each set bit is reported as significant and non significant bits are skipped completely. Default is that all bits within the length of the field are significant.

Returns:
a bit mask which has significant bits set
Default:
-1L

priority

public abstract JFormatter.Priority priority
A priority this field is assigned which is used in determining which field to include in output depending on what JFormat.Detail level the user has selected. Default is Priority.MEDIUM.

Returns:
display priority of the field.
Default:
MEDIUM