org.mmbase.bridge
Interface Field

All Superinterfaces:
Comparable<Field>, Descriptor
All Known Implementing Classes:
AbstractField, BasicField, CoreField, DataTypeField, FieldDefs, FieldWrapper, MockField, MockNodeManager.SystemField, VirtualNodeManagerField

public interface Field
extends Descriptor, Comparable<Field>

This interface represents a node's field type information object.

Version:
$Id: Field.java 41862 2010-04-13 09:32:29Z michiel $
Author:
Pierre van Rooden, Jaco de Groot

Field Summary
static int STATE_PERSISTENT
          A field's state is 'persistent' if it is persistent in storage.
static int STATE_SYSTEM
          A field's state is 'system' if it is persistent in storage, but probably not editable by users (The default value of isReadOnly() is true).
static int STATE_SYSTEM_VIRTUAL
          A field's state is 'system virtual' if it is not persistent in storage, and probably used for administration purposes only.
static int STATE_UNKNOWN
          The field's state when it is not (yet) known.
static int STATE_VIRTUAL
          A field's state is 'virtual' if it is not persistent in storage.
static int TYPE_BINARY
          MMBase base type identifier for the binary (byte[]) data type
static int TYPE_BOOLEAN
          MMBase base type identifier for the Boolean data type
static int TYPE_BYTE
          Deprecated. use TYPE_BINARY
static int TYPE_DATETIME
          MMBase base type identifier for the Date data type
static int TYPE_DECIMAL
           
static int TYPE_DOUBLE
          MMBase base type identifier for the Double data type
static int TYPE_FLOAT
          MMBase base type identifier for the Float data type
static int TYPE_INTEGER
          MMBase base type identifier for the Integer data type
static int TYPE_LIST
          MMBase base type identifier for the List data type
static int TYPE_LONG
          MMBase base type identifier for the Long data type
static int TYPE_NODE
          MMBase base type identifier for the Node data type
static int TYPE_STRING
          MMBase base type identifier for the String data type
static int TYPE_UNKNOWN
          MMBase base type identifier for data types whose type is unknown
static int TYPE_XML
          MMBase base type identifier for the DOM Document data type
 
Method Summary
 DataType getDataType()
          Returns the data type this field contains.
 int getEditPosition()
          Retrieve the position of the field when editing.
 String getGUIType()
          Deprecated. use getDataType() and Descriptor.getName()
 int getListItemType()
          If the type of this field is TYPE_LIST, this method returns the MMBase base type for the list elements.
 int getListPosition()
          Retrieve the position of the field when listing.
 int getMaxLength()
          Returns the maximum length of data this field can contain.
 NodeManager getNodeManager()
          Returns the node manager this field belongs to.
 int getSearchPosition()
          Retrieve the position of the field when searching.
 int getState()
          Returns this field's state identifier (STATE_VIRTUAL, STATE_PERSISTENT, STATE_SYSTEM or STATE_SYSTEM_VIRTUAL, in errorneous sitations it may return STATE_UNKNOWN)
 int getStoragePosition()
          Retrieve the position of the field in the database table.
 int getType()
          Returns the identifier for the MMBase base type for this field.
 boolean hasIndex()
          Returns whether this field is a key field, meaning that the storage layer should define an index for it, allowing optimization with search and sort actions.
 boolean isReadOnly()
          Returns whether a field is 'read only' - that is, a user cannot edit it.
 boolean isRequired()
          Returns whether this field is required (should have content).
 boolean isUnique()
          Returns whether this field is part of a unique key (a set of fields whose combined content should occur only once).
 boolean isVirtual()
          A field's state is 'virtual' if it is not persistent in storage.
 Collection<String> validate(Object value)
          Checks whether a given value is valid for this field.
 
Methods inherited from interface org.mmbase.bridge.Descriptor
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

TYPE_STRING

static final int TYPE_STRING
MMBase base type identifier for the String data type

See Also:
Constant Field Values

