Business Components

oracle.jbo.server
Class AttributeDefImpl

java.lang.Object
  |
  +--oracle.jbo.common.BaseObject
        |
        +--oracle.jbo.server.NamedObjectImpl
              |
              +--oracle.jbo.server.DefObject
                    |
                    +--oracle.jbo.server.AttributeDefImpl

public class AttributeDefImpl
extends oracle.jbo.server.DefObject
implements AttributeDef, EJBPersistable

Describes properties exported by JavaBeans. An instance of this class describe a property that is accessible through get and set methods.

Since:
JDeveloper 3.0

Field Summary
static byte ATTR_LOAD_BULK
           
static byte ATTR_LOAD_EACH
           
static byte ATTR_LOAD_SKIP
           
protected  byte mAttrLoad
          Attribute Loading
protected  java.lang.String mColumnName
          Column name for the attribute
protected  oracle.jbo.server.RowDef mDef
          Back Pointer to Def Object where the Attribute belongs
protected  java.lang.Object mDefaultValue
          Deafult Value
protected  java.lang.Object mElemFactory
           
protected  java.lang.Class mElemType
          The Java Type Object
protected  int mIndex
          Index in the Table
protected  java.lang.Class mJavaType
          The Java Type Object
protected  byte mKind
          Attribute kind : Transient, Dynamic etc
protected  boolean mMandatory
          Does this attribute not allow null values
protected  boolean mNotNull
          Is null or not
protected  boolean mObjectTableOID
          Is OID present
protected  boolean mObjectTableRef
          Does it have Object table ref
protected  java.lang.String mObjectType
          Object Type
protected  java.lang.String[] mOIDAttrNames
           
protected  int mPrecision
          Precision Value , defualted to zero
protected  boolean mPrimaryKey
          Is primary Key or not
protected  boolean mQueriable
          Is queryable or not
protected  java.lang.reflect.Method mReadMethod
          To keep the read method with this attribute
protected  boolean mRetrievedOnInsert
          Is retrieved on Insert
protected  boolean mRetrievedOnUpdate
          Is retrieved on update
protected  int mScale
          Scale value for attribute set by default to 0 Its the number of decimal points before/after the decimal based on whether on whether the scale if positive or negative
protected  SQLBuilder mSQLBuilder
          Handle to SQL Builder
protected  int mType
          Attribute SQLtype
protected  java.lang.Object mTypeFactory
          The CustomDatumFactory
protected  boolean mTypeFactoryInitialized
          No factory Found
protected  byte mUpdateable
          Is the attribute updatable
protected  java.lang.reflect.Method mWriteMethod
          To keep the write method with this attribute
 
Fields inherited from class oracle.jbo.server.DefObject
mCompUsageList, mCompUsages
 
Fields inherited from class oracle.jbo.server.NamedObjectImpl
mFullName, mName, mParent, mProperties
 
Fields inherited from class oracle.jbo.common.BaseObject
TRACE_EVERY_ALLOC, TRACE_NONE, TRACE_OCCASIONAL, TRACE_UNINITIALIZED
 
Fields inherited from interface oracle.jbo.AttributeDef
ATTR_ASSOCIATED_ROW, ATTR_ASSOCIATED_ROWITERATOR, ATTR_DYNAMIC, ATTR_ENTITY_DERIVED, ATTR_PERSISTENT, ATTR_SQL_DERIVED, ATTR_TRANSIENT, READONLY, UPDATEABLE, UPDATEABLE_WHILE_NEW
 
Constructor Summary
protected AttributeDefImpl()
          Default constructor
 
