org.mmbase.bridge
Interface Field

All Superinterfaces:
Descriptor
All Known Implementing Classes:
AbstractField, BasicField, CoreField

public interface Field
extends Descriptor

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

Version:
$Id: Field.java,v 1.36 2006/04/18 13:13:12 michiel Exp $
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, and editable.
static int STATE_SYSTEM
          A field's state is 'system' if it is persistent in storage, but not editable by users.
static int STATE_SYSTEM_VIRTUAL
          A field's state is 'system virtual' if it is not persistent in storage, nor editable by users.
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_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 (virtual, persistent, system, systemvirtual).
 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 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
 

Field Detail

TYPE_STRING

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

See Also:
Constant Field Values

TYPE_INTEGER

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

See Also:
Constant Field Values

TYPE_BINARY

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

See Also:
Constant Field Values

TYPE_BYTE

public 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

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

See Also:
Constant Field Values

TYPE_DOUBLE

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

See Also:
Constant Field Values

TYPE_LONG

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

See Also:
Constant Field Values

TYPE_XML

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

See Also:
Constant Field Values

TYPE_NODE

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

See Also:
Constant Field Values

TYPE_DATETIME

public 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

public 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

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

Since:
MMBase-1.8
See Also:
Constant Field Values

TYPE_UNKNOWN

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

See Also:
Constant Field Values

STATE_VIRTUAL

public static final int STATE_VIRTUAL
A field's state is 'virtual' if it is not persistent in storage.

See Also:
Constant Field Values

STATE_PERSISTENT

public static final int STATE_PERSISTENT
A field's state is 'persistent' if it is persistent in storage, and editable.

See Also:
Constant Field Values

STATE_SYSTEM

public static final int STATE_SYSTEM
A field's state is 'system' if it is persistent in storage, but not editable by users.

See Also:
Constant Field Values

STATE_SYSTEM_VIRTUAL

public static final int STATE_SYSTEM_VIRTUAL
A field's state is 'system virtual' if it is not persistent in storage, nor editable by users.

See Also:
Constant Field Values
To Do:
reserved but not used yet

STATE_UNKNOWN

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

See Also:
Constant Field Values
Method Detail

getNodeManager

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

Returns:
the node manager this field belongs to

getState

public int getState()
Returns this field's state identifier (virtual, persistent, system, systemvirtual).

Returns:
an int which identifies the state of this field

getDataType

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

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

isUnique

public 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

public 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

public 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

public 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

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

Since:
MMBase-1.8

getListPosition

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

Since:
MMBase-1.8

getEditPosition

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

Since:
MMBase-1.8

getStoragePosition

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

Since:
MMBase-1.8

getGUIType

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

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

See Also:
getDataType()

isRequired

public 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

public 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.

Returns:
the maximum length of data this field can contain

validate

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

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

public 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

public 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 build 1.8.1.20060716