$attribute

Other name(s) : $attrib$field

( documentation for Telosys generator version 4.0.0 )


This object provides all information about an entity attribute
Each attribute is obtained from its entity class


Example :
   
   #foreach( $attribute in $entity.attributes )
    $attribute.name : $attribute.type
   #end

Since : 2.0.0

Attributes and methods
.booleanFalseValue : String

Returns the value to use for a boolean when is FALSE (eg to be stored in a database)

.booleanTrueValue : String

Returns the value to use for a boolean when is TRUE (eg to be stored in a database)

.databaseComment : String

Returns the database comment for the attribute (or a void string if none)

Since : 2.1.1

.databaseDefaultValue : String

Returns the database default value for the attribute (or a void string if none)

.databaseName : String

Returns the database name for the attribute (as defined in the model)
or an empty string if none
Typically the column name for a relational database

.databaseSize : String

Returns the database size for the attribute
(for example : '45' or '10,2' for precision with scale)
or an empty string if none
Try to get the size from the 'database type' first
if not found return the standard size if any

.databaseType : String

Returns the database native type for the attribute (as defined in the model)
or an empty string if none
For example : INTEGER, VARCHAR, etc...

.dateAfterValue : String

Returns the 'date after' value (for date validation)
(returns a void string if none)

.dateBeforeValue : String

Returns the 'date before' value (for date validation)
(returns a void string if none)

.defaultValue : String

Returns the default value for the attribute
(returns a void string if none)

.entity : EntityInContext

Returns the entity owning the attribute

.fkParts : List of 'fkPart' objects

Returns the parts of Foreign Keys for which the attribute is implied.
Each 'FK part' provides the referenced entity and attribute (with table and colunm)
An empty list is returned if the attribute does not participate in any FK.

Example :
   #foreach( $fkPart in $attrib.fkParts )
   ...
   #end

Since : 3.3.0

.formattedName(int n) : String

Returns the attribute's name with trailing blanks in order to obtain the expected size

Parameters :
   n : the expected size

.formattedType(int n) : String

Returns the attribute's type with trailing blanks in order to obtain the expected size

Parameters :
   n : the expected size

.formattedWrapperType(int n) : String

Returns the attribute's wrapper type with trailing blanks in order to obtain the expected size

Parameters :
   n : the expected size

.fullType : String

Returns the full type name
e.g. for a Java object type : java.math.BigDecimal, java.util.Date, ..
or for a Java primitive type : short, int, ..

.generatedValueGenerator : String

Returns the generator for a 'generated value'
Typically for JPA : 'SequenceGenerator' or 'TableGenerator'

.generatedValueStrategy : String

Returns the strategy for a 'generated value' (or null if none)
e.g : 'auto', 'identity', 'sequence', 'table'

.getter : String

Returns the getter for the attribute
e.g : 'getFoo' for 'foo' (or 'isFoo' for a boolean primitive type)

.getterWithGetPrefix : String

Returns the getter for the attribute with always a 'get' prefix
even for a boolean

.hasDatabaseComment() : boolean

Returns TRUE if the attribute has a database comment defined in the model
(database comment not null and not void)

Example :
   #if ( $attribute.hasDatabaseComment() )
   ...
   #end

Since : 3.3.0

.hasDatabaseDefaultValue() : boolean

Returns TRUE if the attribute has a database default value
(database default value not null and not void)
If the attribute is 'auto-incremented' then always returns false

Example :
   #if ( $attribute.hasDatabaseDefaultValue() )
   ...
   #end

.hasDatabaseName() : boolean

Returns TRUE if the attribute has a database name explicitly defined in the model
(database name not null and not void)

Example :
   #if ( $attribute.hasDatabaseName() )
   ...
   #end

Since : 3.4.0

.hasDatabaseType() : boolean

Returns TRUE if the attribute has a database type explicitly defined in the model
(database type not null and not void)

Example :
   #if ( $attribute.hasDatabaseType() )
   ...
   #end

