org.mmbase.core
Class AbstractField

java.lang.Object
  extended byorg.mmbase.core.AbstractDescriptor
      extended byorg.mmbase.core.AbstractField
All Implemented Interfaces:
Cloneable, Comparable, Descriptor, Field
Direct Known Subclasses:
BasicField, CoreField

public abstract class AbstractField
extends AbstractDescriptor
implements Field, Comparable

Since:
MMBase-1.8
Version:
$Id: AbstractField.java,v 1.13 2006/06/26 11:45:50 michiel Exp $
Author:
Pierre van Rooden, Michiel Meeuwissen
Warning: No Java Documentation Available.

Field Summary
protected  DataType dataType
           
protected  int listItemType
           
protected  boolean readOnly
           
protected  int state
           
protected  int type
           
 
Fields inherited from class org.mmbase.core.AbstractDescriptor
description, guiName, key
 
Fields inherited from interface org.mmbase.bridge.Field
STATE_PERSISTENT, STATE_SYSTEM, STATE_SYSTEM_VIRTUAL, STATE_UNKNOWN, STATE_VIRTUAL, TYPE_BINARY, TYPE_BOOLEAN, TYPE_BYTE, TYPE_DATETIME, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LIST, TYPE_LONG, TYPE_NODE, TYPE_STRING, TYPE_UNKNOWN, TYPE_XML
 
Constructor Summary
protected AbstractField(String name, Field field)
          Create a field object based on another field.
protected AbstractField(String name, Field field, boolean cloneDataForRewrite)
          Create a field object based on another field.
protected AbstractField(String name, int type, int listItemType, int state, DataType dataType)
          Create a field object
 
Method Summary
 Object clone()
           
 Object clone(String name, boolean copyDataTypeForRewrite)
           
 int compareTo(Object o)
           
 boolean equals(Object o)
          Whether data type equals to other data type.
 DataType getDataType()
          Returns the data type this field contains.
abstract  int getEditPosition()
          Retrieve the position of the field when editing.
abstract  String getGUIType()
          Returns the GUI name for the data type this field contains.
 int getListItemType()
          If the type of this field is TYPE_LIST, this method returns the MMBase base type for the list elements.
abstract  int getListPosition()
          Retrieve the position of the field when listing.
abstract  int getMaxLength()
          Returns the maximum length of data this field can contain.
abstract  NodeManager getNodeManager()
          Returns the node manager this field belongs to.
abstract  int getSearchPosition()
          Retrieve the position of the field when searching.
 int getState()
          Returns this field's state identifier (virtual, persistent, system, systemvirtual).
abstract  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.
 int hashCode()
           
 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 isTemporary()
          Returns whether a field is a temporary field.
 boolean isUnique()
          Retrieve whether the field is a key and thus need be unique.
 boolean isVirtual()
          A field's state is 'virtual' if it is not persistent in storage.
 void setDataType(DataType dataType)
          Sets the datatype of a field.
protected  void setState(int state)
           
 String toString()
          Returns a description for this field.
 
Methods inherited from class org.mmbase.core.AbstractDescriptor
clone, getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.bridge.Field
validate
 
Methods inherited from interface org.mmbase.bridge.Descriptor
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName
 

Field Detail

dataType

protected DataType dataType

type

protected int type

state

protected int state

listItemType

protected int listItemType

readOnly

protected boolean readOnly
Constructor Detail

AbstractField

protected AbstractField(String name,
                        Field field)
Create a field object based on another field. The newly created field shared the datatype of it's parent (which means that any changes to the datatype affects both fields).

Parameters:
name - the name of the field
field - the parent field

AbstractField

protected AbstractField(String name,
                        Field field,
                        boolean cloneDataForRewrite)
Create a field object based on another field.

Parameters:
name - the name of the field
field - the parent field
cloneDataForRewrite - determines whether the datatype of the parent field is copied (which means it can be altered without affecting the original datatype)

AbstractField

protected AbstractField(String name,
                        int type,
                        int listItemType,
                        int state,
                        DataType dataType)
Create a field object

Parameters:
name - the name of the field
dataType - the data type of the field
Method Detail

