org.mmbase.module.corebuilders
Class FieldDefs

java.lang.Object
  extended byorg.mmbase.module.corebuilders.FieldDefs
All Implemented Interfaces:
java.lang.Comparable, Storable

public class FieldDefs
extends java.lang.Object
implements java.lang.Comparable, Storable

One of the core objects. It is not itself a builder, but is used by builders. Defines one field of a object type / builder.

Version:
$Id: FieldDefs.java,v 1.40 2004/01/06 12:22:39 michiel Exp $
Author:
Daniel Ockeloen, Hans Speijer, Pierre van Rooden
See Also:
Field

Field Summary
static int DBSTATE_MAXVALUE
           
static int DBSTATE_MINVALUE
           
static int DBSTATE_PERSISTENT
           
static int DBSTATE_SYSTEM
           
static int DBSTATE_UNKNOWN
           
static int DBSTATE_VIRTUAL
           
static int ORDER_CREATE
           
static int ORDER_EDIT
           
static int ORDER_LIST
           
static int ORDER_SEARCH
           
static int TYPE_BYTE
           
static int TYPE_DOUBLE
           
static int TYPE_FLOAT
           
static int TYPE_INTEGER
           
static int TYPE_LONG
           
static int TYPE_MAXVALUE
           
static int TYPE_MINVALUE
           
static int TYPE_NODE
           
static int TYPE_STRING
           
static int TYPE_UNKNOWN
           
static int TYPE_XML
           
 
Constructor Summary
FieldDefs()
          Constructor for default FieldDefs.
FieldDefs(java.lang.String guiName, java.lang.String guiType, int search, int list, java.lang.String name, int type)
          Constructor for FieldDefs with partially initialized fields.
FieldDefs(java.lang.String guiName, java.lang.String guiType, int guiSearch, int guiList, java.lang.String name, int type, int guiPos, int state)
          Constructor for FieldDefs with partially initialized fields.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compare this object to the supplied one (should be a FieldDefs)
 boolean equals(java.lang.Object o)
          
 java.lang.String getDBDocType()
          Retrieve the doctype MM: I think this is odd that this is on a field-type because, this can only be defined for XML fields.
 java.lang.String getDBName()
          Retrieve the database name of the field.
 boolean getDBNotNull()
          Retrieve whether the field can be left blank.
 int getDBPos()
          Retrieve the position of the field in the database table.
 int getDBSize()
          Retrieve size of the field.
 int getDBState()
          Retrieve the state of the field (persistent, system, or virtual).
 java.lang.String getDBStateDescription()
          Provide a description for the current state.
static java.lang.String getDBStateDescription(int state)
          Provide a description for the specified state.
static int getDBStateId(java.lang.String state)
          Provide an id for the specified mmbase state description.
 int getDBType()
          Retrieves the basic MMBase type of the field.
 java.lang.String getDBTypeDescription()
          Provide a description for the current type.
static java.lang.String getDBTypeDescription(int type)
          Provide a description for the specified type.
static int getDBTypeId(java.lang.String type)
          Provide an id for the specified mmbase type description
 java.lang.String getDescription()
          Retrieve the GUI name of the field.
 java.lang.String getDescription(java.lang.String lang)
          Retrieve the description of the field depending on specified langauge.
 java.util.Map getDescriptions()
          Retrieve a Map with all descriptions for this field, accessible by language.
 int getGUIList()
          Retrieve the position of the field when listing.
 java.lang.String getGUIName()
          Retrieve the GUI name of the field.
 java.lang.String getGUIName(java.lang.String lang)
          Retrieve the GUI name of the field depending on specified langauge.
 java.util.Map getGUINames()
          Retrieve a Map with all GUI names for this field, accessible by language.
 int getGUIPos()
          Retrieve the position of the field when editing.
 int getGUISearch()
          Retrieve the position of the field when searching.
 java.lang.String getGUIType()
          Retrieve the GUI type of the field.
 MMObjectBuilder getParent()
          Retrieves the parent builder for this field
 java.lang.Object getStorageIdentifier()
          Returns a storage identifier for this object. This should return:
  • For MMBase: the object storage element identifier as a String (i.e. fully expanded table name)
  • For MMObjectBuilder: the builder storage element identifier as a String (i.e. fully expanded table name)
  • For MMObjectNode: the object number as a Integer
  • For FieldDefs: a storage-compatible field name as a String (if no such name exists a StorageException is thrown)