TYPE_INTEGER

static final int TYPE_INTEGER
MMBase base type identifier for the Integer data type

See Also:
Constant Field Values

TYPE_BINARY

static final int TYPE_BINARY
MMBase base type identifier for the binary (byte[]) data type

See Also:
Constant Field Values

TYPE_BYTE

@Deprecated
static final int TYPE_BYTE
Deprecated. use TYPE_BINARY
MMBase base type identifier for the binary (byte[]) data type

See Also:
Constant Field Values

TYPE_FLOAT

static final int TYPE_FLOAT
MMBase base type identifier for the Float data type

See Also:
Constant Field Values

TYPE_DOUBLE

static final int TYPE_DOUBLE
MMBase base type identifier for the Double data type

See Also:
Constant Field Values

TYPE_LONG

static final int TYPE_LONG
MMBase base type identifier for the Long data type

See Also:
Constant Field Values

TYPE_XML

static final int TYPE_XML
MMBase base type identifier for the DOM Document data type

See Also:
Constant Field Values

TYPE_NODE

static final int TYPE_NODE
MMBase base type identifier for the Node data type

See Also:
Constant Field Values

TYPE_DATETIME

static final int TYPE_DATETIME
MMBase base type identifier for the Date data type

Since:
MMBase-1.8
See Also:
Constant Field Values

TYPE_BOOLEAN

static final int TYPE_BOOLEAN
MMBase base type identifier for the Boolean data type

Since:
MMBase-1.8
See Also:
Constant Field Values

TYPE_LIST

static final int TYPE_LIST
MMBase base type identifier for the List data type

Since:
MMBase-1.8
See Also:
Constant Field Values

TYPE_DECIMAL

static final int TYPE_DECIMAL
Since:
MMBase-1.9.1
See Also:
Constant Field Values

TYPE_UNKNOWN

static final int TYPE_UNKNOWN
MMBase base type identifier for data types whose type is unknown

See Also:
Constant Field Values

STATE_VIRTUAL

static final int STATE_VIRTUAL
A field's state is 'virtual' if it is not persistent in storage. The value of such a field may be implicitely calculated from the values of other fields. This can e.g. be done with Processor's which are associated with the DataType of this field.

See Also:
Constant Field Values

STATE_PERSISTENT

static final int STATE_PERSISTENT
A field's state is 'persistent' if it is persistent in storage. Most normal fields are this.

See Also:
Constant Field Values

STATE_SYSTEM

static final int STATE_SYSTEM
A field's state is 'system' if it is persistent in storage, but probably not editable by users (The default value of isReadOnly() is true). It is used to (automaticly) adminstrate special properties of a Node, like its number, owner and type (these fields are available always), but also e.g. 'created' and 'lastmodified' fields can be marked as 'system' fields.

See Also:
Constant Field Values

STATE_SYSTEM_VIRTUAL

static final int STATE_SYSTEM_VIRTUAL
A field's state is 'system virtual' if it is not persistent in storage, and probably used for administration purposes only. In other words the field is both STATE_SYSTEM and STATE_VIRTUAL.

See Also:
STATE_VIRTUAL, STATE_SYSTEM, Constant Field Values

STATE_UNKNOWN

static final int STATE_UNKNOWN
The field's state when it is not (yet) known.

See Also:
Constant Field Values
Method Detail

getNodeManager

NodeManager getNodeManager()
Returns the node manager this field belongs to.

Returns:
the node manager this field belongs to

getState

int getState()
Returns this field's state identifier (STATE_VIRTUAL, STATE_PERSISTENT, STATE_SYSTEM or STATE_SYSTEM_VIRTUAL, in errorneous sitations it may return STATE_UNKNOWN)

Returns:
an int which identifies the state of this field
See Also:
isReadOnly();

getDataType

DataType getDataType()
Returns the data type this field contains.

Returns:
a DataType object describing the constraints on this field.
Since:
MMBase-1.8

isUnique