getNodeManager

public abstract NodeManager getNodeManager()
Description copied from interface: Field
Returns the node manager this field belongs to.

Specified by:
getNodeManager in interface Field
Returns:
the node manager this field belongs to

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object o)
Whether data type equals to other data type. Only key and type are considered. DefaultValue and required propererties are only 'utilities'.

Returns:
true if o is a DataType of which key and type equal to this' key and type.

hashCode

public int hashCode()

getState

public int getState()
Description copied from interface: Field
Returns this field's state identifier (virtual, persistent, system, systemvirtual).

Specified by:
getState in interface Field
Returns:
an int which identifies the state of this field

setState

protected void setState(int state)

getType

public int getType()
Description copied from interface: Field
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.

Specified by:
getType in interface Field
Returns:
an int which identifies the base type

getListItemType

public int getListItemType()
Description copied from interface: Field
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.

Specified by:
getListItemType in interface Field
Returns:
an int which identifies the base type

getDataType

public DataType getDataType()
Description copied from interface: Field
Returns the data type this field contains.

Specified by:
getDataType in interface Field
Returns:
a DataType object describing the constraints on this field.

setDataType

public void setDataType(DataType dataType)
                 throws IllegalArgumentException
Sets the datatype of a field. It is possible that the datatype of a field is different from the actual field type.

Throws:
IllegalArgumentException
See Also:
getType()

hasIndex

public boolean hasIndex()
Description copied from interface: Field
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.

Specified by:
hasIndex in interface Field
Returns:
true if the field has a key defined

getSearchPosition

public abstract int getSearchPosition()
Description copied from interface: Field
Retrieve the position of the field when searching. A value of -1 indicates the field is unavailable during search.

Specified by:
getSearchPosition in interface Field

getListPosition

public abstract int getListPosition()
Description copied from interface: Field
Retrieve the position of the field when listing. A value of -1 indicates the field is unavailable in a list.

Specified by:
getListPosition in interface Field

getEditPosition

public abstract int getEditPosition()
Description copied from interface: Field
Retrieve the position of the field when editing. A value of -1 indicates the field cannot be edited.

Specified by:
getEditPosition in interface Field

getStoragePosition

public abstract int getStoragePosition()
Description copied from interface: Field
Retrieve the position of the field in the database table.

Specified by:
getStoragePosition in interface Field

isUnique

public boolean isUnique()
Retrieve whether the field is a key and thus need be unique.

Specified by:
isUnique in interface Field
Returns:
true if the field is part of a unique key

getMaxLength

public abstract int getMaxLength()
Description copied from interface: Field
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.

Specified by:
getMaxLength in interface Field
Returns:
the maximum length of data this field can contain

isRequired

public boolean isRequired()
Description copied from interface: Field
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.

Specified by:
isRequired in interface Field
Returns:
true if the field is required
See Also:
Field.isRequired()

isVirtual

public boolean isVirtual()
Description copied from interface: Field
A field's state is 'virtual' if it is not persistent in storage.

Specified by:
isVirtual in interface Field
Returns:
true when a field is virtual
See Also:
Field.isVirtual()

isTemporary

public boolean isTemporary()
Returns whether a field is a temporary field. Temporary fields hold data needed by a builder to facilitate certain functionality, such as holding node references in a transaction. Temporary fields are never persistent and should normally be ignored.

Since:
MMBase-1.8

isReadOnly

public boolean isReadOnly()
Description copied from interface: Field
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.

Specified by:
isReadOnly in interface Field
Returns:
true when a field is read only
See Also:
Field.isVirtual()

getGUIType

public abstract String getGUIType()
Description copied from interface: Field
Returns the GUI name for the data type this field contains.

Specified by:
getGUIType in interface Field
See Also:
Field.getDataType()

toString

public String toString()
Returns a description for this field.

Overrides:
toString in class AbstractDescriptor

clone

public Object clone()
Overrides:
clone in class AbstractDescriptor

clone

public Object clone(String name,
                    boolean copyDataTypeForRewrite)


MMBase build 1.8.1.20060716