org.makumba.providers.datadefinition.mdd
Class FieldDefinitionImpl

java.lang.Object
  extended by org.makumba.providers.datadefinition.mdd.FieldDefinitionImpl
All Implemented Interfaces:
Serializable, FieldDefinition

public class FieldDefinitionImpl
extends Object
implements FieldDefinition, Serializable

See Also:
Serialized Form

Field Summary
protected  Vector<String> charEnumValues
           
protected  Vector<String> charEnumValuesDeprecated
           
protected  int charLength
           
protected  String description
           
protected  boolean fixed
           
protected  LinkedHashMap<Integer,String> intEnumValues
           
protected  LinkedHashMap<Integer,String> intEnumValuesDeprecated
           
protected  DataDefinitionImpl mdd
           
protected  String name
           
protected  String NaNError
           
protected  String notBooleanError
           
protected  boolean notEmpty
           
protected  String notEmptyError
           
protected  String notIntError
           
protected  boolean notNull
           
protected  String notNullError
           
protected  String notRealError
           
protected  DataDefinition pointed
           
protected  String pointedType
           
protected  DataDefinitionImpl subfield
           
protected  FieldType type
           
protected  boolean unique
           
protected  String uniqueError
           
 
Fields inherited from interface org.makumba.FieldDefinition
_binary, _boolean, _char, _charEnum, _date, _dateCreate, _dateModify, _file, _int, _intEnum, _nil, _ptr, _ptrIndex, _ptrOne, _ptrRel, _real, _set, _setCharEnum, _setComplex, _setIntEnum, _text, ERROR_NOT_EMPTY, ERROR_NOT_NULL, ERROR_NOT_UNIQUE
 
Constructor Summary
FieldDefinitionImpl(DataDefinitionImpl mdd, FieldNode f)
          constructor used when creating the DataDefinitionImpl during parsing
FieldDefinitionImpl(String name, DataDefinitionImpl dd)
          Minimal constructor for standard fields
FieldDefinitionImpl(String name, FieldDefinition fi)
          for virtual FieldDefinition
FieldDefinitionImpl(String name, FieldDefinition field, String description)
          for virtual field definitions
FieldDefinitionImpl(String name, String type)
          Creates a field definition given a name and a type
FieldDefinitionImpl(String name, String type, DataDefinitionImpl mdd)
           
FieldDefinitionImpl(String name, String type, String description)
          Creates a field definition given a name, type and description
 