Since : 3.4.0

.hasDateAfterValidation() : boolean

Returns TRUE if the attribute must be validated as a date AFTER a given date value

.hasDateBeforeValidation() : boolean

Returns TRUE if the attribute must be validated as a date BEFORE a given date value

.hasDateFutureValidation() : boolean

Returns TRUE if the attribute must be validated as a date in the future

.hasDatePastValidation() : boolean

Returns TRUE if the attribute must be validated as a date in the past

.hasDefaultValue() : boolean

Returns TRUE if there's a default value for the attribute (not void)

.hasInitialValue() : boolean

Returns TRUE if there's an initial value for the attribute (not void)

.hasInputType() : boolean

Returns TRUE if there's an 'input type' defined for the attribute (not void)

Since : 3.3.0

.hasLabel() : boolean

Returns TRUE if there's an 'label' defined for the attribute (not void)

Since : 3.3.0

.hasSequenceGenerator() : boolean

Returns TRUE if the attribute is a 'generated value' using a 'sequence generator'
Typically for JPA '@SequenceGenerator'

.hasTableGenerator() : boolean

Returns TRUE if the attribute is a 'generated value' using a 'table generator'
Typically for JPA '@TableGenerator'

.hasTag(String tagName) : boolean

Returns TRUE if the attribute has a tag with the given name

Parameters :
   tagName : name of the tag for which to check the existence

Example :
   $attrib.hasTag('mytag')

Since : 3.3.0

.initialValue : String

Returns the initial value for the attribute

.inputType : String

Returns the 'input type' defined for the attribute
Typically for HTML 5 : 'number', 'date', ...

Since : 2.0.3

.insertable : String

Returns the 'insertable' flag value as string
( 'true' or 'false' or 'undefined' )

Since : 3.3.0

.insertableIs(boolean value) : boolean

Returns true if 'insertable' flag equals the given value
The flag can be 'undefined' then then neither true nor false

Parameters :
   value : the boolean value

Since : 3.3.0

.isAutoIncremented() : boolean

Returns TRUE if the attribute is 'auto-incremented' by the database
when a new entity is inserted in the database

.isBinaryType() : boolean

Returns TRUE if the attribute's neutral type is 'binary'

Since : 3.0.0

.isBooleanType() : boolean

Returns TRUE if the attribute's neutral type is'boolean'

Since : 2.0.7

.isByteType() : boolean

Returns TRUE if the attribute's neutral type is 'byte'

Since : 2.0.7

.isDatabaseNotNull() : boolean

Returns TRUE if the attribute must be NOT NULL when stored in the database

(!) DEPRECATED : use 'isNotNull()' instead

.isDateType() : boolean

Returns TRUE if the attribute's neutral type is 'date'

Since : 3.0.0

.isDecimalType() : boolean

Returns TRUE if the attribute's neutral type is 'decimal'

Since : 3.0.0

.isDoubleType() : boolean

Returns TRUE if the attribute's neutral type is 'double'

Since : 2.0.7

.isFK() : boolean

Returns TRUE if the attribute is used in (at least) one Foreign Key
( it can be an 'Simple FK' or a 'Composite FK' or both )

Since : 3.0.0

.isFKComposite() : boolean

Returns TRUE if the attribute is a part of a 'Composite Foreign Key'
( the FK is based on many attributes including this attribute )

Since : 3.0.0

.isFKSimple() : boolean

Returns TRUE if the attribute is itself a 'Simple Foreign Key'
( the FK is based only on this single attribute )

Since : 3.0.0

.isFloatType() : boolean

Returns TRUE if the attribute's neutral type is 'float'

Since : 2.0.7

.isGeneratedValue() : boolean

Returns TRUE if the attribute's value is generated when a new entity is inserted in the database
It can be generated by the database ('auto-incremented')
or generated by the persistence layer (typically by JPA)

.isIntegerType() : boolean

Returns TRUE if the attribute's neutral type is 'int'

