Expresso 5-6

com.jcorporate.expresso.core.dataobjects
Interface DataObjectMetaData

All Superinterfaces:
Serializable
All Known Subinterfaces:
JDBCObjectMetaData
All Known Implementing Classes:
DBObjectDef, JoinedDataObjectMetaData

public interface DataObjectMetaData
extends Serializable

This interface contains the "definition" of the DBObject, while the DBObject itself contains only the data itself. One DBObjectDef object is stored in a static HashMap in the DBObject class, and is looked up and referenced for all definitions of the structure of the given object.

since this class is not threadsafe for adding information, it is imperitive that all information addition, typically done when the first instance of a DBObject is instantiated, is done in a synchronized context.

Author:
Michael Rimov

Method Summary
 boolean checkZeroUpdate()
          Retrieves whether or not checkZeroUpdate is enabled for this data object
 void disableLogging()
          Disable change logging of all objects of this type
 void enableLogging()
          Enable logging of changes to this object.
 Set getAllAttributes(String fieldName)
          Retrieve all the attributes so you can iterate through them.
 HashMap getAllFieldsMap()
          Return the "allFields" Hashtable, which contains all of the DBField objects that make up this DB object.
 HashMap getAllKeysMap()
          Return the "allKeys" hash, containing the DBField objects that make up the primary key for this db object.
 Object getAttribute(String fieldName, String attribName)
          Gets an Object attribute from the field's metatdata
 int getCacheSize()
          Get the current Cache size of this object.
 String getCharset()
          return the current object's character set
 String getDefaultValue(String fieldName)
          Retreive the default value of a particular field for when it is first instantiated
 String getDescription()
          Return a description of this database object.
 String getDescription(Locale l)
          Retrieve the table description in a localized way.
 String getDescription(Locale l, String fieldName)
          Retrieve an localized description as per the locale defined for the 'client'
 String getDescription(String fieldName)
          Return the long description of a field, if available
 String getDetailFieldsForeign(String detailName)
          Retrieve the foreign key fields
 String getDetailFieldsLocal(String detailName)
          Retrieve the local key fields.
 Set getDetailSet()
          Retrieve a list of all the detail objects
 ArrayList getFieldListArray()
          Get a list of all of the fields in this object This is threadsafe in that it makes a new copy of the fieldNamesInOrder ArrayList
 DataFieldMetaData getFieldMetadata(String fieldName)
          Get the DBField object specified by the fieldname
 String[] getFields()
          This convenience method iterates through all the fields belonging to this DBObject returns an array of field names ( String ).
 ArrayList getKeyFieldListArray()
          Get a list of all of the names of the key fields in this object
 String getLength(String fieldName)
          Return the length of a field
 int getLengthInt(String fieldName)
          Return the length of a field as an integer
 String getLookupField(String fieldName)
          When you get a lookup object, to perform a complete mapping between the two, you need to know what field name in the remote object maps to this field.
 String getLookupObject(String fieldName)
          Get a field's lookup object - this is the name of another database object that can be used to look up valid values for this object.
 String getName()
          Get the name of this object
 int getPrecision(String fieldName)
          Retrieve the precision of a particular field
 String getSchema()
          Retrieve the schema object's class name associated with this data object
 String getType(String fieldName)
          Return the type of a field - this method returns the internal Expresso type
 boolean hasField(String fieldName)
          This method will return a boolean true if the field is defined in the DBOBject, false otherwise.
 boolean isAllowsNull(String fieldName)
          Returns whether the field allows null values or not.
 boolean isField(String fieldName)
          Check if a certain name is a field (of any kind) in this DBOBject
 String isFieldIgnoreCase(String fieldName)
          Check if a certain name is a field (of any kind) in this DBOBject since SQL is case insensitive, ignore case of field name for match, this method takes longer, so use isField if the field name is known precisely
 boolean isLoggingEnabled()
          Retrieves whether or not change logging is enabled for a particular data object
 boolean isMultiValued(String fieldName)
          Method called to determine if a particular field is multi-valued, that is does it have a set of specific values and descriptions
 boolean isReadOnly(String fieldName)
          Is a given field readOnly - these fields are not offered for entry when a form is produced by the generic database maintenance servlet
 boolean isSecret(String fieldName)
          Is a given field 'secret' - these fields are not shown when a list is produced by the generic database maintenance servlet (DBMaint).
 boolean isVirtual(String fieldName)
          Is a given field virtual?
 void removeAttribute(String fieldName, String attribName)
          Removes an attribute from the field.
 void setAttribute(String fieldName, String attribName, Object attribValue)
           
 void setCacheSize(int newValue)
          Sets the cache size for this DBObject
 void setCheckZeroUpdate(boolean newFlag)
          Turn on or off the facility to verify that when an update is made that at least one record got updated.
 