Method Summary
 void addValidationRule(Collection<ValidationRule> rules)
          methods for validation rules
 void addValidationRule(ValidationRule rule)
          Adds a new validation rule to this field.
 boolean base_isAssignableFrom(FieldDefinition fi)
           
 void checkInsert(Dictionary<String,Object> d)
          methods for checks (assignability)
 void checkUpdate(Dictionary<String,Object> d)
          check if the corresponding field from the dictionary can be updated
 Object checkValue(Object value)
          check if the value can be assigned
 DataDefinitionImpl getDataDefinition()
          The data definition that contains this field definition
 String getDataType()
          methods for types (java, sql, null)
 Date getDefaultDate()
          methods for default values
 int getDefaultInt()
          Get the default value as an integer.
 String getDefaultString()
          Get the default value as a String.
 Object getDefaultValue()
          returns the default value of this field
 Vector<String> getDeprecatedValues()
          methods for enumerations
 String getDescription()
          Returns field's description
 Object getEmptyValue()
          The value returned in case there is no value in the database and no default value is indicated
 int getEnumeratorSize()
          Get the number of the members of an enumerated field.
 DataDefinition getForeignTable()
          methods for relational types
 int getIntAt(int i)
          Get the integer at a certain position in an enumerated type.
 int getIntegerType()
          returns the integer value associated with the field's internal makumba type.
 Class<?> getJavaType()
          The Java type of this field.
 String getName()
          The name of this field, normally the same with the name of the field
 String getNameAt(int i)
          Get the name at a certain position in an enumerated field.
 String getNameFor(int i)
          Get the name for a certain value of the enumerated field.
 Collection<String> getNames()
          Get the names of an enumerated field.
 String getNotANumberErrorMessage()
          gets the error message for the not a number field constraint, if specified
 String getNotBooleanErrorMessage()
          gets the error message for the not a boolean field constraint, if specified
 String getNotEmptyErrorMessage()
          gets the error message for the not empty field constraint, if specified
 String getNotIntErrorMessage()
          gets the error message for the not an int field constraint, if specified
 String getNotNullErrorMessage()
          gets the error message for not null field, if specified
 String getNotRealErrorMessage()
          gets the error message for the not a real field constraint, if specified
 String getNotUniqueErrorMessage()
          gets the error message for the not unique field constraint, if specified
 Object getNull()
          The null value for this type
 FieldDefinition getOriginalFieldDefinition()
          The original field definition this field definition was made of, used e.g. in form responders.
 DataDefinition getPointedType()
          The type referred.
 String getStructure()
           
 DataDefinition getSubtable()
          The subtype created by an immediate ptr or set definition.
 String getTitleField()
          Get the alternative title field, if the title to be used is indicated specifically on a ptr or set.
 String getType()
          Returns field's internal makumba type.
 Collection<ValidationRule> getValidationRules()
          Returns all the validation rules connected to this field.
 Collection getValues()
          Get the values of an enumerated field.
 int getWidth()
          Get the maximum character width.
 boolean hasDescription()
          Tells wether this field has a description in the MDD
 boolean is_int_AssignableFrom(FieldDefinition fi)
           
 boolean is_intEnum_AssignableFrom(FieldDefinition fi)
           
 boolean is_ptrRel_AssignableFrom(FieldDefinition fi)
           
 boolean is_real_AssignableFrom(FieldDefinition fi)
           
 boolean is_set_AssignableFrom(FieldDefinition fi)
           
 boolean isAssignableFrom(FieldDefinition fi)
          check compatibility with the given type
 boolean isBinaryType()
          methods for type
 boolean isBooleanType()
          returns whether this field is a boolean type
 boolean isComplexSet()
          returns whether this field is a setComplex.
 boolean isDateType()
          returns whether this field is a date type, i.e. date, or the default fields dateCreate and dateModify.
 boolean isDefaultField()
          returns whether this field is a default field generated by makumba.
 boolean isEnumType()
          returns whether this field is a simple enum type, i.e. intEnum or charEnum.
 boolean isExternalSet()
          returns whether this field is an external set, i.e. set ptr, but not setIntEnum, not setCharEnum nor setComplex.
 boolean isFileType()
          returns whether this field is a file type.
 boolean isFixed()
          tells whether this field is fixed
 boolean isIndexPointerField()
          Indicates whether this field is the index pointer field of the DataDefinition it belongs to.
 boolean isIntegerType()
          returns whether this field is an integer type.
 boolean isInternalSet()
          returns whether this field is any kind of internal set type, i.e. set, setIntEnum, setCharEnum and setComplex, but not set.
 boolean isNotEmpty()
          tells whether this field is not empty
 boolean isNotNull()
          tells whether this field is not null
 boolean isNumberType()
          returns whether this field is a number type, i.e. int or real.
 boolean isPointer()
          returns whether this field is a pointer.
 boolean isRealType()
          returns whether this field is a real type.
 boolean isSetEnumType()
          returns whether this field is a set enum type, i.e. setIntEnum or setCharEnum.
 boolean isSetType()
          returns whether this field is a set type, i.e. set, setIntEnum or setCharEnum or setComplex.
 boolean isStringType()
          returns whether this field is a string type, i.e. char or text.
 boolean isUnique()
          methods for modifiers
protected  Object normalCheck(Object value)
           
 void setDefaultValue(Object defaultValue)
           
 void setDescription(String description)
           
 void setFixed(boolean fixed)
           
 void setName(String name)
          methods for base fields
 void setNotEmpty(boolean notEmpty)
           
 void setNotNull(boolean notNull)
           
 void setType(String type)
           
 void setUnique(boolean unique)
           
 boolean shouldEditBySingleInput()
          Indicates whether this field should be edited by a simple mak:input, or needs it's own form.
 String toString()
           
 String toString1()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mdd