Since : 2.0.7

.isKeyElement() : boolean

Returns TRUE if the attribute is the Primary Key or a part of the Primary Key in the database

.isLongText() : boolean

Returns TRUE if the attribute is a 'Long Text'
i.e. that cannot be transported in a classical string
Typically a text stored as a CLOB or a BLOB

.isLongType() : boolean

Returns TRUE if the attribute's neutral type is 'long'

Since : 2.0.7

.isNotBlank() : boolean

Returns TRUE if the attribute has a 'Not Blank' validation rule

.isNotEmpty() : boolean

Returns TRUE if the attribute has a 'Not Empty' validation rule

.isNotNull() : boolean

Returns TRUE if the attribute has a 'Not Null' validation rule

.isNumberType() : boolean

Returns TRUE if the attribute's neutral type is a number type
( byte, short, int, long, decimal, float, double )

Since : 2.0.7

.isPrimitiveType() : boolean

Returns TRUE if the attribute's language type is a primitive type
i.e. for Java : int, float, boolean, ...

.isSelected() : boolean

Returns TRUE if the attribute is selected (ckeckbox ckecked in the GUI)

.isShortType() : boolean

Returns TRUE if the attribute's neutral type is 'short'

Since : 2.0.7

.isStringType() : boolean

Returns TRUE if the attribute's neutral type is 'string'

Since : 2.0.7

.isTemporalType() : boolean

Returns TRUE if the attribute's neutral type is a temporal type
( date, time, timestamp )

Since : 2.0.7

.isTimeType() : boolean

Returns TRUE if the attribute's neutral type is 'time'

Since : 3.0.0

.isTimestampType() : boolean

Returns TRUE if the attribute's neutral type is 'timestamp'

Since : 3.0.0

.isTransient() : boolean

Returns TRUE if the attribute is marked as 'transient'

Since : 3.3.0

.isUnique() : boolean

Returns TRUE if the attribute is 'unique'

Since : 3.4.0

.jdbcRecommendedJavaType : String

Returns the recommended Java type for the JDBC type of the attribute

.jdbcTypeCode : int

Returns the JDBC type of the attribute (the type code)

.jdbcTypeName : String

Returns the JDBC type name ('CHAR', 'VARCHAR', 'NUMERIC', ... )

The 'java.sql.Types' constant name for the current JDBC type code

.label : String

Returns the label for the attribute
(returns a void string if none)

.maxLength : String

Returns the maximum length for the attribute
(returns a void string if none)

.maxValue : String

Returns the maximum value for the attribute
(returns a void string if none)

.minLength : String

Returns the minimum length for the attribute
(returns a void string if none)

.minValue : String

Returns the minimum value for the attribute
(returns a void string if none)

.name : String

Returns the name of the attribute

.neutralType : String

Returns the 'neutral type', that is to say the type as defined in the model
e.g. : 'string', 'short', 'decimal', 'boolean', 'date', 'time', etc

.pattern : String

Returns the Reg Exp pattern defined for the attribute
(returns a void string if none)

.referencedEntity : EntityInContext

Returns the entity referenced by this attribute (if any)
Can be used only if the attribute 'isFK'
Throws an exception if no entity is refrerenced by the attribute

Since : 3.0.0

.referencedEntityName : String

Returns the name (class name) of the entity referenced by this attribute (if any)
Can be used only if the attribute 'isFK'
Throws an exception if no entity is refrerenced by the attribute

Since : 3.0.0

.sequenceGeneratorAllocationSize : int

Returns the 'sequence allocation size' to be used in the 'sequence generator' definition
Typically for JPA '@SequenceGenerator/allocationSize'

.sequenceGeneratorName : String

Returns the name of the 'sequence generator'
Typically for JPA '@SequenceGenerator/name'

.sequenceGeneratorSequenceName : String

Returns the 'sequence name' to be used in the 'sequence generator' definition
Typically for JPA '@SequenceGenerator/sequenceName'

