org.apache.cayenne.map
Class DbAttribute

java.lang.Object
  extended by org.apache.cayenne.map.Attribute
      extended by org.apache.cayenne.map.DbAttribute
All Implemented Interfaces:
java.io.Serializable, CayenneMapEntry, XMLSerializable
Direct Known Subclasses:
DerivedDbAttribute, EODbAttribute

public class DbAttribute
extends Attribute

A DbAttribute defines a descriptor for a single database table column.

Author:
Misha Shengaout, Andrei Adamchik
See Also:
Serialized Form

Field Summary
protected  boolean generated
          Defines whether this column value is generated by the database.
protected  boolean mandatory
          Defines whether the attribute allows nulls.
protected  int maxLength
           
protected  int precision
           
protected  boolean primaryKey
          Defines whether the attribute is a part of the table primary key.
protected  int type
          Defines JDBC type of the column.
 
Fields inherited from class org.apache.cayenne.map.Attribute
entity, name
 
Constructor Summary
DbAttribute()
           
DbAttribute(java.lang.String name)
           
DbAttribute(java.lang.String name, int type, DbEntity entity)
           
 
Method Summary
 void encodeAsXML(XMLEncoder encoder)
          Prints itself as XML to the provided XMLEncoder.
 java.lang.String getAliasedName(java.lang.String alias)
           
 int getMaxLength()
          Returns the length of database column described by this attribute.
 int getPrecision()
          Returns the number of digits after period for DECIMAL.
 int getType()
          Returns the SQL type of the column.
 boolean isForeignKey()
          Returns true if the DB column represented by this attribute is a foreign key, referencing another table.
 boolean isGenerated()
          Returns true if this column value is generated by the database.
 boolean isMandatory()
           
 boolean isPrimaryKey()
           
 void setGenerated(boolean generated)
          Updates attribute "generated" property.
 void setMandatory(boolean mandatory)
           
 void setMaxLength(int maxLength)
          Sets the length of character or binary type or max num of digits for DECIMAL.
 void setPrecision(int precision)
          Sets the number of digits after period for DECIMAL.
 void setPrimaryKey(boolean primaryKey)
          Updates attribute "primaryKey" property.
 void setType(int type)
          Sets the SQL type for the column.
 
Methods inherited from class org.apache.cayenne.map.Attribute
getEntity, getName, getParent, setEntity, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected int type
Defines JDBC type of the column.


mandatory

protected boolean mandatory
Defines whether the attribute allows nulls.


primaryKey

protected boolean primaryKey
Defines whether the attribute is a part of the table primary key.


generated

protected boolean generated
Defines whether this column value is generated by the database. Other terms for such columns are "auto-increment" or "identity".

Since:
1.2

maxLength

protected int maxLength

precision

protected int precision
Constructor Detail

DbAttribute

public DbAttribute()

DbAttribute

public DbAttribute(java.lang.String name)

DbAttribute

public DbAttribute(java.lang.String name,
                   int type,
                   DbEntity entity)
Method Detail

encodeAsXML

public void encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided XMLEncoder.

Since:
1.1

getAliasedName

public java.lang.String getAliasedName(java.lang.String alias)

getType

public int getType()
Returns the SQL type of the column.

See Also:
Types

setType

public void setType(int type)
Sets the SQL type for the column.

See Also:
Types

isPrimaryKey

public boolean isPrimaryKey()

isForeignKey

public boolean isForeignKey()
Returns true if the DB column represented by this attribute is a foreign key, referencing another table.

Since:
1.1

setPrimaryKey

public void setPrimaryKey(boolean primaryKey)
Updates attribute "primaryKey" property.


isMandatory

public boolean isMandatory()

setMandatory

public void setMandatory(boolean mandatory)

getMaxLength

public int getMaxLength()
Returns the length of database column described by this attribute.


setMaxLength

public void setMaxLength(int maxLength)
Sets the length of character or binary type or max num of digits for DECIMAL.


getPrecision

public int getPrecision()
Returns the number of digits after period for DECIMAL.


setPrecision

public void setPrecision(int precision)
Sets the number of digits after period for DECIMAL.


isGenerated

public boolean isGenerated()
Returns true if this column value is generated by the database. Other terms for such columns are "auto-increment" or "identity".

Since:
1.2

setGenerated

public void setGenerated(boolean generated)
Updates attribute "generated" property.

Since:
1.2


Copyright © 2001-2006 Apache.org All Rights Reserved.