Method Summary
 void beanToStore(java.lang.Object bean, Row store)
           
 java.lang.Object convertToJava(java.lang.Object data)
          Converts a value from the database type to a Java type.
 java.lang.Object convertToStorage(java.lang.Object data, DBTransactionImpl trans)
          Converts a value from the attribute's Java type to a database type.
 byte getAttributeKind()
          Gets the "kind" of this attribute.
 byte getAttrLoad()
          Gets the attribute's load value.
 java.lang.String getColumnName()
          Gets the column name of the attribute.
 java.lang.String getColumnNameForQuery()
          Gets the column name to be used in query statement.
 oracle.jbo.server.RowDef getDef()
          Gets the DefObject which describes this attribute.
 java.lang.Object getDefaultValue()
          Gets the default value of the attribute.
 java.lang.Object getElemFactory()
           
 java.lang.Class getElemType()
          Gets the element type of the attribute.
 EntityDefImpl getEntityDef()
          Gets the EntityDefImpl which contains this attribute.
 int getIndex()
          Gets the column position of this attribute in the data source.
 java.lang.Class getJavaType()
          Gets the Java type of the attribute.
 java.lang.String getName()
          Gets the name of the attribute.
 java.lang.String getObjectType()
          Gets the name of the attribute's type name.
 java.lang.String[] getOIDAttrNames()
           
 int getPrecision()
          Gets the attribute's precision.
 java.util.Hashtable getProperties()
          Creates a table of this attribute's properties.
 java.lang.Object getProperty(java.lang.String hintName)
          Retrieves the specified property, if available.
 int getScale()
          Gets the attribute's scale value.
protected  SQLBuilder getSQLBuilder()
          Get the SQLBuilderImpl - lazily building
 int getSQLType()
          Gets the SQL type of this attribute.
static java.lang.String getSQLTypeIdToString(int typeId)
          Converts an identifier to the name of an SQL type.
static int getSQLTypeStringToId(java.lang.String sqlType)
          Converts a SQL type name to its identifier.
 java.lang.Object getTypeFactory()
           
 byte getUpdateableFlag()
          Tests if this attribute is updateable.
 boolean isMandatory()
          Tests if an attribute is not null.
 boolean isObjectTableOID()
           
 boolean isObjectTableRef()
           
 boolean isPrimaryKey()
          Tests if this attribute is a Primary Key.
 boolean isQueriable()
          Tests if this attribute can be queried.
 boolean isRetrievedOnInsert()
          Tests if the attribute is retrieved after a row is inserted.
 boolean isRetrievedOnUpdate()
          Tests if the attribute is retrieved after a row is updated.
 java.lang.Object loadFromResultSet(java.sql.ResultSet rs, int index, DBTransactionImpl trans)
           
 java.lang.Object loadFromStatement(java.sql.PreparedStatement cs, int index, Transaction trans)
           
 void storeToBean(java.lang.Object bean, Row store)
           
 
Methods inherited from class oracle.jbo.server.DefObject
getPackageDef, getPackageName, isObjectResolved
 
Methods inherited from class oracle.jbo.server.NamedObjectImpl
getFullName, getParent, getPropertiesAsStrings, setFullName, setProperty
 
Methods inherited from class oracle.jbo.common.BaseObject
dumpState, setTraceLevel, setTraceWriter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_LOAD_EACH

public static final byte ATTR_LOAD_EACH

ATTR_LOAD_BULK

public static final byte ATTR_LOAD_BULK

ATTR_LOAD_SKIP

public static final byte ATTR_LOAD_SKIP

mColumnName

protected java.lang.String mColumnName
Column name for the attribute

mQueriable

protected boolean mQueriable
Is queryable or not

mPrimaryKey

protected boolean mPrimaryKey
Is primary Key or not

mMandatory

protected boolean mMandatory
Does this attribute not allow null values

mRetrievedOnInsert

protected boolean mRetrievedOnInsert
Is retrieved on Insert

mRetrievedOnUpdate

protected boolean mRetrievedOnUpdate
Is retrieved on update

mDef

protected oracle.jbo.server.RowDef mDef
Back Pointer to Def Object where the Attribute belongs

mObjectTableRef

protected boolean mObjectTableRef
Does it have Object table ref

mObjectTableOID

protected boolean mObjectTableOID
Is OID present

mOIDAttrNames

protected java.lang.String[] mOIDAttrNames

mObjectType

protected java.lang.String mObjectType
Object Type

mNotNull

protected boolean mNotNull
Is null or not

mPrecision

protected int mPrecision
Precision Value , defualted to zero

mScale

protected int mScale
Scale value for attribute set by default to 0 Its the number of decimal points before/after the decimal based on whether on whether the scale if positive or negative

mUpdateable

protected byte mUpdateable
Is the attribute updatable

mKind

protected byte mKind
Attribute kind : Transient, Dynamic etc

mAttrLoad

protected byte mAttrLoad
Attribute Loading

mType

protected int mType
Attribute SQLtype