Method Detail

getDefaultValue

public String getDefaultValue(String fieldName)
Retreive the default value of a particular field for when it is first instantiated

Parameters:
fieldName - the name of the field to retrieve
Returns:
java.lang.String

getDetailSet

public Set getDetailSet()
Retrieve a list of all the detail objects

Returns:
java.util.Set

getDetailFieldsLocal

public String getDetailFieldsLocal(String detailName)
Retrieve the local key fields.

Parameters:
detailName - the name of the detail dbobject
Returns:
java.lang.String

getDetailFieldsForeign

public String getDetailFieldsForeign(String detailName)
Retrieve the foreign key fields

Parameters:
detailName - the name of the detail dbobject
Returns:
java.lang.String

isAllowsNull

public boolean isAllowsNull(String fieldName)
                     throws DBException
Returns whether the field allows null values or not.

Parameters:
fieldName - name of the field
Returns:
true if the field allows null
Throws:
DBException

removeAttribute

public void removeAttribute(String fieldName,
                            String attribName)
Removes an attribute from the field.

Parameters:
fieldName - the name of the field to remove the attribute
attribName - the attribute name to remove

setAttribute

public void setAttribute(String fieldName,
                         String attribName,
                         Object attribValue)
                  throws DBException
Parameters:
fieldName - the name of the field to set the attribute for
attribName - the name of the attribute to set
attribValue - the attribute to set
Throws:
DBException

getAttribute

public Object getAttribute(String fieldName,
                           String attribName)
                    throws DBException
Gets an Object attribute from the field's metatdata

Parameters:
fieldName - the name of the field for the attribute
attribName - the name of the attribute
Returns:
java.lang.Object
Throws:
DBException

getAllAttributes

public Set getAllAttributes(String fieldName)
Retrieve all the attributes so you can iterate through them.

Parameters:
fieldName - the name of the field to get all the attributes
Returns:
java.util.Set of all attributes.

disableLogging

public void disableLogging()
Disable change logging of all objects of this type


enableLogging

public void enableLogging()
Enable logging of changes to this object. Change logging writes an entry to the ChangeLog object every time an add, update, or delete is made to this object. It is used to track important tables, such as user information, account information, etc.


isLoggingEnabled

public boolean isLoggingEnabled()
Retrieves whether or not change logging is enabled for a particular data object

Returns:
boolean true if logging is enabled.

isFieldIgnoreCase

public String isFieldIgnoreCase(String fieldName)
Check if a certain name is a field (of any kind) in this DBOBject since SQL is case insensitive, ignore case of field name for match, this method takes longer, so use isField if the field name is known precisely

Parameters:
fieldName - the name of the field to check
Returns:
internal format for field name if matched, or null if no match

isField

public boolean isField(String fieldName)
Check if a certain name is a field (of any kind) in this DBOBject

Parameters:
fieldName - the name of the field to check
Returns:
true if the field name exists

getAllFieldsMap

public HashMap getAllFieldsMap()
Return the "allFields" Hashtable, which contains all of the DBField objects that make up this DB object.

Returns:
java.util.HashMap

getAllKeysMap

public HashMap getAllKeysMap()
Return the "allKeys" hash, containing the DBField objects that make up the primary key for this db object.

Returns:
java.util.HashMap

getCharset

public String getCharset()
return the current object's character set

Returns:
java.lang.String

getCacheSize

public int getCacheSize()
Get the current Cache size of this object. or -2 if it hasn't been defined yet.

Returns:
current cache size value.

setCacheSize

public void setCacheSize(int newValue)
Sets the cache size for this DBObject

Parameters:
newValue - the new value. Must be >= -2
Throws:
IllegalArgumentException - if newValue < -2

getDescription

public String getDescription()
Return a description of this database object. If no explicit description has been set, return the class name.

Returns:
A string describing this database object

getDescription

public String getDescription(String fieldName)
                      throws DBException
Return the long description of a field, if available

Parameters:
fieldName - The name of the field
Returns:
String: The long description of the field (user-readable)
Throws:
DBException - If there is no such field

getDescription

public String getDescription(Locale l,
                             String fieldName)
Retrieve an localized description as per the locale defined for the 'client'

Parameters:
l - the Locale to use. If null, will use the System default Locale
fieldName - the name of the field to retrieve the i18n'ized description for.
Returns:
the localized description of the field name

getFieldMetadata

public DataFieldMetaData getFieldMetadata(String fieldName)
Get the DBField object specified by the fieldname

Parameters:
fieldName - the name of the field to retrieve
Returns:
DBField object

getFieldListArray

public ArrayList getFieldListArray()
Get a list of all of the fields in this object This is threadsafe in that it makes a new copy of the fieldNamesInOrder ArrayList