protected DataDefinitionImpl mdd

name

protected String name

type

protected FieldType type

description

protected String description

fixed

protected boolean fixed

notNull

protected boolean notNull

notEmpty

protected boolean notEmpty

unique

protected boolean unique

notNullError

protected String notNullError

NaNError

protected String NaNError

uniqueError

protected String uniqueError

notEmptyError

protected String notEmptyError

notIntError

protected String notIntError

notRealError

protected String notRealError

notBooleanError

protected String notBooleanError

intEnumValues

protected LinkedHashMap<Integer,String> intEnumValues

intEnumValuesDeprecated

protected LinkedHashMap<Integer,String> intEnumValuesDeprecated

charEnumValues

protected Vector<String> charEnumValues

charEnumValuesDeprecated

protected Vector<String> charEnumValuesDeprecated

charLength

protected int charLength

pointedType

protected String pointedType

pointed

protected transient DataDefinition pointed

subfield

protected DataDefinitionImpl subfield
Constructor Detail

FieldDefinitionImpl

public FieldDefinitionImpl(String name,
                           String type,
                           String description)
Creates a field definition given a name, type and description

Parameters:
name - the name of the field
type - the type of the filed, e.g. char, int, ptr - but no relational type definition
description - the description of the field

FieldDefinitionImpl

public FieldDefinitionImpl(String name,
                           DataDefinitionImpl dd)
Minimal constructor for standard fields


FieldDefinitionImpl

public FieldDefinitionImpl(String name,
                           String type)
Creates a field definition given a name and a type

Parameters:
name - the name of the field
type - the type of the filed, e.g. char, int, ptr - but no relational type definition

FieldDefinitionImpl

public FieldDefinitionImpl(String name,
                           String type,
                           DataDefinitionImpl mdd)

FieldDefinitionImpl

public FieldDefinitionImpl(String name,
                           FieldDefinition fi)
for virtual FieldDefinition


FieldDefinitionImpl

public FieldDefinitionImpl(String name,
                           FieldDefinition field,
                           String description)
for virtual field definitions


FieldDefinitionImpl

public FieldDefinitionImpl(DataDefinitionImpl mdd,
                           FieldNode f)
constructor used when creating the DataDefinitionImpl during parsing

Method Detail

setName

public void setName(String name)
methods for base fields


getName

public String getName()
Description copied from interface: FieldDefinition
The name of this field, normally the same with the name of the field

Specified by:
getName in interface FieldDefinition

setType

public void setType(String type)

setDescription

public void setDescription(String description)

setFixed

public void setFixed(boolean fixed)

setNotNull

public void setNotNull(boolean notNull)

setNotEmpty

public void setNotEmpty(boolean notEmpty)

setUnique

public void setUnique(boolean unique)

setDefaultValue

public void setDefaultValue(Object defaultValue)

getDescription

public String getDescription()
Description copied from interface: FieldDefinition
Returns field's description

Specified by:
getDescription in interface FieldDefinition

hasDescription

public boolean hasDescription()
Description copied from interface: FieldDefinition
Tells wether this field has a description in the MDD

Specified by:
hasDescription in interface FieldDefinition

getDataDefinition

public DataDefinitionImpl getDataDefinition()
Description copied from interface: FieldDefinition
The data definition that contains this field definition

Specified by:
getDataDefinition in interface FieldDefinition

isUnique

public boolean isUnique()
methods for modifiers

Specified by:
isUnique in interface FieldDefinition

isFixed

public boolean isFixed()
Description copied from interface: FieldDefinition
tells whether this field is fixed

Specified by:
isFixed in interface FieldDefinition

isNotEmpty

public boolean isNotEmpty()
Description copied from interface: FieldDefinition
tells whether this field is not empty