mIndex

protected int mIndex
Index in the Table

mDefaultValue

protected java.lang.Object mDefaultValue
Deafult Value

mJavaType

protected java.lang.Class mJavaType
The Java Type Object

mElemType

protected java.lang.Class mElemType
The Java Type Object

mReadMethod

protected java.lang.reflect.Method mReadMethod
To keep the read method with this attribute

mWriteMethod

protected java.lang.reflect.Method mWriteMethod
To keep the write method with this attribute

mTypeFactory

protected java.lang.Object mTypeFactory
The CustomDatumFactory

mElemFactory

protected java.lang.Object mElemFactory

mTypeFactoryInitialized

protected boolean mTypeFactoryInitialized
No factory Found

mSQLBuilder

protected SQLBuilder mSQLBuilder
Handle to SQL Builder
Constructor Detail

AttributeDefImpl

protected AttributeDefImpl()
Default constructor
Method Detail

getName

public java.lang.String getName()
Description copied from interface: AttributeDef
Gets the name of the attribute.
Specified by:
getName in interface AttributeDef
Overrides:
getName in class NamedObjectImpl
Returns:
the name of the attribute.

isQueriable

public boolean isQueriable()
Tests if this attribute can be queried.

Queriable attributes are those attributes that may have a filter condition for the WHERE clause. If this method returns false, the attribute will not be used in constructing the WHERE clause of the SQL statement.

Specified by:
isQueriable in interface AttributeDef
Returns:
true if queriable.

getUpdateableFlag

public byte getUpdateableFlag()
Tests if this attribute is updateable.
Specified by:
getUpdateableFlag in interface AttributeDef
Returns:
true if this is an editable attribute.

isPrimaryKey

public boolean isPrimaryKey()
Tests if this attribute is a Primary Key.
Specified by:
isPrimaryKey in interface AttributeDef
Returns:
true if this is a Primary Key.

isRetrievedOnInsert

public boolean isRetrievedOnInsert()
Tests if the attribute is retrieved after a row is inserted.

Some derived attributes need to be re-fetched after a save operation has been performed. These typically include timestamps, computed fields, virtual columns and Oracle ROWIDs and OIDs.

Returns:
true if this attribute is retrieved after insert operations.

isRetrievedOnUpdate

public boolean isRetrievedOnUpdate()
Tests if the attribute is retrieved after a row is updated.

Some derived attributes need to be re-fetched after a save operation has been performed. These typically include timestamps, computed fields, virtual columns and Oracle ROWIDs and OIDs.

Returns:
true if this attribute is retrieved after update operations.

isMandatory

public boolean isMandatory()
Tests if an attribute is not null.
Specified by:
isMandatory in interface AttributeDef
Returns:
true if this is attribute not null.

isObjectTableRef

public boolean isObjectTableRef()

isObjectTableOID

public boolean isObjectTableOID()

getOIDAttrNames

public java.lang.String[] getOIDAttrNames()

getObjectType

public java.lang.String getObjectType()
Gets the name of the attribute's type name.
Returns:
the name of the type.

getPrecision

public int getPrecision()
Gets the attribute's precision.

For strings, precision is maximum allowed length. For numeric values, precision is the number of significant digits.

Specified by:
getPrecision in interface AttributeDef
Returns:
the precision value, or 0 if unspecified.

getScale

public int getScale()
Gets the attribute's scale value.

Scale value is meaningful only for numeric attributes.

Specified by:
getScale in interface AttributeDef
Returns:
the scale value, or 0 if unspecified.

getEntityDef

public EntityDefImpl getEntityDef()
Gets the EntityDefImpl which contains this attribute.
Returns:
this Entity Object definition to which this attribute belongs.

getDef

public oracle.jbo.server.RowDef getDef()
Gets the DefObject which describes this attribute.
Returns:
the definition for this attribute.

getIndex

public int getIndex()
Gets the column position of this attribute in the data source.
Specified by:
getIndex in interface AttributeDef
Returns:
the column index.

getSQLType

public int getSQLType()
Gets the SQL type of this attribute.
Specified by:
getSQLType in interface AttributeDef
Returns:
the data type, a value of java.sql.Types.

getAttributeKind