A Storable object (except for MMObjectNode) should retrieve its storage identifier using StorageManagerFactory.getStorageIdentifier() when it is first instantiated.
 int getStorageType()
          Retrieves the storage type. The meaning of this type is dependent on the storage implementation.
 boolean inStorage()
          Returns whether an object is (or, for a new object, should be) defined in the storage. Virtual fields or builders should return false.
 boolean isKey()
          Retrieve whether the field is a key and thus need be unique.
 void setDBDocType(java.lang.String dt)
          Set whether the field has an doctype to validate
 void setDBKey(boolean value)
          Set whether the field is a key and thus need be unique.
 void setDBName(java.lang.String value)
          Set the database name of the field.
 void setDBNotNull(boolean value)
          Set whether the field can be left blank.
 void setDBPos(int value)
          Set the position of the field in the database table.
 void setDBSize(int value)
          Set size of the field.
 void setDBState(int value)
          Set the state of the field (persistent, system, or virtual).
 void setDBState(java.lang.String value)
          Set the basic MMBase state of the field, using the state description
 void setDBType(int value)
          Set the basic MMBase type of the field.
 void setDBType(java.lang.String value)
          Set the basic MMBase type of the field, using the type description
 void setDescription(java.lang.String lang, java.lang.String value)
          Set the description of the field for a specified langauge.
 void setGUIList(int value)
          Set the position of the field when listing.
 void setGUIName(java.lang.String lang, java.lang.String value)
          Set the GUI name of the field for a specified langauge.
 void setGUIPos(int value)
          Set the position of the field when editing.
 void setGUISearch(int value)
          Set the position of the field when searching.
 void setGUIType(java.lang.String value)
          Set the GUI type of the field.
 void setParent(MMObjectBuilder parent)
          Set the parent builder for this field
 void setStorageType(int value)
          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.
static void sort(java.util.List fielddefs)
          Sorts a list with FieldDefs objects, using the default order (ORDER_CREATE)
static void sort(java.util.List fielddefs, int order)
          Sorts a list with FieldDefs objects, using the specified order
 boolean storageEquals(FieldDefs f)
          Whether this FieldDefs object is equal to another for storage purposes (so, ignoring gui and documentation fields)
 java.lang.String toString()
          Returns a description for this field.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DBSTATE_MINVALUE

public static final int DBSTATE_MINVALUE
See Also:
Constant Field Values

DBSTATE_VIRTUAL

public static final int DBSTATE_VIRTUAL
See Also:
Constant Field Values

DBSTATE_PERSISTENT

public static final int DBSTATE_PERSISTENT
See Also:
Constant Field Values

DBSTATE_SYSTEM

public static final int DBSTATE_SYSTEM
See Also:
Constant Field Values

DBSTATE_MAXVALUE

public static final int DBSTATE_MAXVALUE
See Also:
Constant Field Values

DBSTATE_UNKNOWN

public static final int DBSTATE_UNKNOWN
See Also:
Constant Field Values

TYPE_MINVALUE

public static final int TYPE_MINVALUE
See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
See Also:
Constant Field Values

TYPE_INTEGER

public static final int TYPE_INTEGER
See Also:
Constant Field Values

TYPE_BYTE

public static final int TYPE_BYTE
See Also:
Constant Field Values

TYPE_FLOAT

public static final int TYPE_FLOAT
See Also:
Constant Field Values

TYPE_DOUBLE

public static final int TYPE_DOUBLE
See Also:
Constant Field Values

TYPE_LONG

public static final int TYPE_LONG
See Also:
Constant Field Values

TYPE_XML

public static final int TYPE_XML
See Also:
Constant Field Values

TYPE_NODE

public static final int TYPE_NODE
See Also:
Constant Field Values

TYPE_MAXVALUE