Specified by:
isNotEmpty in interface FieldDefinition

isNotNull

public boolean isNotNull()
Description copied from interface: FieldDefinition
tells whether this field is not null

Specified by:
isNotNull in interface FieldDefinition

isBinaryType

public boolean isBinaryType()
methods for type

Specified by:
isBinaryType in interface FieldDefinition

isBooleanType

public boolean isBooleanType()
Description copied from interface: FieldDefinition
returns whether this field is a boolean type

Specified by:
isBooleanType in interface FieldDefinition

isComplexSet

public boolean isComplexSet()
Description copied from interface: FieldDefinition
returns whether this field is a setComplex.

Specified by:
isComplexSet in interface FieldDefinition

isDateType

public boolean isDateType()
Description copied from interface: FieldDefinition
returns whether this field is a date type, i.e. date, or the default fields dateCreate and dateModify.

Specified by:
isDateType in interface FieldDefinition

isEnumType

public boolean isEnumType()
Description copied from interface: FieldDefinition
returns whether this field is a simple enum type, i.e. intEnum or charEnum.

Specified by:
isEnumType in interface FieldDefinition

isExternalSet

public boolean isExternalSet()
Description copied from interface: FieldDefinition
returns whether this field is an external set, i.e. set ptr, but not setIntEnum, not setCharEnum nor setComplex.

Specified by:
isExternalSet in interface FieldDefinition

isFileType

public boolean isFileType()
Description copied from interface: FieldDefinition
returns whether this field is a file type.

Specified by:
isFileType in interface FieldDefinition

isIndexPointerField

public boolean isIndexPointerField()
Description copied from interface: FieldDefinition
Indicates whether this field is the index pointer field of the DataDefinition it belongs to.

Specified by:
isIndexPointerField in interface FieldDefinition

isIntegerType

public boolean isIntegerType()
Description copied from interface: FieldDefinition
returns whether this field is an integer type.

Specified by:
isIntegerType in interface FieldDefinition

isInternalSet

public boolean isInternalSet()
Description copied from interface: FieldDefinition
returns whether this field is any kind of internal set type, i.e. set, setIntEnum, setCharEnum and setComplex, but not set.

Specified by:
isInternalSet in interface FieldDefinition

isNumberType

public boolean isNumberType()
Description copied from interface: FieldDefinition
returns whether this field is a number type, i.e. int or real.

Specified by:
isNumberType in interface FieldDefinition

isPointer

public boolean isPointer()
Description copied from interface: FieldDefinition
returns whether this field is a pointer.

Specified by:
isPointer in interface FieldDefinition

isRealType

public boolean isRealType()
Description copied from interface: FieldDefinition
returns whether this field is a real type.

Specified by:
isRealType in interface FieldDefinition

isSetEnumType

public boolean isSetEnumType()
Description copied from interface: FieldDefinition
returns whether this field is a set enum type, i.e. setIntEnum or setCharEnum.

Specified by:
isSetEnumType in interface FieldDefinition

isSetType

public boolean isSetType()
Description copied from interface: FieldDefinition
returns whether this field is a set type, i.e. set, setIntEnum or setCharEnum or setComplex.

Specified by:
isSetType in interface FieldDefinition

isStringType

public boolean isStringType()
Description copied from interface: FieldDefinition
returns whether this field is a string type, i.e. char or text.

Specified by:
isStringType in interface FieldDefinition

addValidationRule

public void addValidationRule(Collection<ValidationRule> rules)
methods for validation rules

Specified by:
addValidationRule in interface FieldDefinition

addValidationRule

public void addValidationRule(ValidationRule rule)
Description copied from interface: FieldDefinition
Adds a new validation rule to this field.

Specified by:
addValidationRule in interface FieldDefinition

getValidationRules

public Collection<ValidationRule> getValidationRules()
Description copied from interface: FieldDefinition
Returns all the validation rules connected to this field.

Specified by:
getValidationRules in interface FieldDefinition

checkInsert

public void checkInsert(Dictionary<String,Object> d)
methods for checks (assignability)

