org.mmbase.core
Class CoreField

java.lang.Object
  extended by org.mmbase.core.AbstractDescriptor
      extended by org.mmbase.core.AbstractField<Object>
          extended by org.mmbase.core.CoreField
All Implemented Interfaces:
Cloneable, Comparable<Field>, Descriptor, Field, Storable, PublicCloneable<AbstractDescriptor>
Direct Known Subclasses:
FieldDefs

public class CoreField
extends AbstractField<Object>
implements Field, Storable

Since:
MMBase-1.8

Field Summary
 
Fields inherited from class org.mmbase.core.AbstractField
dataType, listItemType, readOnly, state, 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_DECIMAL, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LIST, TYPE_LONG, TYPE_NODE, TYPE_STRING, TYPE_UNKNOWN, TYPE_XML
 
Constructor Summary
  CoreField(Field field)
          Creates a CoreField object based on a more generic 'Field'.
protected CoreField(String name, CoreField coreField)
          Copy constructor.
protected CoreField(String name, int type, int listItemType, int state, DataType dataType)
          Create a core object
 
Method Summary
 CoreField clone()
           
 CoreField clone(String name)
           
 int compareTo(Field o)
          Compare this object to the supplied one (should be a CoreField)
 boolean equals(Object o)
          Whether data type equals to other data type.
 void finish()
          Finishes this encapsulated DataType with current field.
 int getEditPosition()
          Retrieve the position of the field when editing.
 String getGUIType()
          Retrieve the GUI type of the field.
 int getListPosition()
          Retrieve the position of the field when listing.
 int getMaxLength()
          Returns the (maximum) size of this field, as determined by the storage layer.
 NodeManager getNodeManager()
          Returns the node manager this field belongs to.
 MMObjectBuilder getParent()
          Retrieves the parent builder for this field
 int getSearchPosition()
          Retrieve the position of the field when searching.
 Object getStorageIdentifier()
          Returns a storage identifier for this object.
 int getStoragePosition()
          Retrieve the position of the field in the database table.
 int getStorageType()
          Retrieves the storage type.
 int hashCode()
           
 boolean inStorage()
          Returns whether an object is (or, for a new object, should be) defined in the storage.
 boolean isNotNull()
           
 void rewrite()
           
 void setDataType(DataType dataType)
          Sets the datatype of a field.
 void setEditPosition(int i)
          Set the position of the field when editing.
 void setListItemType(int listItemType)
           
 void setListPosition(int i)
          Set the position of the field when listing.
 void setMaxLength(int size)
           
 void setNotNull(boolean nl)
           
 void setParent(MMObjectBuilder parent)
          Set the parent builder for this field
 void setReadOnly(boolean readOnly)
           
 void setSearchPosition(int i)
          Set the position of the field when searching.
 void setState(int state)
           
 void setStoragePosition(int i)
          Set the position of the field in the database table.
 void setStorageType(int type)
          Sets the storage type.
 void setType(int type)
           
 void setUnique(boolean unique)
           
 boolean storageEquals(CoreField f)
          Whether this CoreField is equal to another for storage purposes (so, ignoring gui and documentation fields)
 String toString()
          Returns a description for this field.
 Collection<String> validate(Object value)
          Checks whether a given value is valid for this field.
 
Methods inherited from class org.mmbase.core.AbstractField
clone, getDataType, getListItemType, getState, getType, hasIndex, isReadOnly, isRequired, isTemporary, isUnique, isVirtual
 
Methods inherited from class org.mmbase.core.AbstractDescriptor
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
getDataType, getListItemType, getState, getType, hasIndex, isReadOnly, isRequired, isUnique, isVirtual
 
Methods inherited from interface org.mmbase.bridge.Descriptor
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName
 

Constructor Detail

CoreField

public CoreField(Field field)
Creates a CoreField object based on a more generic 'Field'.

Since:
MMBase-1.8.1

CoreField

protected CoreField(String name,
                    int type,
                    int listItemType,
                    int state,
                    DataType dataType)
Create a core object

Parameters:
name - the name of the data type
dataType - the data type for this field

CoreField

protected CoreField(String name,
                    CoreField coreField)
Copy constructor.

Parameters:
name - the name of the data type
coreField -
Method Detail

getNodeManager

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

Specified by:
getNodeManager in interface Field
Specified by:
getNodeManager in class AbstractField<Object>
Returns:
the node manager this field belongs to

clone

public final CoreField clone()
Specified by:
clone in interface PublicCloneable<AbstractDescriptor>
Overrides:
clone in class AbstractField<Object>

clone

public CoreField clone(String name)
Overrides:
clone in class AbstractDescriptor

setReadOnly

public void setReadOnly(boolean readOnly)

setNotNull

public void setNotNull(boolean nl)