.setter : String

Returns the setter for the attribute
e.g : 'setFoo' for 'foo'

.simpleType : String

Returns the simple type name
e.g. for a Java object type : BigDecimal, Date, Integer, ..
or for a Java primitive type : short, int, ..

.size : String

Returns the attribute size if any.
Try to get the 'explicit size' first
if no 'explicit size' try to get the 'maximum length'.
The size is returned as a string containing the size as defined in the model
for example : '45' or '10,2' for precision with scale
Returns an empty string if no size

Since : 3.4.0

.sizeAsDecimal : BigDecimal

Returns the attribute size as decimal value (BigDecimal)
(same behavior as 'size' but with conversion to decimal )
Returns 0 if no size
If the size has a scale it is converted to 'precision.scale'
for example : 10.2 for '10,2'

Since : 3.4.0

.sqlColumnConstraints : String

Returns the SQL column constraints for the attribute
For example : NOT NULL DEFAULT 12


Since : 3.4.0

.sqlColumnName : String

Returns the SQL database column name for the attribute
For example 'city_code' for an attribute named 'cityCode'
The database name defined in the model is used in priority
if no database name is defined then the attribute name is converted to database name
by applying the target database conventions (defined in $env)


Since : 3.4.0

.sqlColumnType : String

Returns the SQL database column type for the attribute
For example 'varchar(12)' for an attribute with neutral type 'string'
The database type defined in the model is used in priority
if no database type is defined then the neutral type is converted to database type
by applying the target database conventions (defined in $env)


Since : 3.4.0

.tableGeneratorName : String

Returns the name of the 'table generator'
Typically for JPA '@TableGenerator/name'

.tableGeneratorPkColumnName : String

Returns the name of the Primary Key column used in the 'table generator'
Typically for JPA '@TableGenerator/pkColumnName'

.tableGeneratorPkColumnValue : String

Returns the primary key value in the generator table that distinguishes this set of generated values
from others that may be stored in the table
Typically for JPA '@TableGenerator/pkColumnValue'

.tableGeneratorTable : String

Returns the name of the table used in the 'table generator'
Typically for JPA '@TableGenerator/table'

.tableGeneratorValueColumnName : String

Returns the name of the column that stores the last value generated by the 'table generator'
Typically for JPA '@TableGenerator/valueColumnName'

.tagValue(String tagName) : String

Returns the value held by the given tag name
If the tag is undefined or has no value, the returned value is an empty string

Parameters :
   tagName : name of the tag for which to get the value

Example :
   $attrib.tagValue('mytag')

Since : 3.3.0

.tagValue(String tagName, String defaultValue) : String

Returns the value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $attrib.tagValue('mytag', 'abc')

Since : 3.4.0

.tagValueAsBoolean(String tagName, boolean defaultValue) : boolean

Returns the boolean value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $attrib.tagValueAsBoolean('mytag', false)

Since : 3.4.0

.tagValueAsInt(String tagName, int defaultValue) : int

Returns the integer value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $attrib.tagValueAsInt('mytag', 123)

Since : 3.4.0

.type : String

Returns the recommended type for the attribute
usually the simple type ( 'int', 'BigDecimal', 'Date' )
sometimes the full type ( if the simple type is considered as ambiguous )
Examples for Java : 'int', 'BigDecimal', 'Date', 'java.util.Date', 'java.sql.Date'

.updatable : String

Returns the 'updatable' flag value as string
( 'true' or 'false' or 'undefined' )

Since : 3.3.0

.updatableIs(boolean value) : boolean

Returns true if 'updatable' flag equals the given value
The flag can be 'undefined' then then neither true nor false

Parameters :
   value : the boolean value

Since : 3.3.0

.wrapperType : String

Returns the wrapper type corresponding to the attribute's primitive type
Examples : 'Float' for 'float', 'Integer' for 'int', 'Boolean' for 'boolean', ...
The attribute's type is retuned as is if it's not a primitive type