Specified by:
checkInsert in interface FieldDefinition

checkUpdate

public void checkUpdate(Dictionary<String,Object> d)
Description copied from interface: FieldDefinition
check if the corresponding field from the dictionary can be updated

Specified by:
checkUpdate in interface FieldDefinition

checkValue

public Object checkValue(Object value)
Description copied from interface: FieldDefinition
check if the value can be assigned

Specified by:
checkValue in interface FieldDefinition

normalCheck

protected Object normalCheck(Object value)

isAssignableFrom

public boolean isAssignableFrom(FieldDefinition fi)
Description copied from interface: FieldDefinition
check compatibility with the given type

Specified by:
isAssignableFrom in interface FieldDefinition

base_isAssignableFrom

public boolean base_isAssignableFrom(FieldDefinition fi)

is_int_AssignableFrom

public boolean is_int_AssignableFrom(FieldDefinition fi)

is_intEnum_AssignableFrom

public boolean is_intEnum_AssignableFrom(FieldDefinition fi)

is_ptrRel_AssignableFrom

public boolean is_ptrRel_AssignableFrom(FieldDefinition fi)

is_real_AssignableFrom

public boolean is_real_AssignableFrom(FieldDefinition fi)

is_set_AssignableFrom

public boolean is_set_AssignableFrom(FieldDefinition fi)

getDataType

public String getDataType()
methods for types (java, sql, null)

Specified by:
getDataType in interface FieldDefinition

getJavaType

public Class<?> getJavaType()
Description copied from interface: FieldDefinition
The Java type of this field. For example, intEnum and int both have java.lang.Integer as data type

Specified by:
getJavaType in interface FieldDefinition

getIntegerType

public int getIntegerType()
Description copied from interface: FieldDefinition
returns the integer value associated with the field's internal makumba type.

Specified by:
getIntegerType in interface FieldDefinition

getNull

public Object getNull()
Description copied from interface: FieldDefinition
The null value for this type

Specified by:
getNull in interface FieldDefinition

getEmptyValue

public Object getEmptyValue()
Description copied from interface: FieldDefinition
The value returned in case there is no value in the database and no default value is indicated

Specified by:
getEmptyValue in interface FieldDefinition

getType

public String getType()
Description copied from interface: FieldDefinition
Returns field's internal makumba type. Can be:

Specified by:
getType in interface FieldDefinition

isDefaultField

public boolean isDefaultField()
Description copied from interface: FieldDefinition
returns whether this field is a default field generated by makumba.

Specified by:
isDefaultField in interface FieldDefinition

getDefaultDate

public Date getDefaultDate()
methods for default values

Specified by:
getDefaultDate in interface FieldDefinition

getDefaultInt

public int getDefaultInt()
Description copied from interface: FieldDefinition
Get the default value as an integer. Works only for int, intEnum types

Specified by:
getDefaultInt in interface FieldDefinition

getDefaultString

public String getDefaultString()
Description copied from interface: FieldDefinition
Get the default value as a String. Works only for char, text, charEnum, setcharEnum types

Specified by:
getDefaultString in interface FieldDefinition

getDefaultValue

public Object getDefaultValue()
returns the default value of this field

Specified by:
getDefaultValue in interface FieldDefinition

getDeprecatedValues

public Vector<String> getDeprecatedValues()
methods for enumerations

Specified by:
getDeprecatedValues in interface FieldDefinition

getEnumeratorSize

public int getEnumeratorSize()
Description copied from interface: FieldDefinition
Get the number of the members of an enumerated field. Works only for intEnum, charEnum types

Specified by:
getEnumeratorSize in interface FieldDefinition

getIntAt

public int getIntAt(int i)
Description copied from interface: FieldDefinition
Get the integer at a certain position in an enumerated type. Works only for intEnum types

Specified by:
getIntAt in interface FieldDefinition

getNameAt

public String getNameAt(int i)
Description copied from interface: FieldDefinition
Get the name at a certain position in an enumerated field. Works only for intEnum, charEnum types