public static final int TYPE_MAXVALUE
See Also:
Constant Field Values

TYPE_UNKNOWN

public static final int TYPE_UNKNOWN
See Also:
Constant Field Values

ORDER_CREATE

public static final int ORDER_CREATE
See Also:
Constant Field Values

ORDER_EDIT

public static final int ORDER_EDIT
See Also:
Constant Field Values

ORDER_LIST

public static final int ORDER_LIST
See Also:
Constant Field Values

ORDER_SEARCH

public static final int ORDER_SEARCH
See Also:
Constant Field Values
Constructor Detail

FieldDefs

public FieldDefs()
Constructor for default FieldDefs.


FieldDefs

public FieldDefs(java.lang.String guiName,
                 java.lang.String guiType,
                 int search,
                 int list,
                 java.lang.String name,
                 int type)
Constructor for FieldDefs with partially initialized fields.

Parameters:
guiName - the default GUIName for a field
guiType - the GUI type (i.e. "integer' or 'field')
name - the actual name of the field in the database
type - the basic MMBase type of the field

FieldDefs

public FieldDefs(java.lang.String guiName,
                 java.lang.String guiType,
                 int guiSearch,
                 int guiList,
                 java.lang.String name,
                 int type,
                 int guiPos,
                 int state)
Constructor for FieldDefs with partially initialized fields.

Parameters:
guiName - the default GUIName for a field
guiType - the GUI type (i.e. "integer' or 'field')
guiSearch - position in the editor for this field when searching
guiList - position in the editor for this field when listing
name - the actual name of the field in the database
type - the basic MMBase type of the field
guiPos - position in the editor for this field when editing
state - the state of the field (persistent, virtual, etc.)
Method Detail

getDBTypeDescription

public static java.lang.String getDBTypeDescription(int type)
Provide a description for the specified type. Useful for debugging, errors or presenting GUI info.

Parameters:
type - the type to get the description of
Returns:
the description of the type.

getDBStateDescription

public static java.lang.String getDBStateDescription(int state)
Provide a description for the specified state. Useful for debugging, errors or presenting GUI info.

Parameters:
state - the state to get the description of
Returns:
the description of the state.

getDBTypeId

public static int getDBTypeId(java.lang.String type)
Provide an id for the specified mmbase type description

Parameters:
type - the type description to get the id of
Returns:
the id of the type.

getDBStateId

public static int getDBStateId(java.lang.String state)
Provide an id for the specified mmbase state description.

Returns:
the id of the state.

getDBTypeDescription

public java.lang.String getDBTypeDescription()
Provide a description for the current type.

Returns:
the description of the type.

getDBStateDescription

public java.lang.String getDBStateDescription()
Provide a description for the current state.

Returns:
the description of the state.

getGUIName

public java.lang.String getGUIName(java.lang.String lang)
Retrieve the GUI name of the field depending on specified langauge. If the language is not available, the "en" value is returned instead. If that one is unavailable the internal fieldname is returned.

Parameters:
lang - the language to return the name in
Returns:
the GUI Name

getGUIName

public java.lang.String getGUIName()
Retrieve the GUI name of the field. If possible, the "en" value is returned. If that one is unavailable the internal fieldname is returned.

Returns:
the GUI Name

getDescription

public java.lang.String getDescription(java.lang.String lang)
Retrieve the description of the field depending on specified langauge. If the language is not available, the "en" value is returned instead.

Parameters:
lang - the language to return the name in
Returns:
the description

getDescription

public java.lang.String getDescription()
Retrieve the GUI name of the field. If possible, the "en" value is returned.

Returns:
the Description

getGUINames

public java.util.Map getGUINames()
Retrieve a Map with all GUI names for this field, accessible by language.


getDescriptions

public java.util.Map getDescriptions()
Retrieve a Map with all descriptions for this field, accessible by language.


getGUIType

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


getDBName

public java.lang.String getDBName()
Retrieve the database name of the field.


getDBType

public int getDBType()
Retrieves the basic MMBase type of the field.

Returns:
The type, this is one of the values defined in this class.

getDBSize

public int getDBSize()
Retrieve size of the field. This may not be specified for some field types.


getDBNotNull

public boolean getDBNotNull()
Retrieve whether the field can be left blank.


getDBDocType

public java.lang.String getDBDocType()
Retrieve the doctype MM: I think this is odd that this is on a field-type because, this can only be defined for XML fields. deprecated?

Since:
MMBase-1.6

getDBState

public int getDBState()
Retrieve the state of the field (persistent, system, or virtual).


isKey

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


getGUISearch

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


getGUIList

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


getGUIPos

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


getDBPos

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


setGUIName

public void setGUIName(java.lang.String lang,
                       java.lang.String value)
Set the GUI name of the field for a specified langauge.

Parameters:
lang - the language to set the name for
value - the value to set

setDescription

public void setDescription(java.lang.String lang,
                           java.lang.String value)
Set the description of the field for a specified langauge.

Parameters:
lang - the language to set the description for
value - the value to set

setGUIType

public void setGUIType(java.lang.String value)
Set the GUI type of the field.

Parameters:
value - the value to set

setDBName

public void setDBName(java.lang.String value)
Set the database name of the field.

Parameters:
value - the value to set

setGUIList

public void setGUIList(int value)
Set the position of the field when listing. A value of -1 indicates teh field is unavailable in a list.

Parameters:
value - the value to set

setGUIPos

public void setGUIPos(int value)
Set the position of the field when editing. A value of -1 indicates the field cannot be edited.

Parameters:
value - the value to set

setGUISearch

public void setGUISearch(int value)
Set the position of the field when searching. A value of -1 indicates teh field is unavailable during search.

Parameters:
value - the value to set

setDBSize

public void setDBSize(int value)
Set size of the field.

Parameters:
value - the value to set

setDBType

public void setDBType(int value)
Set the basic MMBase type of the field.

Parameters:
value - the id of the type

setDBType

public void setDBType(java.lang.String value)
Set the basic MMBase type of the field, using the type description

Parameters:
value - the name of the type

setDBPos

public void setDBPos(int value)
Set the position of the field in the database table.

Parameters:
value - the value to set

setDBState

public void setDBState(int value)
Set the state of the field (persistent, system, or virtual).

Parameters:
value - the value to set

setDBState

public void setDBState(java.lang.String value)
Set the basic MMBase state of the field, using the state description

Parameters:
value - the name of the state

setDBKey

public void setDBKey(boolean value)
Set whether the field is a key and thus need be unique.

Parameters:
value - the value to set

setDBNotNull

public void setDBNotNull(boolean value)
Set whether the field can be left blank.

Parameters:
value - the value to set

setDBDocType

public void setDBDocType(java.lang.String dt)
Set whether the field has an doctype to validate

Since:
MMBase-1.6

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 fielddefs parent

toString

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


equals

public boolean equals(java.lang.Object o)

Since:
MMBase-1.7

storageEquals

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

Since:
MMBase-1.7

getStorageIdentifier

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

inStorage

public boolean inStorage()
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
Since:
MMBase 1.7

getStorageType

public int getStorageType()
Retrieves the storage type. The meaning of this type is dependent on the storage implementation.

Specified by:
getStorageType in interface Storable
Since:
MMBase 1.7

setStorageType

public void setStorageType(int value)
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:
value - the value to set
Since:
MMBase 1.7

compareTo

public int compareTo(java.lang.Object o)
Compare this object to the supplied one (should be a FieldDefs)

Specified by:
compareTo in interface java.lang.Comparable
Returns:
-1,1, or 0 according to wether this object is smaller, greater, or equals to the supplied one.

sort

public static void sort(java.util.List fielddefs)
Sorts a list with FieldDefs objects, using the default order (ORDER_CREATE)

Parameters:
fielddefs - the list to sort

sort

public static void sort(java.util.List fielddefs,
                        int order)
Sorts a list with FieldDefs objects, using the specified order

Parameters:
fielddefs - the list to sort
order - one of ORDER_CREATE, ORDER_EDIT, ORDER_LIST,ORDER_SEARCH


MMBase build 1.7.1.20041002