$attribute

Other name(s) : $attrib$field

( documentation for Telosys generator version 3.3.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
Typically the column name for a relational database

.databaseSize : String

Returns the database size for the attribute

.databaseType : String

Returns the database native type for the attribute
For example : INTEGER, VARCHAR, etc...

.databaseTypeWithSize : String

Returns the database native type for the attribute with the size if it makes sens
For example : INTEGER, VARCHAR(24), NUMBER, CHAR(3), etc...

Since : 2.0.7

.dateAfterValue : String

Returns the 'date after' value (for date validation)

.dateBeforeValue : String

Returns the 'date before' value (for date validation)

.dateType : int

Returns the type of the date : $const.DATE_ONLY, $const.TIME_ONLY, $const.DATE_AND_TIME

.defaultValue : String

Returns the default value for the attribute

.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 (not null and not void)

Since : 3.3.0

.hasDatabaseDefaultValue() : boolean

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

.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

.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

.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

.maxLength : String

Returns the maximum length for the attribute (if any, else returns void)

.maxValue : String

Returns the maximum value for the attribute (if any, else returns void)

.minLength : String

Returns the minimum length for the attribute (if any, else returns void)

.minValue : String

Returns the minimum value for the attribute (if any, else returns void)

.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 (if any, else returns void)

.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, ..

.sqlType : String

Returns the database SQL type corresponding to the attribute
for example : INTEGER, VARCHAR(24), NUMBER, CHAR(3), etc...
Returns the 'sqlType' if explicitly defined or tries to infer it from the neutral type
The Sql Type inference is based on 'env.database' (PostgreSQL, MySQL, etc)
or 'env.databaseTypesMapping' (specific types mapping)

Since : 3.3.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

.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