Specified by:
getNameAt in interface FieldDefinition

getNameFor

public String getNameFor(int i)
Description copied from interface: FieldDefinition
Get the name for a certain value of the enumerated field. Works only for intEnum or setIntEnum

Specified by:
getNameFor in interface FieldDefinition

getNames

public Collection<String> getNames()
Description copied from interface: FieldDefinition
Get the names of an enumerated field. Works only for intEnum, charEnum types

Specified by:
getNames in interface FieldDefinition

getValues

public Collection getValues()
Description copied from interface: FieldDefinition
Get the values of an enumerated field. Works only for intEnum, charEnum types.

Specified by:
getValues in interface FieldDefinition

getForeignTable

public DataDefinition getForeignTable()
methods for relational types

Specified by:
getForeignTable in interface FieldDefinition
Returns:
the foreign type indicated in set or ptr definition

getOriginalFieldDefinition

public FieldDefinition getOriginalFieldDefinition()
Description copied from interface: FieldDefinition
The original field definition this field definition was made of, used e.g. in form responders.

Specified by:
getOriginalFieldDefinition in interface FieldDefinition

getPointedType

public DataDefinition getPointedType()
Description copied from interface: FieldDefinition
The type referred. Will return getRelationType() for ptr, ptrRel and set types and getSubtype() for ptrOne, set, setComplex types. Works only for ptrOne, set, setComplex types

Specified by:
getPointedType in interface FieldDefinition
Returns:
the subtype indicated in set or ptr definition

getSubtable

public DataDefinition getSubtable()
Description copied from interface: FieldDefinition
The subtype created by an immediate ptr or set definition. Works only for ptrOne, set, setComplex types

Specified by:
getSubtable in interface FieldDefinition
Returns:
the subtype indicated in set or ptr definition

getTitleField

public String getTitleField()
Description copied from interface: FieldDefinition
Get the alternative title field, if the title to be used is indicated specifically on a ptr or set. Works only for ptr and set types

Specified by:
getTitleField in interface FieldDefinition
Returns:
title field of the record in the foreign table, as indicated in this field definition or in the respective foreign table record definition
See Also:
DataDefinition.getTitleFieldName()

getWidth

public int getWidth()
Description copied from interface: FieldDefinition
Get the maximum character width. Works only for char, charEnum, setcharEnum types

Specified by:
getWidth in interface FieldDefinition

shouldEditBySingleInput

public boolean shouldEditBySingleInput()
Description copied from interface: FieldDefinition
Indicates whether this field should be edited by a simple mak:input, or needs it's own form.

Specified by:
shouldEditBySingleInput in interface FieldDefinition

toString

public String toString()
Overrides:
toString in class Object

toString1

public String toString1()

getStructure

public String getStructure()

getNotANumberErrorMessage

public String getNotANumberErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for the not a number field constraint, if specified

Specified by:
getNotANumberErrorMessage in interface FieldDefinition

getNotNullErrorMessage

public String getNotNullErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for not null field, if specified

Specified by:
getNotNullErrorMessage in interface FieldDefinition

getNotUniqueErrorMessage

public String getNotUniqueErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for the not unique field constraint, if specified

Specified by:
getNotUniqueErrorMessage in interface FieldDefinition

getNotEmptyErrorMessage

public String getNotEmptyErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for the not empty field constraint, if specified

Specified by:
getNotEmptyErrorMessage in interface FieldDefinition

getNotIntErrorMessage

public String getNotIntErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for the not an int field constraint, if specified

Specified by:
getNotIntErrorMessage in interface FieldDefinition

getNotRealErrorMessage

public String getNotRealErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for the not a real field constraint, if specified

Specified by:
getNotRealErrorMessage in interface FieldDefinition

getNotBooleanErrorMessage

public String getNotBooleanErrorMessage()
Description copied from interface: FieldDefinition
gets the error message for the not a boolean field constraint, if specified

Specified by:
getNotBooleanErrorMessage in interface FieldDefinition