isNotNull

public boolean isNotNull()

getSearchPosition

public int getSearchPosition()
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
Specified by:
getSearchPosition in class AbstractField<Object>
Returns:
position of the field when searching

setSearchPosition

public void setSearchPosition(int i)
Set the position of the field when searching.

See Also:
getSearchPosition()

getListPosition

public int getListPosition()
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
Specified by:
getListPosition in class AbstractField<Object>
Returns:
position of the field when listing

setListPosition

public void setListPosition(int i)
Set the position of the field when listing.

See Also:
getListPosition()

getEditPosition

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

Specified by:
getEditPosition in interface Field
Specified by:
getEditPosition in class AbstractField<Object>
Returns:
position of the field when editing

setEditPosition

public void setEditPosition(int i)
Set the position of the field when editing.

See Also:
getEditPosition()

getStoragePosition

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

Specified by:
getStoragePosition in interface Field
Specified by:
getStoragePosition in class AbstractField<Object>
Returns:
position in the database table

setStoragePosition

public void setStoragePosition(int i)
Set the position of the field in the database table.


getParent

public MMObjectBuilder getParent()
Retrieves the parent builder for this field


setParent

public void setParent(MMObjectBuilder parent)
Set the parent builder for this field

Parameters:
parent - the parent builder

setState

public void setState(int state)
Overrides:
setState in class AbstractField<Object>

setType

public void setType(int type)

setListItemType

public void setListItemType(int listItemType)

validate

public Collection<String> validate(Object value)
Description copied from interface: Field
Checks whether a given value is valid for this field.

Specified by:
validate in interface 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.

storageEquals

public boolean storageEquals(CoreField f)
Whether this CoreField is equal to another for storage purposes (so, ignoring gui and documentation fields)

Since:
MMBase-1.7

equals

public boolean equals(Object o)
Description copied from class: AbstractField
Whether data type equals to other data type. Only key and type are considered. DefaultValue and required properties are only 'utilities'.

Overrides:
equals in class AbstractField<Object>
Parameters:
o - the reference object with which to compare.
Returns:
true if o is a DataType of which key and type equal to this' key and type.
Since:
MMBase-1.7
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractField<Object>
See Also:
Object.hashCode()

compareTo

public int compareTo(Field o)
Compare this object to the supplied one (should be a CoreField)

Specified by:
compareTo in interface Comparable<Field>
Overrides:
compareTo in class AbstractField<Object>
Parameters:
o - the object to compare to
Returns:
-1,1, or 0 according to wether this object is smaller, greater, or equal to the supplied one.

finish

public void finish()
Finishes this encapsulated DataType with current field.

Throws:
IllegalStateException - If the datatype is already finished

rewrite

public void rewrite()

getMaxLength

public int getMaxLength()
Returns the (maximum) size of this field, as determined by the storage layer. 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
Specified by:
getMaxLength in class AbstractField<Object>
Returns:
the maximum size of data this field can contain

setMaxLength

public void setMaxLength(int size)

setDataType

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

Overrides:
setDataType in class AbstractField<Object>
Throws:
IllegalArgumentException
See Also:
AbstractField.getType()

setUnique

public void setUnique(boolean unique)

getStorageIdentifier

public Object getStorageIdentifier()
                            throws StorageException
Returns a storage identifier for this object. This should return: A Storable object (except for MMObjectNode) should retrieve its storage identifier using StorageManagerFactory.getStorageIdentifier() when it is first instantiated.

Specified by:
getStorageIdentifier in interface Storable
Returns:
the identifier
Throws:
StorageException
Since:
MMBase 1.7

getStorageType

public int getStorageType()
Description copied from interface: Storable
Retrieves the storage type. The meaning of this type is dependent on the storage implementation.

Specified by:
getStorageType in interface Storable

setStorageType

public void setStorageType(int type)
Description copied from interface: Storable
Sets the storage type. This method is called by the storage layer when first loading a builder. The meaning of this type is dependent on the storage implementation.

Specified by:
setStorageType in interface Storable
Parameters:
type - the value to set

inStorage

public boolean inStorage()
Description copied from interface: Storable
Returns whether an object is (or, for a new object, should be) defined in the storage. Virtual fields or builders should return false.

Specified by:
inStorage in interface Storable
Returns:
true if the object is kept in the storage

getGUIType

public String getGUIType()
Retrieve the GUI type of the field.

Specified by:
getGUIType in interface Field
Specified by:
getGUIType in class AbstractField<Object>
Returns:
the GUI name
See Also:
Field.getDataType()

toString

public String toString()
Description copied from class: AbstractField
Returns a description for this field.

Overrides:
toString in class AbstractField<Object>
Returns:
a string representation of the object.


MMBase 2.0-SNAPSHOT - null