Class Field<T>
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.field.Field<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
IDestructableField
,IField
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Field<T>
Creates a newField
in the given struct with the given type.void
int
Returns the required byte alignment for the field.Returns the name of the field.int
Returns the field offset, in bytes from the start of the struct.int
Returns the size of the field, in bytes.boolean
protected void
setFieldName(String fieldName)
void
setOffset(int offset)
Sets the field offset (bytes from the start of the struct).
-
Field Details
-
factory
-
offset
protected int offset
-
-
Constructor Details
-
Field
-
-
Method Details
-
get
-
hasDestructor
public boolean hasDestructor() -
destruct
- Specified by:
destruct
in interfaceIDestructableField
-
getRecordSize
public int getRecordSize()Description copied from interface:IField
Returns the size of the field, in bytes.- Specified by:
getRecordSize
in interfaceIField
-
getAlignment
public int getAlignment()Description copied from interface:IField
Returns the required byte alignment for the field.- Specified by:
getAlignment
in interfaceIField
-
create
Creates a newField
in the given struct with the given type.- Parameters:
struct
- the struct that will contain the newly-created field (must not have hadStructDef.done()
called on it yet).fieldType
- the data type for the contents of the newly created field- Returns:
- the newly-constructed field
-
setFieldName
-
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. -
getOffset
public final int getOffset()Description copied from interface:IField
Returns the field offset, in bytes from the start of the struct. -
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 interfaceIField
-