java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.field.Field<T>
Type Parameters:
T -
All Implemented Interfaces:
IDestructableField, IField

public final class Field<T> extends Object implements IDestructableField
Used to represent a single field of an object stored in the database. Objects which store themselves in the database should store a set of static final FieldDefinitions at the top of their class definition to indicate their memory map. This serves as a standard way to document the memory map for such structs, provides access to the field offsets, and provides a convenience getter.

There are two ways to use this. Callers can either use the "get" method to access the value of the field, or can use the public "offset" attribute to perform the reads manually. The get function is more convenient but allocates objects and so should probably not be used for frequently-accessed fields or primitive types that would end up being autoboxed unnecessarily.

  • Field Details

    • factory

      public final ITypeFactory<T> factory
    • offset

      protected int offset
  • Constructor Details

  • Method Details

    • get

      public T get(Nd nd, long address)
    • hasDestructor

      public boolean hasDestructor()
    • destruct

      public void destruct(Nd nd, long address)
      Specified by:
      destruct in interface IDestructableField
    • getRecordSize

      public int getRecordSize()
      Description copied from interface: IField
      Returns the size of the field, in bytes.
      Specified by:
      getRecordSize in interface IField
    • getAlignment

      public int getAlignment()
      Description copied from interface: IField
      Returns the required byte alignment for the field.
      Specified by:
      getAlignment in interface IField
    • create

      public static <T> Field<T> create(StructDef<?> struct, StructDef<T> fieldType)
      Creates a new Field in the given struct with the given type.
      Parameters:
      struct - the struct that will contain the newly-created field (must not have had StructDef.done() called on it yet).
      fieldType - the data type for the contents of the newly created field
      Returns:
      the newly-constructed field
    • setFieldName

      protected final void setFieldName(String fieldName)
    • setOffset

      public final void setOffset(int offset)
      Description copied from interface: IField
      Sets the field offset (bytes from the start of the struct). This is invoked some time after field construction, after the sizes of all preceeding fields are known.
      Specified by:
      setOffset in interface IField
    • getOffset

      public final int getOffset()
      Description copied from interface: IField
      Returns the field offset, in bytes from the start of the struct.
      Specified by:
      getOffset in interface IField
    • getFieldName

      public final String getFieldName()
      Description copied from interface: IField
      Returns the name of the field. This is mainly used for error messages, debug output, and diagnostic tools. Meant to be programmer-readable but not user-readable.
      Specified by:
      getFieldName in interface IField