public byte getAttributeKind()
Gets the "kind" of this attribute.
Specified by:
getAttributeKind in interface AttributeDef
Returns:
one of ATTR_PERSISTENT, ATTR_SQL_DERIVED, ATTR_ASSOCIATED_ROW, ATTR_TRANSIENT or ATTR_DYNAMIC.

getAttrLoad

public byte getAttrLoad()
Gets the attribute's load value.
Returns:
the load value

getJavaType

public java.lang.Class getJavaType()
Gets the Java type of the attribute.

Subclasses should override this method because entities with no accessors should also be able to get their types from attribute descriptors and beans.

Specified by:
getJavaType in interface AttributeDef
Returns:
the attribute's Java class, or Object for attributes which have no accessor methods available.

getElemType

public java.lang.Class getElemType()
Gets the element type of the attribute.

Element type is relevant only if the attribute is an array attribute.

Returns:
the attribute's element class, or null if the attribute is not an array attribute.

getDefaultValue

public java.lang.Object getDefaultValue()
Gets the default value of the attribute.

The default value for an attribute is expressed in terms of the Java type system, rather than the storage type system.

Returns:
the default value for the attribute, or null if none.

getColumnName

public java.lang.String getColumnName()
Gets the column name of the attribute.
Specified by:
getColumnName in interface AttributeDef
Returns:
the database column name of this attribute.

getColumnNameForQuery

public java.lang.String getColumnNameForQuery()
Gets the column name to be used in query statement. For entities, this name is same as the column name returned by getColumnName(). For view object, it may be different.
Specified by:
getColumnNameForQuery in interface AttributeDef
Returns:
the column name to be used in query.

convertToJava

public java.lang.Object convertToJava(java.lang.Object data)
                               throws DataCreationException
Converts a value from the database type to a Java type.

This method uses AttributeDefImpl() metadata to convert a database value to the corresponding Java value.

Parameters:
data - a storage value to be converted.
Returns:
an object of the Java type defined for this attribute.
Throws:
DataCreationException - if the conversion cannot be performed.

getTypeFactory

public java.lang.Object getTypeFactory()

getElemFactory

public java.lang.Object getElemFactory()

loadFromResultSet

public java.lang.Object loadFromResultSet(java.sql.ResultSet rs,
                                          int index,
                                          DBTransactionImpl trans)
                                   throws DataCreationException

loadFromStatement

public java.lang.Object loadFromStatement(java.sql.PreparedStatement cs,
                                          int index,
                                          Transaction trans)
                                   throws DataCreationException

convertToStorage

public java.lang.Object convertToStorage(java.lang.Object data,
                                         DBTransactionImpl trans)
Converts a value from the attribute's Java type to a database type.

This method uses AttributeDefImpl() metadata to convert a Java value to the corresponding database value.

Parameters:
data - a Java value to be converted.
trans -  
Returns:
an object of the storage type.
Throws:
DataCreationException - if the conversion cannot be performed.

getSQLTypeStringToId

public static int getSQLTypeStringToId(java.lang.String sqlType)
Converts a SQL type name to its identifier.
Parameters:
sqlType - the name of a SQL datatype.
Returns:
the SQL type's identifier.
See Also:
JboTypeMap

getSQLTypeIdToString

public static java.lang.String getSQLTypeIdToString(int typeId)
Converts an identifier to the name of an SQL type.
Parameters:
typeID - an SQL type identifier.
Returns:
the name of an SQL type.
See Also:
JboTypeMap

getProperty

public java.lang.Object getProperty(java.lang.String hintName)
Retrieves the specified property, if available.
Overrides:
getProperty in class NamedObjectImpl
Parameters:
hintName - the property's key.
Returns:
the property associated with hintName, or null if not found.

getProperties

public java.util.Hashtable getProperties()
Creates a table of this attribute's properties.
Overrides:
getProperties in class NamedObjectImpl
Returns:
the table of properties.

getSQLBuilder

protected SQLBuilder getSQLBuilder()
Get the SQLBuilderImpl - lazily building
Returns:
the SQLBuilderImpl

storeToBean

public void storeToBean(java.lang.Object bean,
                        Row store)
Specified by:
storeToBean in interface EJBPersistable

beanToStore

public void beanToStore(java.lang.Object bean,
                        Row store)
Specified by:
beanToStore in interface EJBPersistable

Business Components