Returns:
An array of all of the fieldNames in this object

getKeyFieldListArray

public ArrayList getKeyFieldListArray()
Get a list of all of the names of the key fields in this object

Returns:
An ArrayList of all of the names of the key fields

getLength

public String getLength(String fieldName)
                 throws DBException
Return the length of a field

Parameters:
fieldName - The name of the field
Returns:
String: The length of the field
Throws:
DBException - If there is no such field in this object

getLengthInt

public int getLengthInt(String fieldName)
                 throws DBException
Return the length of a field as an integer

Parameters:
fieldName - The name of the field
Returns:
integer: The length of the field
Throws:
DBException - If there is no such field in this object

getPrecision

public int getPrecision(String fieldName)
                 throws DBException
Retrieve the precision of a particular field

Parameters:
fieldName - The name of the field
Returns:
integer for demcimal precision of the field
Throws:
DBException

getLookupObject

public String getLookupObject(String fieldName)
                       throws DBException
Get a field's lookup object - this is the name of another database object that can be used to look up valid values for this object. The lookup object for a field is set in the db objects setupFields method, and is used by the DBMaint servlet to provide automatic lookup links for fields.

Parameters:
fieldName - Field name to check
Returns:
String specifying the className of the lookup object
Throws:
DBException - If the specified field does not exist.

getLookupField

public String getLookupField(String fieldName)
When you get a lookup object, to perform a complete mapping between the two, you need to know what field name in the remote object maps to this field.

Parameters:
fieldName - the name of the field to look up.
Returns:
java.lang.String or null if there is no lookup field
Throws:
IllegalArgumentException - if the field name does not exist

getName

public String getName()
Get the name of this object

Returns:
String The database object name, or the table name if none has been assigned

getType

public String getType(String fieldName)
               throws DBException
Return the type of a field - this method returns the internal Expresso type

Parameters:
fieldName - The name of the field
Returns:
String: The type of the field
Throws:
DBException - If there is no such field in this object

hasField

public boolean hasField(String fieldName)
This method will return a boolean true if the field is defined in the DBOBject, false otherwise. Creation date: (8/8/00 11:04:32 AM)

Parameters:
fieldName - java.lang.String
Returns:
boolean

isMultiValued

public boolean isMultiValued(String fieldName)
                      throws DBException
Method called to determine if a particular field is multi-valued, that is does it have a set of specific values and descriptions

Parameters:
fieldName - Name of the field
Returns:
boolean True if the field is multi-valued, false if not
Throws:
DBException - If there is no such field

isReadOnly

public boolean isReadOnly(String fieldName)
                   throws DBException
Is a given field readOnly - these fields are not offered for entry when a form is produced by the generic database maintenance servlet

Parameters:
fieldName - name of the field to check
Returns:
true of the field is "read only", false if it is not
Throws:
DBException - Ff there is no such field

isSecret

public boolean isSecret(String fieldName)
                 throws DBException
Is a given field 'secret' - these fields are not shown when a list is produced by the generic database maintenance servlet (DBMaint). This means that only users with update permission to the record can see the value of the specified field.

Parameters:
fieldName - The name of the field to check
Returns:
True if the field is 'secret', false if it is not
Throws:
DBException - If there is no such field.

isVirtual

public boolean isVirtual(String fieldName)
                  throws DBException
Is a given field virtual? A virtual field is not stored in the target table for this object - it may be computed, or stored in another table.

Parameters:
fieldName - The name of the field to check
Returns:
True of the field is virtual, false if it is not
Throws:
DBException - If there is no such field

setCheckZeroUpdate

public void setCheckZeroUpdate(boolean newFlag)
Turn on or off the facility to verify that when an update is made that at least one record got updated. If this flag is on, and no records get updated, the update() method throws an Exception. Note that for some databases, if the existing record is not changed (e.g. it was already identical to what was being updated) this counts "no update" (notably, mySQL does this).

Parameters:
newFlag - True to turn on checking, false to turn it off

checkZeroUpdate

public boolean checkZeroUpdate()
Retrieves whether or not checkZeroUpdate is enabled for this data object

Returns:
true if checkZeroUpdate() is enabled

getSchema

public String getSchema()
Retrieve the schema object's class name associated with this data object

Returns:
the className of the schema associated with this DBObject

getFields

public String[] getFields()

This convenience method iterates through all the fields belonging to this DBObject returns an array of field names ( String ).

Returns:
String array of all field names in this object.
See Also:
#getFieldList()

getDescription

public String getDescription(Locale l)
Retrieve the table description in a localized way. If l == null, the function uses the system locale to generate the value. If unable to locate the key in the message bundle, the key becomes the return value.

Parameters:
l - the Locale to use for rendering the table description
Returns:
java.lang.String

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.