boolean isUnique()
Returns whether this field is part of a unique key (a set of fields whose combined content should occur only once). Note that MMBase lets the storage layer handle this. If your storage implementation or configuration does not support this the uniqueness may not be enforced.

Returns:
true if the field is part of a unique key
Since:
MMBase-1.6

hasIndex

boolean hasIndex()
Returns whether this field is a key field, meaning that the storage layer should define an index for it, allowing optimization with search and sort actions. Note that MMBase lets the storage layer decide whether an index is actually defined. Some implementations or configurations may not do this. Note: Currently, this method only returns true if the field is the primary key (number field) or a Node field.

Returns:
true if the field has a key defined
Since:
MMBase-1.7

getType

int getType()
Returns the identifier for the MMBase base type for this field. This represents one of field type constants. This basic type determines how data is stored in MMBase. Note that it is possible that the datatype for a field (used for validation and in/out put) can be of a different basic type than how it is stored in the database. This shoudl not occur often, but is possible in some cases, such as when you use older clod models (which used INTEGER fields for dates). In general this should not prove a [problem - however you shoudl not assumeto know the classtype iof data of a field based on this method. To acquire the datatype's type, use getDataType.getBaseType() instead.

Returns:
an int which identifies the base type

getListItemType

int getListItemType()
If the type of this field is TYPE_LIST, this method returns the MMBase base type for the list elements. This represents one of field type constants. This basic type determines how data is stored in MMBase. For any field types other that TYPE_LIST, this method returns TYPE_UNKNOWN.

Returns:
an int which identifies the base type

getSearchPosition

int getSearchPosition()
Retrieve the position of the field when searching. A value of -1 indicates the field is unavailable during search.

Returns:
position of the field when searching
Since:
MMBase-1.8

getListPosition

int getListPosition()
Retrieve the position of the field when listing. A value of -1 indicates the field is unavailable in a list.

Returns:
position of the field when listing
Since:
MMBase-1.8

getEditPosition

int getEditPosition()
Retrieve the position of the field when editing. A value of -1 indicates the field cannot be edited.

Returns:
position of the field when editing
Since:
MMBase-1.8

getStoragePosition

int getStoragePosition()
Retrieve the position of the field in the database table.

Returns:
position in the database table
Since:
MMBase-1.8

getGUIType

@Deprecated
String getGUIType()
Deprecated. use getDataType() and Descriptor.getName()

Returns the GUI name for the data type this field contains.

Returns:
the GUI name
See Also:
getDataType()

isRequired

boolean isRequired()
Returns whether this field is required (should have content). Note that MMBase does not generally enforce required fields to be filled - If not provided, a default value (generally an empty string or the integer value -1) is filled in by the system. As such, isRequired will mostly be used as an indicator for (generic) editors.

Returns:
true if the field is required
Since:
MMBase-1.6

getMaxLength

int getMaxLength()
Returns the maximum length of data this field can contain. For example if a field contains characters the size indicates the maximum number of characters it can contain. If the field is a numeric field (such as an integer), the result is -1. For a 'decimal' type though, this returns the same as the precision of the associated datatype.

Returns:
the maximum length of data this field can contain

validate

Collection<String> validate(Object value)
Checks whether a given value is valid for this field.

Parameters:
value - value to validate
Returns:
Collection of error-strings (describing the problem) in the current locale, or an empty collection if the value is ok.
Since:
MMBase-1.8

isVirtual

boolean isVirtual()
A field's state is 'virtual' if it is not persistent in storage.

Returns:
true when a field is virtual
Since:
MMBase-1.8

isReadOnly

boolean isReadOnly()
Returns whether a field is 'read only' - that is, a user cannot edit it. In general, fields with state SYSTEM or SYSTEM_VIRTUAL are defined as read only, while others are not. It is possible to override this behaviour per field.

Returns:
true when a field is read only
Since:
MMBase-1.8


MMBase 2.0-SNAPSHOT - null