Expresso 5-6

com.jcorporate.expresso.core.dbobj
Class DBObject

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Serializable
Direct Known Subclasses:
ChangeLog, RowGroupPerms, RowPermissions, SecuredDBObject

public abstract class DBObject
extends JDBCDataObject
implements Cacheable, LookupInterface

DBObjects are the core of Expresso's object-relational mapping. They are object-oriented wrappers for some sort of data. They are generally expected to be used in a single thread, like in processing a web query.

When making your own application, you derive your classes from DBObject or SecuredDBObject.

Since:
Expresso 1.0
Author:
Michael Nash
See Also:
SecuredDBObject, DBException, DBConnection, Serialized Form

Nested Class Summary
 class DBObject.FieldError
          Private class that defines errors for fields.
 class DBObject.FieldUpdate
          Private class used to track field updates
 
Field Summary
static String ATTRIBUTE_ERROR
          Attribute String for if there's an error with the field.
static String ATTRIBUTE_ERROR_MESSAGE
          Attribute String for what message to display if there's an error with thie field.
static String ATTRIBUTE_PAGE_LIMIT
          Attribute for what is the limit to retrieve from searchAndRetrieve operations
protected static BigDecimal BIG_DECIMAL_ZERO
          A static zero BIG DECIMAL object

author Peter Pilgrim

static String EMAIL_MASK
          Email Regular Expression Constant.
static String EVENT_ADD
          Event 'Add' code
static String EVENT_DELETE
          Event 'Delete' Code
static String EVENT_UPDATE
          Event 'Update' Code
static String FLOAT_MASK
          Floating point regular expression syntax for easy reference.
static String INT_MASK
          Integer Regular Expression for easy reference
static String IS_CHECK_RELATIONAL_INTEGRITY
           
static String UPDATE_CHANGED_ONLY
          setup code for update() policy: for efficiency, developers who are confident that their code does not have any 'blind updates' can set the Setup value UPDATE_CHANGED_ONLY to true (a blind update is where the object is not retieved before values in it are reset)
static String WHERE_KEYWORD
           
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, LONGBINARY_READ_DEFAULT_SIZE, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus, globalMask
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
DBObject()
          Default Constructor.
DBObject(DBConnection newConnection)
          Constructor that sets a connection as the object is created - typically this is used when a particular DBConnection is required for the purposes of maintaining a database transaction.
DBObject(DBConnection newConnection, String setupTablesContext)
          Constructor that sets a connection as the object is created - typically this is used when a particular DBConnection is required for the purposes of maintaining a database transaction.
DBObject(RequestContext request)
          For using DBObjects within Controllers.
DBObject(String newdbKey)
          Initialize this DBObject and set the db/context to the specified key
 
Method Summary
 void add()
          Add a new record to the target table.
protected  void addDetail(String objName, String keyFieldsLocal, String keyFieldsForeign)
          Specify a new "detail" db object, and the fields in this object they specify the fields in the related object
protected  void addField(String fieldName, String fieldType, int fieldSize, boolean allowNull, String fieldDescription)
          Add a field with more details: This version of addfield supplies the allowNull flags and a description of the field to be used when reporting errors to the user.
protected  void addField(String fieldName, String fieldType, int fieldSize, int fieldPrecision, boolean allowNull, String fieldDescription)
          Add a field with more details: This version allows the user to specify a precision, for fields that use both a size and precision.
protected  void addFieldError(String fieldName, String errorMessage)
          Use this in your derived checkField() class to add error messages to be associated with various fields.
 void addFoundKeys(String fieldName)
          This is used internally by JDBC Exceutor's and JDBC Query when dealing with queries to the underlying datasource.
 void addIfNeeded()
          Determine if a record with this key exists already - if not, add a new record.
protected  void addIndex(String indexName, String fieldNames, boolean isUnique)
          Add an index to the table.
protected  void addKey(String keyFieldName)
          Add a new field to the list of fields that are part of this object's key.
 void addOrUpdate()
          Determine if a record with these fields exists already - if so, update.
 void addSortKey(String fieldString, boolean ascending)
          Add a field to be sorted in a search
protected  void addTransition(Transition t)
          ?????
protected  void addVirtualField(String fieldName, String fieldType, int fieldSize, int fieldPrecision, boolean allowNull, String fieldDescription)
          Add a field with more details: This version allows the user to specify a precision, for fields that use both a size and precision.
protected  void addVirtualField(String fieldName, String fieldType, int fieldSize, int fieldPrecision, boolean allowNull, String descripKey, String fieldDescription)
          Add a field with more details: This version allows the user to specify a precision, for fields that use both a size and precision.
protected  void addVirtualField(String fieldName, String fieldType, int fieldSize, String fieldDescription)
          Add a new virtual field to the definition of this object.
protected  void addVirtualField(String fieldName, String fieldType, int fieldSize, String descripKey, String fieldDescription)
          Add a new virtual field to the definition of this object.
 double average(String fieldName)
          Find the average of the values in the specified field of records selected by the DBObject selection criteria.
 void basicAdd()
          

A "simplified"e; version of add that can be used to do a basic INSERT statement into this table.

 void cacheIsChangedComparison()
          reset 'original' value and isChanged flags on all fields, establishing a baseline for comparison.
 boolean checkAllowed(String function)
          No security is applied at the DBObject level, only at the level of SecuredDBObjects.
protected  void checkAllReferredToBy()
          Extended by subclasses to make calls to ReferredToBy as needed.
protected  void checkAllRefs()
          Extended by subclasses to make calls to checkRef as needed.
 void checkAllRefsPublic()
          Public interface to checkAllRefs()
protected  void checkDeleteDetailPerm(DBObject obj)
          extracted for subclasses checking
 void checkField(String fieldName, String fieldValue)
          Check that a given value is valid for a given field.
protected  void checkRef(String foreignKeyNames, DBObject refObject, String errorMessage)
          Convenience method for checking a reference where blank is *not* allowed in the foreign key; This test can be turned off if you add an Expresso setup (configuration) entry, 'isCheckRelationalIntegrity' set to false
protected  void checkRef(String foreignKeyNames, DBObject refObject, String errorMessage, boolean allowBlank)
          Verify referential integrity from the given list of fields to the key fields in the given DB Object.
 void clear()
          Set all fields to empty value & clear the last result set & clear sort keys and customWhereClause
 void clearDistinctFields()
          This convenience method clears all the distinct flags of DBFields belonging to this DBObject

author Peter Pilgrim

protected  void clearError(String fieldName)
          Used to clear field error flags.
 void clearFieldsToRetrieve()
          This convenience method clears all the fileds to be retrieved DBFields belonging to this DBObject

author Yves Henri Amaizo

 void clearSortKeys()
          Clear the sort keys
protected  boolean containsWildCards(String fieldValue)
          See if this field value contains wild cards (e.g. pattern matching criteria for the database).
protected  void copyAttributes(DBObject returnObj)
          called by newInstance(), this method should make sure that the newly created object is properly initialized
 int count()
          Just like find, but only retrieves the count, not the records themselves.
 void delete()
          Delete this record from the target table.
 void delete(boolean deleteDetails)
          Delete this record, optionally deleting any associated detail records.
 void deleteAll()
          Delete all of the records specified by the current search criteria.
 void deleteAll(boolean oneByOne)
          Delete all of the records specified by the current search criteria.
protected  void deleteDetails(DBConnection detailConnection)
          If this DB object has associated detail objects, locate the appropriate related detail records and delete them as well.
protected  String denotesRange(String fieldValue)
          Does a given field value denote a range?
 boolean equals(Object parm1)
          Equals implementation.
 boolean find()
          A lot like retrieve, but works with any fields, not just the key field.
 String forKey()
          Return a string we can use in error messages to indicate the record that had the problem by including the key and the current database/context
 String formatDateTime(String fieldName)
          Given the value of a date/time or date/time field, return the value formatted as appropriate for the current DBMS.
 Object get(String fieldName)
          Directly gets the DataField Data without having to deal with the DataField itself
 Map getAllAttributes()
          Returns a Read Only Map containing all the current attributes set for this particular data object instance.
 Object getAttribute(String attribName)
          Return an "attribute".
 Iterator getAttributesIterator(String fieldName)
          Get an iterator for all of the attributes specified for a field
protected  String getBooleanFieldValue(boolean fieldValue)
          Internal refactoring for getting what a boolean field should be set to.
 int getCacheSize()
          Gets the set size of the cache for this DBOBject
static HashMap getCacheStatsMap()
           
protected  CacheUtils getCacheUtil()
          'Pseudo' factory method to retrieve the caching utility class instance.
 boolean getCheckZeroUpdate()
          Gets the check zero update flags for this DBObject.
 String getCustomWhereClause()
          Allows us to query the custom where clause (if any). ' WHERE ' has been prepended to the clause.
 String getDataContext()
          Returns the name of the currently set DataContext
 DataField getDataField(String fieldName)
          Same as getField, but works with the DataObject interface for now.
 DataTransferObject getDataTransferObject()
          Gets the data transfer object usually for serialization purposes
 String getDBName()
          Deprecated. since Expresso 5.1 Use getDataContext() instead
 Enumeration getDetails()
          Get a list of all db objects that are specified as being "details" to this db object.
 int getDistinctFieldCount()
          This convenience method counts DBFields belonging to this DBObject that are set to distinct.
 String[] getDistinctFields()
          This convenience method iterates through all the fields belonging to this DBObject returns an array of field names ( String ) that are set to distinct.
 String getField(String fieldName)
          Get the string value of a field in this object as a string
 BigDecimal getFieldBigDecimal(String fieldName)
          Get the BigDecimal value of a field in this object.
 boolean getFieldBoolean(String fieldName)
          Boolean typesafe getField
 byte getFieldByte(String fieldName)
          Get the primitive byte value of a field in this object.
 byte[] getFieldByteArray(String fieldName)
          Get the primitive byteArray value of a field in this object.
protected  String getFieldData(String fieldName)
          Internal mechanism for getting the raw field data
 Date getFieldDate(String fieldName)
          Return the value of a field as a Date object
 String getFieldDecimalFormatted(String fieldName, String formatPattern)
          Return the value of a field as a Date object
 double getFieldDouble(String fieldName)
          Get the primitive double value of a field in this object. we use the locale specified in the properties file directly to determine how to parse the field
 String getFieldErrorMessage(String fieldName)
          Retrieve the error message associated with this field.
 float getFieldFloat(String fieldName)
          Get the primitive float value of a field in this object. we use the locale specified in the properties file directly to determine how to parse the field
 int getFieldInt(String fieldName)
          Get the primitive integer value of a field in this object.
 long getFieldLong(String fieldName)
          Get the prmitive long value of a field in this object.
 DataFieldMetaData getFieldMetaData(String fieldName)
          Returns the metadata for the specified field.
 short getFieldShort(String fieldName)
          Get the primitive integer value of a field in this object.
 int getFieldsToRetrieveCount()
          This convenience method counts DBFields belonging to this DBObject that are set to retrieve.
 Class getFilterClass()
          the INSTANCE value of filter class that will be used for all string filtering for THIS INSTANCE.
 long getFoundCount()
          Return the number of records found in the last search operation.
 Object[] getFoundKeysArray()
          Return the Array of keys (in the form field/field/field) that was found in the last search() call
 Object[] getIndexArray()
          Deprecated. since 5.6, Use ((DBObjectDef)getMetaData()).getIndexArray() instead
protected  Vector getISOValuesDefault(String valueField, String descripField)
          Basic version of getValidValues with supports internationalisation (i18n) that stores/retrieves the valid values in a locale dependent Caches

Valid values are store inside cache with a key name that equals myClassName+"."

protected  Vector getISOValuesDefault(String valueField, String descripField, String whereClause)
          Basic filtered version of getValidValues with supports internationalisation (i18n) that stores/retrieves the valid values in a locale dependent Caches

Valid values are store inside cache with a key name that equals myClassName+"."

protected  Vector getISOValuesDefault(String valueField, String descripField, String whereClause, String sortKeyString)
          Basic version of getValidValues with supports internationalisation (i18n) that stores/retrieves the valid values in a locale dependent Caches.
 String getKey()
          Get a string consisting of the values of each key field for this object appended together with a | between them.
 Iterator getKeyFieldListIterator()
          Get a list of all of the fields in this object This iterator is not thread safe.
 String getLength(String fieldName)
          Return the length of a field
 int getLengthInt(String fieldName)
          Get the length of this field as an integer
 DBConnection getLocalConnection()
          Returns the local connection currently associated with this DBObject...
 Locale getLocale()
          Get the current locale for this dbobject
 org.apache.log4j.Logger getLogger()
          convenience for getting logger for current (sub) class
 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 getMax(String fieldName)
          Get the Maximum value in the table of a particular field

Contributed by Madan Mohanrao Kulkarni [kulsmadya@rediffmail.com]

 String getMax(String fieldName, boolean whereClause)
          Get the Maximum value in the table of a particular field

Contributed by Madan Mohanrao Kulkarni [kulsmadya@rediffmail.com]

 int getMaxRecords()
          A DB Object can be told to only retrieve a certain number of records.
 String getMyKeys()
          Get a string consisting of the values of each key field for this object appended together with a | between them.
protected  Object[] getMyUpdatesArray()
          Return the array of updates (see the inner class) that specify what changes were just made to this object.
 int getOffsetRecord()
          Gets the number of records that be skipped.
protected  org.apache.oro.text.regex.PatternMatcher getPatternMatcher()
          Retrieve a thread local instance of the Perl5 pattern matcher.
 int getPrecision(String fieldName)
          Get the precision of thie field, if one was specified
 String getSerializedForm(DBField theField)
          This function is called whenever the DBField is about to be written to the database.
 String getStringFilter(String fieldName)
          get the current filter for a particular field.
static DBObject getThisDBbj(DataTransferObject dto)
          Constructor method that takes a DataTransferObject and builds a full fledged DBObject out of it.
protected  DBObject getThisDBObj()
          This will return a new object of the type of the subclass.
 String getValidValueDescrip(String fieldName)
          This is a convenience method which will return a ValidValue description for a multi-valued field.
 Vector getValidValues(String fieldName)
          New method to replace getValues with a structure of valid values and descriptions.
 List getValidValuesList(String fieldName)
          Retrieve a list of valid value object for this particular dbobject
 Vector getValues()
          Method to return a Vector of ValidValue Template method--not implemented in this superclass.
protected  Vector getValuesDefault(String valueField, String descripField)
          Basic version of getValidValues that stores/retrieves the valid values in a Cache.
protected  Vector getValuesDefault(String valueField, String descripField, String whereClause)
          Basic filtered version of getValidValues that stores/retrieves the valid values in a Cache.
protected  Vector getValuesDefault(String valueField, String descripField, String whereClause, String sortKeyString)
          Basic version of getValidValues that stores/retrieves the valid values in a Cache.
 boolean hasError(String fieldName)
          Use this to check if a field is in error.
 boolean hasErrors()
          Use this to check if any fields are in error.
 boolean haveAllKeys()
          See if we have a value for each of the key fields
protected  void initialize()
          Sets up metadata for the dbobject via call to setupFields().
 boolean isCached()
          Is this object using internal caching?
 boolean isChanged()
          summarize DataField.isChanged() for all fields.
 boolean isDistinct()
          This method iterates through all the DBFields belonging DBObject returns true if any of them are set a distinct.
 boolean isEmpty()
          Return true if every field in this object is empty or null.
 boolean isFieldDistinct(String fieldName)
          Convenience method to check if a field is distinct or not within this database object.
 boolean isFieldNull(String fieldName)
          Tells whether a particular field is null or not.
 boolean isFieldsToRetrieve()
          This method iterates through all the DBFields belonging DBObject returns true if any of them are between the retrieve fields.
 boolean isFieldToRetrieve(String fieldName)
          Convenience method to check if a field is field to be retrieve or not within this database object.
 boolean isMultiValued(String fieldName)
          Deprecated. since 5.6, use getJDBCMetaData().isMultiValued(String)
 boolean isReadOnly(String fieldName)
          Deprecated. since 5.6, use getJDBCMetaData().isReadOnly(String)
 boolean isSecret(String fieldName)
          Deprecated. since 5.6, use getJDBCMetaData().isSecret(String)
 boolean isVirtual(String fieldName)
          Deprecated. since 5.6, use getJDBCMetaData().isVirtual(String)
 int loadFromConnection(DBConnection connection)
          Hand a dbobject a connection that contains fields corresponding to what the dbobject expects, and it'll set itself.
protected  void logChange(DBField oneField, String fieldValue)
          Helper Function: If Change Logging is enabled, then this logs what has changed
 double max(String fieldName)
          Find the maximum of the values in the specified field of records se;lected by the DBObject selection criteria.
 double min(String fieldName)
          Find the minimum of the values in the specified field of records selected by the DBObject selection criteria.
 DBObject newInstance()
          get a new instance of this object, with some basic attributes copied, like the local connection of the transaction

Generally speaking, DO NOT OVERRIDE THIS METHOD.

protected  String noNewLine(String fieldValue)
          Strip out the newlines out of a string
protected  String noQuotes(String oldString)
          Utility method to return a string with all single quotes replaced with a pair of single quotes, and all double quotes also replaced with a pair of single quotes
protected  void notifyListeners(String eventCode)
          Used by internal caching to ensure that caches are cleared when an update is made.
 void populateDefaultValues()
          populateDefaultValues is called by the schema object to allow a table to populate itself with any desired values.
protected  void referredToBy(DBObject refObject, String foreignKeyNames, String errorMessage)
          The reverse of the checkRef method - if this object is referred to by some other object, and we are changing our own key (only allowed by deleting) then check the other table to make sure our key is not being used by it!
 void removeAttribute(String attributeName)
          Removes an attribute from this particular database object.
 void removeFromCache(DBObject theDBObj)
          Remove a specific object from that object's cache.
 void retrieve()
          Get a particular record from the database into this object's fields Key fields for this object must be set; throws otherwise
 boolean retrieveFromCache()
          Retrieve this object from cache, if possible.
 void saveBinaryField(String fieldName, byte[] incomingData)
          Deprecated. since Expresso 5.6. Use LobField directly or com.jcorporate.expresso.services.dbobj.MediaDBObject for BLOB storage since they all require much less memory as well as provides more dynamic database support.
 void search()
          Find a set of keys of all of the objects that match the current search critieria in the fields.
 void search(String sortKeyString)
          Second form of search: takes a list of sort keys & calls regular search.
 ArrayList searchAndRetrieveList()
          Find a set of records of all of the objects that match the current search critieria in the fields and retrieve the list of all records that match this criteria NOTE: Criteria in 'text' type colums is ignored (SQL Server limitation)

SIDE-EFFECT: custom 'where' clause is set to null.

 ArrayList searchAndRetrieveList(String sortKeyString)
          Search and retrieve in a particular order
 void set(String fieldName, Object o)
          sets the field value by using 'instanceof' operator; convenient for template methods, but less efficient than calling setField()
 void setAttribute(String attribName, Object attribValue)
          Set an attribute.
 void setCacheSize()
          Read the configuration table to determine the max size of the cache for this db object.
 void setCharset(String newCharSet)
          Set a characterset for a particular field.
 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.
 void setConnection(DBConnection newConnection)
          Set a specific DB connection for use with this db object.
 void setConnection(DBConnection newConnection, String setupTablesContext)
          

Set a specific DB connection for use with this db object.

 void setCustomWhereClause(String newCustomWhere)
          Specify a custom "where" clause for the SQL used to retrieve records for this object.
 void setCustomWhereClause(String newCustomWhere, boolean append)
          Allows us to specify a custom WHERE clause and have it appended to the one built from the field values in the object
 void setDataContext(String newContext)
          Sets the data context that this object is residing in.
 void setDataField(String fieldName, DataField o)
          Same as setField, but works with the DataObject Interface
 void setDataTransferObject(DataTransferObject dto)
          fill fields with values found in dto; REPLACES any data field already present.
protected  void setDefaultValue(String fieldName, String fieldValue)
          Define a "default" value for a field - to be used for the field when the user does not specify a value.
 void setDescription(String newDescription)
          Set the description of this object
 void setField(String fieldName, BigDecimal fieldValue)
          BigDecimal object Typesafe version of setField.
 void setField(String fieldName, boolean fieldValue)
          Boolean typesafe version of setField
 void setField(String fieldName, byte fieldValue)
          Byte primitive integer Typesafe version of setField.
 void setField(String fieldName, byte[] fieldValue)
          Byte primitive integer Typesafe version of setField.
 void setField(String fieldName, Date fieldValue)
          Date object Typesafe version of setField.
 void setField(String fieldName, double fieldValue)
          Double primitive Typesafe version of setField.
 void setField(String fieldName, int fieldValue)
          Integer primitive Typesafe version of setField.
 void setField(String fieldName, long fieldValue)
          Long primitive Typesafe version of setField.
 void setField(String fieldName, short fieldValue)
          Short primitive integer Typesafe version of setField.
 void setField(String fieldName, String fieldValue)
          Set the given field to a given value.
protected  void setFieldData(String fieldName, byte[] fieldValue)
          Helper function that doesn't fire all the processing... just set's the field data in raw form and forgets it.
protected  void setFieldData(String fieldName, String fieldValue)
          Helper function that doesn't fire all the processing... just set's the field data in raw form and forgets it.
 void setFieldDistinct(String fieldName, boolean flag)
          Convenience method to set a field to be distinct or not within this database object.
 void setFieldsToRetrieve(String fieldNames)
          Convenience method to set the fields to be retrieved within this database object.
 Class setFilterClass(Class filter)
          Deprecated. use setFilterClass(Filter)
 Filter setFilterClass(Filter filter)
          set the filter class that will be used for all string filtering for this object instance ONLY.
 void setKeys(String keyValues)
          Set the values for each of the key fields of this object from a /-delimited string
 void setLocale(Locale newLocale)
          Sets the locale to be used with this DBObject
 void setLookupField(String fieldName, String lookupFieldName)
          Sets the lookup field name.
 void setLookupObject(String fieldName, String objectName)
          Set 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.
protected  void setMask(String fieldName, String newMask)
          Set a "mask", or regular expresso to be matched, for the named field.
 void setMaxRecords(int newMax)
          Specify a maximum number of records to be retrieved in any subsequent searchAndRetrieve() call.
protected  void setMultiValued(String fieldName)
          Set this field to be multi-valued - e.g. there is a specific list of values that are valid for this field.
protected  void setName(String theName)
          Set the name of this object - this name is used to identify the db object with a more human-readable description
 void setOffsetRecord(int newOffset)
          Specifies the number of records that should be skipped over before any data from the ResultSet is retrieved in any subsequent searchAndRetrieve() call.
 void setReadOnly(String fieldName)
          Set a field as read-only - these fields are not offered for update when a form is produced by the generic database maintenance servlet (DBMaint).
 void setSchema(Schema schema)
          Specify which schema this DB object belongs to.
 void setSecret(String fieldName)
          Set a field as 'secret' - these fields are not shown when a list is produced by the generic database maintenance servlet.
protected  void setSortKey(String sortKeyString)
          Parses the sort key string into useful values.
 String setStringFilter(String fieldName, String filterMethod)
          Set a filter for a particular field, permanently for all instances of this class.
 void setStringFiltersOnAll(String filter)
          set string filters to the given filter on ALL fields that are quoted text fields
 void setTargetDbSchema(String theDbSchema)
          Set the target table for this DBObject.
 void setTargetTable(String theTable)
          Set the target table for this DBObject.
protected  void setupFields()
          Method to set up the fields for this database object.
protected  double sqlAggrFunction(String func, String fieldName)
          This allows the invocation of the SQL AVG, MIN, MAX and SUM aggregate functions on one of the DB's columns (the DBObject fieldname is supplied).
 double sum(String fieldName)
          Find the sum of the values in the specified field of records selected by the DBObject selection criteria.
 String toDebugString()
          Generate a debuggable string for suitable printing out in an interactive Java IDE.
 void update()
          Update the database with the new info.
 void update(boolean updateChangedFieldsOnly)
          Update the database with the new info.
 void updateAll()
          Update all of the records specified by the current search criteria.
 void updateAll(boolean oneByOne)
          Update the database with the new info.
 void verify()
          Verify that this object is working correctly by selecting all records, running a validation on each of them.
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
addInParam, addOutParam, buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, createAndRunStoreProcedure, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, runStoredProcedure, runStoredProcedureAndRetrieveList, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setDBName, setMappedDataContext, setOriginalDBName, setTargetStoreProcedure
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getGlobalMask, getStatus, isGlobalMasked, setFieldsWithDefaults, setGlobalMask, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPDATE_CHANGED_ONLY

public static final String UPDATE_CHANGED_ONLY
setup code for update() policy: for efficiency, developers who are confident that their code does not have any 'blind updates' can set the Setup value UPDATE_CHANGED_ONLY to true (a blind update is where the object is not retieved before values in it are reset)

See Also:
Constant Field Values

ATTRIBUTE_ERROR

public static final String ATTRIBUTE_ERROR
Attribute String for if there's an error with the field.

See Also:
Constant Field Values

ATTRIBUTE_ERROR_MESSAGE

public static final String ATTRIBUTE_ERROR_MESSAGE
Attribute String for what message to display if there's an error with thie field.

See Also:
Constant Field Values

ATTRIBUTE_PAGE_LIMIT

public static final String ATTRIBUTE_PAGE_LIMIT
Attribute for what is the limit to retrieve from searchAndRetrieve operations

See Also:
Constant Field Values

EVENT_ADD

public static final String EVENT_ADD
Event 'Add' code

See Also:
Constant Field Values

EVENT_DELETE

public static final String EVENT_DELETE
Event 'Delete' Code

See Also:
Constant Field Values

EVENT_UPDATE

public static final String EVENT_UPDATE
Event 'Update' Code

See Also:
Constant Field Values

BIG_DECIMAL_ZERO

protected static final transient BigDecimal BIG_DECIMAL_ZERO
A static zero BIG DECIMAL object

author Peter Pilgrim

See Also:
getFieldBigDecimal(java.lang.String)

WHERE_KEYWORD

public static final String WHERE_KEYWORD
See Also:
Constant Field Values

INT_MASK

public static final String INT_MASK
Integer Regular Expression for easy reference

See Also:
Constant Field Values

FLOAT_MASK

public static final String FLOAT_MASK
Floating point regular expression syntax for easy reference.

See Also:
Constant Field Values

EMAIL_MASK

public static final String EMAIL_MASK
Email Regular Expression Constant.

See Also:
Constant Field Values

IS_CHECK_RELATIONAL_INTEGRITY

public static final String IS_CHECK_RELATIONAL_INTEGRITY
See Also:
Constant Field Values
Constructor Detail

DBObject

public DBObject()
         throws DBException
Default Constructor. This allows a DB object to be dynamically instantiated (e.g. loaded with Class.forName()) and does all of the required initializations.

Throws:
DBException - upon error.

DBObject

public DBObject(DBConnection newConnection)
         throws DBException
Constructor that sets a connection as the object is created - typically this is used when a particular DBConnection is required for the purposes of maintaining a database transaction. If a specific connection is not used, there is no way to use commit() and rollback() in the event of failure, as a different DBConnection might be used for each phase of the transaction. Critial sections should therefore explicity request a DBConnection from the connection pool and pass it to each of the DB objects in that section.

Parameters:
newConnection - The DBConnection to utilize
Throws:
DBException - upon error.

DBObject

public DBObject(DBConnection newConnection,
                String setupTablesContext)
         throws DBException
Constructor that sets a connection as the object is created - typically this is used when a particular DBConnection is required for the purposes of maintaining a database transaction. If a specific connection is not used, there is no way to use commit() and rollback() in the event of failure, as a different DBConnection might be used for each phase of the transaction. Critial sections should therefore explicity request a DBConnection from the connection pool and pass it to each of the DB objects in that section.

This constructor is neceesary to work with otherDBMap and transaction capabilities

Parameters:
newConnection - The DBConnection to utilize
setupTablesContext - The data context that contains the setup (and security) tables for this object
Throws:
DBException - upon error.
Since:
Expresso 5.0.1

DBObject

public DBObject(RequestContext request)
         throws DBException
For using DBObjects within Controllers. Initializes based upon the current locale and the requested db context. There is no current user login id set in this method. If you need the user id then use you should use the subclass SecuredDBObject type instead.

Parameters:
request - - The controller request handed to you by the framework.
Throws:
DBException - if there's an error constructing the SecuredDBObject

DBObject

public DBObject(String newdbKey)
         throws DBException
Initialize this DBObject and set the db/context to the specified key

Parameters:
newdbKey - The database Context name
Throws:
DBException - upon error.
Method Detail

getPatternMatcher

protected org.apache.oro.text.regex.PatternMatcher getPatternMatcher()
Retrieve a thread local instance of the Perl5 pattern matcher. Allows for optimization of # of instances of pattern matcher vs synchronization.

Returns:
PatternMatcher

getLocale

public Locale getLocale()
Get the current locale for this dbobject

Specified by:
getLocale in interface DataObject
Returns:
The currently set locale or null if there is no locale set.
Since:
Expresso 5.0.1

setLocale

public void setLocale(Locale newLocale)
Sets the locale to be used with this DBObject

Specified by:
setLocale in interface DataObject
Parameters:
newLocale - The new Locale to use with this object
Since:
Expresso 5.0.1

add

public void add()
         throws DBException
Add a new record to the target table. Assumes that the fields of this object are populated with data for the new record. All key fields at least must be supplied with values, and all fields that are specified as "no nulls". This method also validates all referential integrity constraints specified by the object.

Specified by:
add in interface DataObject
Throws:
DBException - If the record cannot be added - this includes if the record has a duplicate key

loadFromConnection

public int loadFromConnection(DBConnection connection)
                       throws DBException
Hand a dbobject a connection that contains fields corresponding to what the dbobject expects, and it'll set itself.

Does not increment the result set in the DBConnection.

Parameters:
connection - The connection that currently has a dbobject ready to be read in it's result set.
Returns:
The number of fields read. Depending on the SQL you sent to the connection the DBObject might not have all fields in existence.
Throws:
DBException - upon error.

cacheIsChangedComparison

public void cacheIsChangedComparison()
                              throws DBException
reset 'original' value and isChanged flags on all fields, establishing a baseline for comparison. call when add(), retrieve, or update() has occurred, and currentValue of data fields should be considered 'original value' for purposes of determining 'isChanged'

Throws:
DBException - upon error.

addFoundKeys

public void addFoundKeys(String fieldName)
This is used internally by JDBC Exceutor's and JDBC Query when dealing with queries to the underlying datasource. Under normal conditions you would not used this function directly.

Parameters:
fieldName - the name of the fieldname found.

addDetail

protected void addDetail(String objName,
                         String keyFieldsLocal,
                         String keyFieldsForeign)
                  throws DBException
Specify a new "detail" db object, and the fields in this object they specify the fields in the related object

Parameters:
objName - The class name of the related object. There is assumed to be a one to one or one to many relationship from this object to the specified object
keyFieldsLocal - A pipe-delimited list of field names in this object
keyFieldsForeign - A pipe-delimieted list of field names in the other object
Throws:
DBException - upon error.

addField

protected void addField(String fieldName,
                        String fieldType,
                        int fieldSize,
                        int fieldPrecision,
                        boolean allowNull,
                        String fieldDescription)
                 throws DBException
Add a field with more details: This version allows the user to specify a precision, for fields that use both a size and precision.

Parameters:
fieldName - Name of the field
fieldType - Type of the field - this is the internal Expresso type, mapping in DBField to a specific database data type.
fieldSize - Size of the field
fieldPrecision - The precision of the field
allowNull - Does this field allow nulls?
fieldDescription - A longer description of this field (user-understandable hopefully!)
Throws:
DBException - upon error.

addField

protected void addField(String fieldName,
                        String fieldType,
                        int fieldSize,
                        boolean allowNull,
                        String fieldDescription)
                 throws DBException
Add a field with more details: This version of addfield supplies the allowNull flags and a description of the field to be used when reporting errors to the user. This method is only used by the class that extends DB object, and typically only in the setupFields() method.

Parameters:
fieldName - Name of the field
fieldType - Type of the field - this is the "internal" Expresso type, and is mapped to a specific type for the database depending on the mappings in the properties file (if any). The DBField object contains the default mappings.
fieldSize - Size of this field, if specified for this type of field. For fields that do not use a size (such as "date"), specify 0 for the size.
allowNull - Does this field allow nulls?
fieldDescription - A longer description of this field (user-understandable hopefully!)
Throws:
DBException - upon error.

addIfNeeded

public void addIfNeeded()
                 throws DBException
Determine if a record with this key exists already - if not, add a new record. Note that this method uses just the key fields to determine if the record already exists.

Throws:
DBException - upon error.

addFieldError

protected void addFieldError(String fieldName,
                             String errorMessage)
Use this in your derived checkField() class to add error messages to be associated with various fields.

Parameters:
fieldName - The field name to add the error to
errorMessage - The custom error message to associate when there's a problem with this field

getFieldErrorMessage

public String getFieldErrorMessage(String fieldName)
Retrieve the error message associated with this field.

Parameters:
fieldName - the fieldName to get the associated error message
Returns:
A string containing the field error message or NULL if there is no error for this field. or POSSIBLY if no error message has been set for this field.

hasError

public boolean hasError(String fieldName)
Use this to check if a field is in error.

Parameters:
fieldName - Check if there's an error set for this field.
Returns:
true if an error is set for this field.

hasErrors

public boolean hasErrors()
Use this to check if any fields are in error.

Returns:
true if an error is set.

clearError

protected void clearError(String fieldName)
Used to clear field error flags.

Parameters:
fieldName - the name of the field to clear the error flag

addIndex

protected void addIndex(String indexName,
                        String fieldNames,
                        boolean isUnique)
                 throws IllegalArgumentException,
                        DBException
Add an index to the table.

Parameters:
indexName - the name to give the index in the table; MUST CONTAIN NO SPACES--use underscores instead
fieldNames - A comma delimited list of all fields in the index.
isUnique - - True if this field is a unique index.
Throws:
IllegalArgumentException - of fieldName is null or doesn't exist or if indexName is null
DBException - upon error.

addKey

protected void addKey(String keyFieldName)
               throws DBException
Add a new field to the list of fields that are part of this object's key. Called after all of the "addField" calls in the setupFields() method to specify which fields make up the primary key of this object.

Parameters:
keyFieldName - The name of the field to add as part of the key
Throws:
DBException - if the field name is not valid or the field allows nulls

addOrUpdate

public void addOrUpdate()
                 throws DBException
Determine if a record with these fields exists already - if so, update. If not, add a new record.

Throws:
DBException - upon error.

addTransition

protected void addTransition(Transition t)
                      throws DBException
?????

Parameters:
t - unknown
Throws:
DBException - upon metadata retrieval error

addVirtualField

protected void addVirtualField(String fieldName,
                               String fieldType,
                               int fieldSize,
                               int fieldPrecision,
                               boolean allowNull,
                               String fieldDescription)
                        throws DBException
Add a field with more details: This version allows the user to specify a precision, for fields that use both a size and precision.

Parameters:
fieldName - Name of the field
fieldType - Type of the field - this is the internal Expresso type, mapping in DBField to a specific database data type.
fieldSize - Size of the field
fieldPrecision - The precision of the field
allowNull - Does this field allow nulls?
fieldDescription - A longer description of this field (user-understandable hopefully!)
Throws:
DBException - upon error.

addVirtualField

protected void addVirtualField(String fieldName,
                               String fieldType,
                               int fieldSize,
                               int fieldPrecision,
                               boolean allowNull,
                               String descripKey,
                               String fieldDescription)
                        throws DBException
Add a field with more details: This version allows the user to specify a precision, for fields that use both a size and precision.

Parameters:
fieldName - Name of the field
fieldType - Type of the field - this is the internal Expresso type, mapping in DBField to a specific database data type.
fieldSize - Size of the field
fieldPrecision - The precision of the field
allowNull - Does this field allow nulls?
descripKey - The key in the local language file for the description of this field
fieldDescription - A longer description of this field (user-understandable hopefully!)
Throws:
DBException - upon error.

addVirtualField

protected void addVirtualField(String fieldName,
                               String fieldType,
                               int fieldSize,
                               String fieldDescription)
                        throws DBException
Add a new virtual field to the definition of this object. A virtual field is just like a regular one, except it's not stored in the target table A normal call to getField or setField on a virtual field will throw an exception - getField and setField should be extended to handle the virtual fields for a particular object correctly.

Parameters:
fieldName - Name of the field
fieldType - Database type of the field
fieldSize - Size of the field in characters
fieldDescription - A longer description of this field (user-understandable hopefully!)
Throws:
DBException - upon error.

setSortKey

protected void setSortKey(String sortKeyString)
Parses the sort key string into useful values. This version forces full parsing of the input values to prevent SQL injection attacks.

Parameters:
sortKeyString - the pipe delimited string of field names with the optional 'ASC or DESC' keyword afterwords; null indicates no sorting

addSortKey

public void addSortKey(String fieldString,
                       boolean ascending)
Add a field to be sorted in a search

Parameters:
fieldString - the name of the field to sort on
ascending - true if using ascending sort order, false if descending sort order.
Throws:
IllegalArgumentException - if the fieldString does not exist

clearSortKeys

public void clearSortKeys()
Clear the sort keys

See Also:
addSortKey(java.lang.String, boolean)

addVirtualField

protected void addVirtualField(String fieldName,
                               String fieldType,
                               int fieldSize,
                               String descripKey,
                               String fieldDescription)
                        throws DBException
Add a new virtual field to the definition of this object. A virtual field is just like a regular one, except it's not stored in the target table A normal call to getField or setField on a virtual field will throw an exception - getField and setField should be extended to handle the virtual fields for a particular object correctly.

Parameters:
fieldName - Name of the field
fieldType - Database type of the field
fieldSize - Size of the field in characters
descripKey - Key into the local langauge file for the description of this field
fieldDescription - A longer description of this field (user-understandable hopefully!)
Throws:
DBException - upon error.

average

public double average(String fieldName)
               throws DBException
Find the average of the values in the specified field of records selected by the DBObject selection criteria.

Parameters:
fieldName - String DBObject fieldName to average
Returns:
double Average of the records matching the criteria
Throws:
DBException - If the search could not be completed

basicAdd

public void basicAdd()
              throws DBException

A "simplified"e; version of add that can be used to do a basic INSERT statement into this table. Often used with data import facilities, when referential integrity and other validations must be temporarily bypassed.

NOTE BLOB Objects are not added with this function!

NOTE this function does NOT handle auto-increment fields!

Throws:
DBException - If the record cannot be added - this includes if the record has a duplicate key

Modify by Yves Henri AMAIZO


checkAllowed

public boolean checkAllowed(String function)
                     throws DBException
No security is applied at the DBObject level, only at the level of SecuredDBObjects. The method is still here, however, so that it can be called by the cascading delete and any other methods as required

Parameters:
function - The appropriate function code. This is mainly used in objects derived from SecuredDBObject
Returns:
true if this function is alloed
Throws:
DBException - upon error.

checkAllReferredToBy

protected void checkAllReferredToBy()
                             throws DBException
Extended by subclasses to make calls to ReferredToBy as needed. This method implements the basic referential integrity of an object by specifying all of the object that refer to this object as a foreign key. This method is called when a delete is about to occurr to verify that removing the current object would not create invalid references in the "referring" objects - if it would, an exception is thrown, preventing the delete.

Throws:
DBException - If the referential integrity is not correct

checkAllRefs

protected void checkAllRefs()
                     throws DBException
Extended by subclasses to make calls to checkRef as needed. Thie method implements (along with checkAllReferredToBy()) basic referential integrity for this object. Whenever an update or add is about to be made, this method is called to see if the changed record is referring to invalid foreign keys - e.g. lookup tables that do not have an appropriate related record. If so, an Exception is thrown. See the checkRef method for the calls that should be made in this method.

Throws:
DBException - If the update/add operation would result in an invalid foreign key reference.

checkAllRefsPublic

public void checkAllRefsPublic()
                        throws DBException
Public interface to checkAllRefs()

Throws:
DBException - upon error.

checkField

public void checkField(String fieldName,
                       String fieldValue)
                throws DBException
Check that a given value is valid for a given field. This method is overriden by specific DBObjects to do their own field-level validations - they should also call super in order to do the standard stuff. Every field is automatically checked by this method before the database is updated.

Specified by:
checkField in interface DataObject
Parameters:
fieldName - Name of the field to verify
fieldValue - Value of the field to be evaluated
Throws:
DBException - If the value is not valid

checkRef

protected void checkRef(String foreignKeyNames,
                        DBObject refObject,
                        String errorMessage)
                 throws DBException
Convenience method for checking a reference where blank is *not* allowed in the foreign key; This test can be turned off if you add an Expresso setup (configuration) entry, 'isCheckRelationalIntegrity' set to false

Parameters:
foreignKeyNames - names of the foreign key fields
refObject - The foreign DBObject to check against
errorMessage - The custom error message to display if check fails
Throws:
DBException - if check fails

checkRef

protected void checkRef(String foreignKeyNames,
                        DBObject refObject,
                        String errorMessage,
                        boolean allowBlank)
                 throws DBException
Verify referential integrity from the given list of fields to the key fields in the given DB Object. Calls to this method are made in the checkAllRefs method only. checkAllRefs is automatically called before any database updates are made to validate the referential integrity of the update. Use of this method (and the checkAllRefs method) allow the referential constraints to be "declared", then automatically maintained for a dbobject.

Parameters:
foreignKeyNames - A semicolon-sperated list of foreign key fields from this object
refObject - Another DBObject that we are to refer to
errorMessage - Error string to throw if the check fails
allowBlank - true if blank fields are allowed
Throws:
DBException - If the referential integrity is not correct

clear

public void clear()
           throws DBException
Set all fields to empty value & clear the last result set & clear sort keys and customWhereClause

Specified by:
clear in interface DataObject
Throws:
DBException - If the fields cannot be cleared

clearDistinctFields

public void clearDistinctFields()
                         throws DBException
This convenience method clears all the distinct flags of DBFields belonging to this DBObject

author Peter Pilgrim

Throws:
DBException - upon error.
See Also:
getDistinctFieldCount(), isDistinct()

clearFieldsToRetrieve

public void clearFieldsToRetrieve()
                           throws DBException
This convenience method clears all the fileds to be retrieved DBFields belonging to this DBObject

author Yves Henri Amaizo

Throws:
DBException - upon error.
See Also:
isFieldsToRetrieve()

containsWildCards

protected boolean containsWildCards(String fieldValue)
                             throws DBException
See if this field value contains wild cards (e.g. pattern matching criteria for the database). The wild cards can be configured via the properties file.

Parameters:
fieldValue - The field value to check for wild cards
Returns:
True if the string does contain wild cards, False if it does not
Throws:
DBException - upon error.

count

public int count()
          throws DBException
Just like find, but only retrieves the count, not the records themselves.

Specified by:
count in interface DataObject
Returns:
integer Count of the records matching the criteria
Throws:
DBException - If the search could not be completed

delete

public void delete()
            throws DBException
Delete this record from the target table. The current field values for the key of this object tell us which record to delete. This default version of delete also deletes associated detail records (e.g. performs a "cascading delete" of details.

Specified by:
delete in interface DataObject
Throws:
DBException - If the delete fails or if the referential integrity would be violated by the delete
See Also:
to delete objects identified by non-key fields

delete

public void delete(boolean deleteDetails)
            throws DBException
Delete this record, optionally deleting any associated detail records.

Parameters:
deleteDetails - Delete associated detail records if true
Throws:
DBException - Modify by Yves Henri AMAIZO
See Also:
to delete objects identified by non-key fields

deleteAll

public void deleteAll()
               throws DBException
Delete all of the records specified by the current search criteria. If you use a blank DBObject, then all the records in the table will be deleted

Throws:
DBException - upon error

deleteAll

public void deleteAll(boolean oneByOne)
               throws DBException
Delete all of the records specified by the current search criteria. If you use a blank DBObject, then all the records in the table will be deleted

Parameters:
oneByOne - set 'true' usually, to make sure that all 'detail' records are also deleted. Set to false if you are sure that the table has no detail records (i.e., it supplies no foreign keys--has no dependent records)
Throws:
DBException - upon error

deleteDetails

protected void deleteDetails(DBConnection detailConnection)
                      throws DBException
If this DB object has associated detail objects, locate the appropriate related detail records and delete them as well. This is a "cascading delete" process.

Parameters:
detailConnection - the DBConnection to use while retrieving details
Throws:
DBException - upon error.

checkDeleteDetailPerm

protected void checkDeleteDetailPerm(DBObject obj)
                              throws DBException
extracted for subclasses checking

Parameters:
obj - the dbobject to check it's permission
Throws:
DBException - upon error

denotesRange

protected String denotesRange(String fieldValue)
Does a given field value denote a range?

Parameters:
fieldValue - The field value to check against.
Returns:
The "range" string if the value starts with a range indicator, null if not

find

public boolean find()
             throws DBException
A lot like retrieve, but works with any fields, not just the key field. Does not throw an exception if the record is not found, just returns false. Finds only first record matching the criteria. The current fields in this object are populated with the data in the record found after the call to find() if the find is successful.

Specified by:
find in interface DataObject
Returns:
boolean If the search resulted in a record
Throws:
DBException - If the search could not be completed Modify by Yves Henri AMAIZO

forKey

public String forKey()
Return a string we can use in error messages to indicate the record that had the problem by including the key and the current database/context

Returns:
String: A formatted string showing the key of this record

formatDateTime

public String formatDateTime(String fieldName)
                      throws DBException
Given the value of a date/time or date/time field, return the value formatted as appropriate for the current DBMS. Can be configured using property file values.

Parameters:
fieldName - java.lang.String The value for the date/time field.
Returns:
java.lang.String The formatted date time, ready for use in the DBMS
Throws:
DBException - upon error.

getAttribute

public Object getAttribute(String attribName)
Return an "attribute". Attributes are temporary (e.g. not stored in the DBMS) values associated with this particular DB object instance.

Specified by:
getAttribute in interface DataObject
Parameters:
attribName - The attribute name to check
Returns:
the object associated with this attribute

getAttributesIterator

public Iterator getAttributesIterator(String fieldName)
                               throws DBException
Get an iterator for all of the attributes specified for a field

Parameters:
fieldName - The field name to get the attirbutes for
Returns:
the Iterator for all attributes associated with this field
Throws:
DBException - upon error.

getCacheSize

public int getCacheSize()
Gets the set size of the cache for this DBOBject

Returns:
The number of cache objects available for this object.

getCacheStatsMap

public static HashMap getCacheStatsMap()
Returns:
a HashMap of all cache stats

getFieldMetaData

public DataFieldMetaData getFieldMetaData(String fieldName)
Returns the metadata for the specified field.

Specified by:
getFieldMetaData in interface DataObject
Parameters:
fieldName - The name of the field to get
Returns:
The DBField for this fieldName

getDBName

public String getDBName()
Deprecated. since Expresso 5.1 Use getDataContext() instead

Return the name of the context/database connection that this DB object is using. If none is set, then we are using the "default" database/context.

Returns:
a String containing the name of the DBName to use.

getDetails

public Enumeration getDetails()
                       throws DBException
Get a list of all db objects that are specified as being "details" to this db object. Returns an empty enumeration if there are no details

Returns:
java.util.Enumeration containing all detail objects
Throws:
DBException - upon error.

getDistinctFieldCount

public int getDistinctFieldCount()
                          throws DBException
This convenience method counts DBFields belonging to this DBObject that are set to distinct.

Returns:
int number of distinct fields.

author Peter Pilgrim

Throws:
DBException - upon error.

getDistinctFields

public String[] getDistinctFields()
                           throws DBException

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

If there are are no distinct fields then the method returns a null reference.

Returns:
String array of distinct field names in this object.

author Peter Pilgrim

Throws:
DBException - upon error.
See Also:
getDistinctFieldCount(), isDistinct()

getField

public String getField(String fieldName)
                throws DBException
Get the string value of a field in this object as a string

Specified by:
getField in interface DataObject
Parameters:
fieldName - Name of the field to fetch
Returns:
The value of the given field as a string - if the field is null, an empty string is returned.
Throws:
DBException - If there is no such field or it's value cannot be accessed

getFieldData

protected String getFieldData(String fieldName)
Internal mechanism for getting the raw field data

Parameters:
fieldName - the name of the field to retrieve the data for
Returns:
java.lang.String or null if the fieldData doesn't exist in the map

getFieldBoolean

public boolean getFieldBoolean(String fieldName)
                        throws DBException
Boolean typesafe getField

Parameters:
fieldName - to retrieve
Returns:
boolean true false
Throws:
DBException - upon error.

getFieldDate

public Date getFieldDate(String fieldName)
                  throws DBException
Return the value of a field as a Date object

Parameters:
fieldName - The field to be retrieved
Returns:
The Date object equivilant to this field's value
Throws:
DBException - If the field does not exist or it's value is not a date or cannot be converted to a date

getFieldDecimalFormatted

public String getFieldDecimalFormatted(String fieldName,
                                       String formatPattern)
                                throws DBException
Return the value of a field as a Date object

Parameters:
fieldName - The field to be retrieved
formatPattern - A formatting pattern according to java.text.DecimalFormat. Leave null for the default format for this locale.
                                                                Symbol Meaning
                                                                0      a digit
                                                                #      a digit, zero shows as absent
                                                                .      placeholder for decimal separator
                                                                ,      placeholder for grouping separator.
                                                                 E      separates mantissa and exponent for exponential formats.
                                                                ;      separates formats.
                                                                -      default negative prefix.
                                                                %      multiply by 100 and show as percentage
                                                                ?      multiply by 1000 and show as per mille
                                                                �      currency sign; replaced by currency symbol; if
                                                                       doubled, replaced by international currency symbol.
                                                                       If present in a pattern, the monetary decimal separator
                                                                       is used instead of the decimal separator.
                                                                X      any other characters can be used in the prefix or suffix
                                                                '      used to quote special characters in a prefix or suffix.
                                                                
Returns:
The Date object equivilant to this field's value
Throws:
DBException - If the field does not exist or it's value is not a date or cannot be converted to a date
See Also:
DecimalFormat

getFieldFloat

public float getFieldFloat(String fieldName)
                    throws DBException
Get the primitive float value of a field in this object. we use the locale specified in the properties file directly to determine how to parse the field

Parameters:
fieldName - Name of the field to be retrieved
Returns:
float The value of the field as a float
Throws:
DBException - If there is no such field or it's value cannot be converted to a float
See Also:
setField(String,double)

getFieldDouble

public double getFieldDouble(String fieldName)
                      throws DBException
Get the primitive double value of a field in this object. we use the locale specified in the properties file directly to determine how to parse the field

Parameters:
fieldName - Name of the field to be retrieved
Returns:
float The value of the field as a float
Throws:
DBException - If there is no such field or it's value cannot be converted to a float
See Also:
setField(String,double)

getFieldBigDecimal

public BigDecimal getFieldBigDecimal(String fieldName)
                              throws DBException
Get the BigDecimal value of a field in this object. We use the locale specified in the properties file directly to determine how to parse the field

NB: Corresponds to java.sql.Type.DECIMAL or java.sql.Type.NUMERIC

Parameters:
fieldName - Name of the field to be retrieved
Returns:
BigDecimal The value of the field as a BigDecimal object
Throws:
DBException - If there is no such field or it's value cannot be converted to a BigDecimal

author Peter Pilgrim

See Also:
"'JDBC API Tutorial and Reference', Second Edition, pg 944, by Catell, Hamilton et al; published by Addison Wesley", setField(String,BigDecimal)

getFieldByte

public byte getFieldByte(String fieldName)
                  throws DBException
Get the primitive byte value of a field in this object. A convenience method for getField

Parameters:
fieldName - Name of a field in this object
Returns:
int The value of the field as a int
Throws:
DBException - if there is no such field or it's value cannot be converted to a byte integer.
See Also:
setField(String,byte)

getFieldByteArray

public byte[] getFieldByteArray(String fieldName)
                         throws DBException
Get the primitive byteArray value of a field in this object. A convenience method for getField

Parameters:
fieldName - Name of a field in this object
Returns:
int The value of the field as a byte{]
Throws:
DBException - if there is no such field or it's value cannot be get to a byte array.
See Also:
setField(String,byte[])

getFieldShort

public short getFieldShort(String fieldName)
                    throws DBException
Get the primitive integer value of a field in this object. A convenience method for getField

Parameters:
fieldName - Name of a field in this object
Returns:
int The value of the field as a int
Throws:
DBException - if there is no such field or it's value cannot be converted to a short integer.
See Also:
setField(String,short)

getFieldInt

public int getFieldInt(String fieldName)
                throws DBException
Get the primitive integer value of a field in this object. A convenience method for getField

Parameters:
fieldName - Name of a field in this object
Returns:
int The value of the field as a int; will return 0 if field is null; throw if underlying string is otherwise non-integer;
Throws:
DBException - if there is no such field or it's value cannot be converted to an integer.
See Also:
setField(String,int), in order to know if 0 is 'real' or because of an underlying null

getFieldLong

public long getFieldLong(String fieldName)
                  throws DBException
Get the prmitive long value of a field in this object. A convenience method for getField

Parameters:
fieldName - Name of a field in this object
Returns:
long The value of the field as a long
Throws:
DBException - if there is no such field or it's value cannot be converted to a long integer.
See Also:
setField(String,long)

saveBinaryField

public void saveBinaryField(String fieldName,
                            byte[] incomingData)
                     throws DBException
Deprecated. since Expresso 5.6. Use LobField directly or com.jcorporate.expresso.services.dbobj.MediaDBObject for BLOB storage since they all require much less memory as well as provides more dynamic database support.

Sets a byte array to the underlying data as a blob

Parameters:
fieldName - The name of the field to save.
incomingData - the stream to write to the database table.
Throws:
DBException - upon error

getFieldsToRetrieveCount

public int getFieldsToRetrieveCount()
                             throws DBException
This convenience method counts DBFields belonging to this DBObject that are set to retrieve.

Returns:
int number of retrieve fields.
Throws:
DBException - upon error.

getFoundCount

public long getFoundCount()
Return the number of records found in the last search operation. See also count() and find().

Returns:
The count of records found

getFoundKeysArray

public Object[] getFoundKeysArray()
Return the Array of keys (in the form field/field/field) that was found in the last search() call

Returns:
An array containing keys as strings

getIndexArray

public Object[] getIndexArray()
                       throws DBException
Deprecated. since 5.6, Use ((DBObjectDef)getMetaData()).getIndexArray() instead

Get an array of DBIndex objects for purpose of creating them through the schema. Return type should actually be DBIndex. Please Note This may cause an exception to be thrown if indexList is null. Call hasIndex() first before calling getIndexArray To be soon deprecated

Returns:
an object containing all the DBOBjects
Throws:
DBException - upon error.

getKey

public String getKey()
Get a string consisting of the values of each key field for this object appended together with a | between them.

Specified by:
getKey in interface Cacheable
Returns:
Value of all keys appended with a | between

getKeyFieldListIterator

public Iterator getKeyFieldListIterator()
                                 throws DBException
Get a list of all of the fields in this object This iterator is not thread safe.

Returns:
An iterator of the fieldNamesInOrder array list
Throws:
DBException - If the list cannot be retrieved

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
Get the length of this field as an integer

Parameters:
fieldName - to check
Returns:
length of field
Throws:
DBException - upon error.

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 - The fieldname to look up
Returns:
A String containing the classname of the lookup dbobject
Throws:
DBException - If the specified field does not exist.

getLocalConnection

public DBConnection getLocalConnection()
Returns the local connection currently associated with this DBObject... may be null if no local connection has ever been set.

Overrides:
getLocalConnection in class JDBCDataObject
Returns:
com.jcorporate.expresso.core.db.DBConnection or null

getMax

public String getMax(String fieldName,
                     boolean whereClause)
              throws DBException
Get the Maximum value in the table of a particular field

Contributed by Madan Mohanrao Kulkarni [kulsmadya@rediffmail.com]

Parameters:
fieldName - the Fieldname to get the max value for.
whereClause - Use a custom whereclause?
Returns:
a String containing the maximum value for this field name Modify by Yves Henri AMAIZO
Throws:
DBException - upon error.

getMax

public String getMax(String fieldName)
              throws DBException
Get the Maximum value in the table of a particular field

Contributed by Madan Mohanrao Kulkarni [kulsmadya@rediffmail.com]

Parameters:
fieldName - The fieldName to check against
Returns:
The maximum value for this field in the table.
Throws:
DBException - upon error.

getMaxRecords

public int getMaxRecords()
A DB Object can be told to only retrieve a certain number of records. If a "max records" value has been specified, this method provides access to it.

Specified by:
getMaxRecords in interface DataObject
Returns:
The maximum number of records that should be retrieved, or zero if no max has been set

getMyKeys

public String getMyKeys()
                 throws DBException
Get a string consisting of the values of each key field for this object appended together with a | between them.

Returns:
Value of all keys appended with a | between
Throws:
DBException - If the key list cannot be built.

getMyUpdatesArray

protected Object[] getMyUpdatesArray()
Return the array of updates (see the inner class) that specify what changes were just made to this object.

Returns:
Logged Updates in an Object Array

getOffsetRecord

public int getOffsetRecord()
Gets the number of records that be skipped. The offset records. A DB Object can be told to skip a certain number of records, before reading records from the ResultSet.

author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001

Specified by:
getOffsetRecord in interface DataObject
Returns:
The maximum number of records that should be skipped over before reading the data records.
See Also:
setOffsetRecord(int)

getPrecision

public int getPrecision(String fieldName)
                 throws DBException
Get the precision of thie field, if one was specified

Parameters:
fieldName - The fieldname to get the precision for
Returns:
length of precision as integer
Throws:
DBException - upon error.

getSerializedForm

public String getSerializedForm(DBField theField)
                         throws DBException
This function is called whenever the DBField is about to be written to the database. It may do additional processing such as encryption depending on the field attributes.

Parameters:
theField - A DBField object
Returns:
the value to write to the data source.
Throws:
DBException - upon error.

getThisDBObj

protected DBObject getThisDBObj()
                         throws DBException
This will return a new object of the type of the subclass.

OVERRIDE this method with implentation like

return new MyObject()

if you want greatest efficiency. For example: A DBObject called "Customer" should return a new "Customer" object.

the implementation in DBObject uses getClass().newInstance(), which seems to be about 50% slower than "new MyObject()" calls on JDK 1.4

Note that this method should never be called directly. It should only be called by newInstance()

Returns:
DBObject A newly allocated object of the subclass's class
Throws:
DBException - upon error.
See Also:
getThisDBObj()

newInstance

public DBObject newInstance()
                     throws DBException
get a new instance of this object, with some basic attributes copied, like the local connection of the transaction

Generally speaking, DO NOT OVERRIDE THIS METHOD. Instead, to improve efficiency, most subclasses will override the method getThisDBObj()

Returns:
DBObject A newly allocated object of the subclass's class
Throws:
DBException - upon error.
See Also:
getThisDBObj()

copyAttributes

protected void copyAttributes(DBObject returnObj)
                       throws DBException
called by newInstance(), this method should make sure that the newly created object is properly initialized

Parameters:
returnObj - the object to set the attributes to.
Throws:
DBException - upon error

getThisDBbj

public static DBObject getThisDBbj(DataTransferObject dto)
                            throws DBException
Constructor method that takes a DataTransferObject and builds a full fledged DBObject out of it.

Parameters:
dto - The DataTransferObject
Returns:
a constructed DBObject that still needs DataContext and record ownership to be set.
Throws:
DBException - upon error

getDataTransferObject

public DataTransferObject getDataTransferObject()
                                         throws DBException
Gets the data transfer object usually for serialization purposes

Returns:
The built DataTransferObject
Throws:
DBException - upon error.

setDataTransferObject

public void setDataTransferObject(DataTransferObject dto)
                           throws DBException
fill fields with values found in dto; REPLACES any data field already present.

Parameters:
dto - The filled out data transfer object
Throws:
DBException - upon error.

getValidValueDescrip

public String getValidValueDescrip(String fieldName)
                            throws DBException
This is a convenience method which will return a ValidValue description for a multi-valued field. (Contributed by Adam Rossi)

Parameters:
fieldName - java.lang.String
Returns:
java.lang.String The description of this multi-valued field
Throws:
DBException - If there is no such field, or the values cannot be retrieved.

getValidValuesList

public List getValidValuesList(String fieldName)
                        throws DBException
Retrieve a list of valid value object for this particular dbobject

Specified by:
getValidValuesList in interface DataObject
Parameters:
fieldName - the name of the field to get the valid values list for
Returns:
java.util.List of ValidValue objects
Throws:
DBException - upon error

getValidValues

public Vector getValidValues(String fieldName)
                      throws DBException
New method to replace getValues with a structure of valid values and descriptions. Database objects should extend this method to return Vectors of ValidValue objects for multi-valued fields. A specific object can return it's own list of ValidValues, or it can call this super method to use the lookup object to get the list of valid values instead.

Parameters:
fieldName - The name of the fields for which a value set is requested
Returns:
A Vector of ValidValue objects
Throws:
DBException - upon error.

getValues

public Vector getValues()
                 throws DBException
Method to return a Vector of ValidValue Template method--not implemented in this superclass. This method may be implemented by objects that want to provide a list of valid values for other DB objects. It is strongly recommended that the valid value list be cached (via the CacheManager) for performance. The naming convention used in Expresso is to store the ValidValue list with a cache name the same as the db objects class name with ".validValues" appended TODO: This should be converted to array List versions

Specified by:
getValues in interface LookupInterface
Returns:
java.util.Vector of valid values
Throws:
DBException - upon error.
See Also:
getValidValues(java.lang.String)

getValuesDefault

protected Vector getValuesDefault(String valueField,
                                  String descripField)
                           throws DBException
Basic version of getValidValues that stores/retrieves the valid values in a Cache. This method does not support internationalisation (i18n).

Valid values are store inside cache with a key name that equals myClassName+".validValues" The method creates ValidValue object instances and stores them in the cache.

Parameters:
valueField - java.lang.String
descripField - java.lang.String
Returns:
java.util.Vector
Throws:
DBException - if a database error occurs

#see #getValuesDefault(String valueField, String descripField, String whereClause) #see #getISOValuesDefault(String valueField, String descripField)


getValuesDefault

protected Vector getValuesDefault(String valueField,
                                  String descripField,
                                  String whereClause)
                           throws DBException
Basic filtered version of getValidValues that stores/retrieves the valid values in a Cache. This method does not support internationalisation (i18n).

Valid values are store inside cache with a key name that equals myClassName+".validValues" The method creates ValidValue object instances and stores them in the cache.

Parameters:
valueField - java.lang.String
descripField - java.lang.String
whereClause - the where clause that will be pass to setCustomWhereClause.
Returns:
java.util.Vector
Throws:
DBException - if a database error occurs

#see #setCustomWhereClause(String newCustomWhere) #see #getISOValuesDefault(String valueField, String descripField)


getValuesDefault

protected Vector getValuesDefault(String valueField,
                                  String descripField,
                                  String whereClause,
                                  String sortKeyString)
                           throws DBException
Basic version of getValidValues that stores/retrieves the valid values in a Cache. This method retrieves the valid values in the order specified by the sortKeyString, and filters them with the given where clause. Note, it does not support internationalisation (i18n).

Valid values are store inside cache with a key name that equals myClassName+".validValues" The method creates ValidValue object instances and stores them in the cache.

Parameters:
valueField - java.lang.String
descripField - java.lang.String
whereClause - the where clause that will be pass to setCustomWhereClause.
sortKeyString - the pipe delimited string of field names with the optional 'ASC or DESC' keyword afterwords; pass in null to indicate no sorting
Returns:
java.util.Vector
Throws:
DBException - if a database error occurs

#see #setCustomWhereClause(String newCustomWhere) #see #setSortKey(String sortKeyString) #see #getISOValuesDefault(String valueField, String descripField)


getISOValuesDefault

protected Vector getISOValuesDefault(String valueField,
                                     String descripField)
                              throws DBException
Basic version of getValidValues with supports internationalisation (i18n) that stores/retrieves the valid values in a locale dependent Caches

Valid values are store inside cache with a key name that equals myClassName+"."+oneLocale.getString()+".validValues". For example the key cache could be:

 "com.acme.test.Fruits.en_gb.validValues"
 "com.acme.test.Fruits.de_de.validValues"
 "com.acme.test.Fruits.es_es.validValues"
 

The method creates ISOValidValue object instances and stores them in the cache.

Parameters:
valueField - java.lang.String
descripField - java.lang.String
Returns:
java.util.Vector
Throws:
DBException - if a database error occurs

#see #getValuesDefault(String valueField, String descripField)


getISOValuesDefault

protected Vector getISOValuesDefault(String valueField,
                                     String descripField,
                                     String whereClause)
                              throws DBException
Basic filtered version of getValidValues with supports internationalisation (i18n) that stores/retrieves the valid values in a locale dependent Caches

Valid values are store inside cache with a key name that equals myClassName+"."+oneLocale.getString()+".validValues". For example the key cache could be:

 "com.acme.test.Fruits.en_gb.validValues"
 "com.acme.test.Fruits.de_de.validValues"
 "com.acme.test.Fruits.es_es.validValues"
 

The method creates ISOValidValue object instances and stores them in the cache.

Parameters:
valueField - java.lang.String
descripField - java.lang.String
whereClause - the where clause that will be pass to setCustomWhereClause.
Returns:
java.util.Vector
Throws:
DBException - if a database error occurs

#see #getValuesDefault(String valueField, String descripField, String whereClause)


getISOValuesDefault

protected Vector getISOValuesDefault(String valueField,
                                     String descripField,
                                     String whereClause,
                                     String sortKeyString)
                              throws DBException
Basic version of getValidValues with supports internationalisation (i18n) that stores/retrieves the valid values in a locale dependent Caches. This method retrieves the valid values in the order specified by the sortKeyString, and filters them with the given where clause.

Valid values are store inside cache with a key name that equals myClassName+"."+oneLocale.getString()+".validValues". For example the key cache could be:

 "com.acme.test.Fruits.en_gb.validValues"
 "com.acme.test.Fruits.de_de.validValues"
 "com.acme.test.Fruits.es_es.validValues"
 

The method creates ISOValidValue object instances and stores them in the cache.

Parameters:
valueField - java.lang.String
descripField - java.lang.String
whereClause - the where clause that will be pass to setCustomWhereClause.
sortKeyString - the pipe delimited string of field names with the optional 'ASC or DESC' keyword afterwords
Returns:
java.util.Vector
Throws:
DBException - if a database error occurs

#see #getValuesDefault(String valueField, String descripField, String whereClause, String sortKeyString)


haveAllKeys

public boolean haveAllKeys()
                    throws DBException
See if we have a value for each of the key fields

Returns:
True if all key fields have a value, false if not
Throws:
DBException - upon error.

initialize

protected void initialize()
                   throws DBException
Sets up metadata for the dbobject via call to setupFields(). it is important within this method to provide STATIC synchronization to enable static (meta)data members to be setup by the first instantiation of a given class. Two threads can simultaneously create the first instance of different classes, and so a simple object-level synchronization alone will not suffice here, though it is useful to block out calls from the same class.

author Adam Rossi, PlatinumSolutions author Larry Hamel, CodeGuild.com

Throws:
DBException - The exception description.

isCached

public boolean isCached()
Is this object using internal caching? If the cache value is set to other than zero, it is using caching

Returns:
True if internal caching is enabled, else false

isDistinct

public boolean isDistinct()
                   throws DBException
This method iterates through all the DBFields belonging DBObject returns true if any of them are set a distinct.

author Peter Pilgrim

Returns:
true if this is a distinct field
Throws:
DBException - upon error.
See Also:
isFieldDistinct(String), getDistinctFields(), getDistinctFieldCount()

isFieldNull

public boolean isFieldNull(String fieldName)
                    throws DBException
Tells whether a particular field is null or not. Note: To maintain backwards compatibility, if you have a virtual field then isFieldNull will always return false. You should override this method for virtual fields if you want isNull support.

Parameters:
fieldName - The name of the field to check for isFieldNull()
Returns:
true if the field is null
Throws:
DBException - if the field doesn't exist for the particular DBObject.

isEmpty

public boolean isEmpty()
                throws DBException
Return true if every field in this object is empty or null. Tests only "real" fields, not virtual ones

Returns:
boolean: True if the record is "empty" (all fields blank), False if not.
Throws:
DBException - If the list of fields cannot be traversed

isFieldDistinct

public boolean isFieldDistinct(String fieldName)
                        throws DBException
Convenience method to check if a field is distinct or not within this database object.

Parameters:
fieldName - the name of the field
Returns:
boolean value true if the field is set distinct.
Throws:
DBException - If the operation could not be completed

author Peter Pilgrim

See Also:
getDistinctFields(), getDistinctFieldCount(), setFieldDistinct(java.lang.String, boolean)

isFieldsToRetrieve

public boolean isFieldsToRetrieve()
                           throws DBException
This method iterates through all the DBFields belonging DBObject returns true if any of them are between the retrieve fields.

author Yves Henri Amaizo

Returns:
true if there are specific fields to retrieve
Throws:
DBException - upon error.
See Also:
isFieldToRetrieve(String)

isFieldToRetrieve

public boolean isFieldToRetrieve(String fieldName)
                          throws DBException
Convenience method to check if a field is field to be retrieve or not within this database object.

Parameters:
fieldName - the name of the field
Returns:
boolean value true if the field is set distinct.
Throws:
DBException - If the operation could not be completed

author Yves Henri Amaizo

See Also:
setFieldsToRetrieve( String )

isMultiValued

public boolean isMultiValued(String fieldName)
                      throws DBException
Deprecated. since 5.6, use getJDBCMetaData().isMultiValued(String)

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
Deprecated. since 5.6, use getJDBCMetaData().isReadOnly(String)

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 - The field name 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
Deprecated. since 5.6, use getJDBCMetaData().isSecret(String)

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.
See Also:
setSecret(String)

isVirtual

public boolean isVirtual(String fieldName)
                  throws DBException
Deprecated. since 5.6, use getJDBCMetaData().isVirtual(String)

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
See Also:
addVirtualField(String, String, int, String)

max

public double max(String fieldName)
           throws DBException
Find the maximum of the values in the specified field of records se;lected by the DBObject selection criteria.

Parameters:
fieldName - String DBObject fieldName to average
Returns:
double Maximum of the records matching the criteria
Throws:
DBException - If the search could not be completed

min

public double min(String fieldName)
           throws DBException
Find the minimum of the values in the specified field of records selected by the DBObject selection criteria.

Parameters:
fieldName - String DBObject fieldName to average
Returns:
double Minimum of the records matching the criteria
Throws:
DBException - If the search could not be completed

noNewLine

protected String noNewLine(String fieldValue)
Strip out the newlines out of a string

Parameters:
fieldValue - the Value to strip of newlines
Returns:
the data with newlines stripped

noQuotes

protected String noQuotes(String oldString)
Utility method to return a string with all single quotes replaced with a pair of single quotes, and all double quotes also replaced with a pair of single quotes

Parameters:
oldString - The original string
Returns:
The string modified as above

getCacheUtil

protected CacheUtils getCacheUtil()
'Pseudo' factory method to retrieve the caching utility class instance.

Returns:
CacheUtils instance

notifyListeners

protected void notifyListeners(String eventCode)
                        throws DBException
Used by internal caching to ensure that caches are cleared when an update is made. Notifies all of the objects registered to receive "update events" on this object of the fact that an update has occurred. The "listener" then clears or updates it's cache as appropriate.

Parameters:
eventCode - The "code" for the event that has just occurred
Throws:
DBException - If an error occurrs trying to send all of the event notices

populateDefaultValues

public void populateDefaultValues()
                           throws DBException
populateDefaultValues is called by the schema object to allow a table to populate itself with any desired values.

The base class implementation does nothing. Override this method in derived classes to achieve your custom behavior.

The calling routine, DBTool.populateTables(), will set dbName on each object, so you can get it from getDataContext(), and you can assume that the user for the population action is Admin.

Throws:
DBException - Upon add error, never if it isn't overridden.

referredToBy

protected void referredToBy(DBObject refObject,
                            String foreignKeyNames,
                            String errorMessage)
                     throws DBException
The reverse of the checkRef method - if this object is referred to by some other object, and we are changing our own key (only allowed by deleting) then check the other table to make sure our key is not being used by it!

This method should by called by subclass delete() methods (which then call super.delete() to handle the actual deletion)

Parameters:
refObject - An instance of the DBObject that refers to us
foreignKeyNames - A semicolon-delimited list of foreign key names from the other object
errorMessage - The error message to throw if the key is in use
Throws:
DBException - If it is not possible to register the given referential constraint

removeFromCache

public void removeFromCache(DBObject theDBObj)
                     throws DBException
Remove a specific object from that object's cache. It will then be re-read when a new object is requested by a client program

Creation date: (4/18/00 1:49:46 PM)

Parameters:
theDBObj - com.jcorporate.expresso.core.dbobj.DBObject The object to be removed
Throws:
DBException - upon error.

removeAttribute

public void removeAttribute(String attributeName)
Removes an attribute from this particular database object.

Parameters:
attributeName - The name of the attribute to remove.

retrieve

public void retrieve()
              throws DBException
Get a particular record from the database into this object's fields Key fields for this object must be set; throws otherwise

Throws:
DBRecordNotFoundException - If the record could not be retrieved.
DBException - [Really DBRecordNotFoundException]
See Also:
find()

retrieveFromCache

public boolean retrieveFromCache()
                          throws DBException
Retrieve this object from cache, if possible.

Returns:
true if the cache supplied this item, false otherwise
Throws:
DBException - upon error.

search

public void search()
            throws DBException
Find a set of keys of all of the objects that match the current search critieria in the fields. Search assumes that the fields are populated with search criteria instead of data NOTE: Criteria in 'text' type colums is ignored. After the search, the foundKeys vector is populated with the keys of the records found by the search.

Throws:
DBException - if unable to retreive records due to a database problem Modify by Yves Henri AMAIZO

search

public void search(String sortKeyString)
            throws DBException
Second form of search: takes a list of sort keys & calls regular search. The records retrieved are in the specified order

Parameters:
sortKeyString - A string containing field names, seperated by pipes, that indicate in what order the objects are retrieved
Throws:
DBException - upon error.

searchAndRetrieveList

public ArrayList searchAndRetrieveList()
                                throws DBException
Find a set of records of all of the objects that match the current search critieria in the fields and retrieve the list of all records that match this criteria NOTE: Criteria in 'text' type colums is ignored (SQL Server limitation)

SIDE-EFFECT: custom 'where' clause is set to null.

Specified by:
searchAndRetrieveList in interface DataObject
Returns:
Vector A vector of new database objects containing the results of the search
Throws:
DBException - If the search could not be completed

searchAndRetrieveList

public ArrayList searchAndRetrieveList(String sortKeyString)
                                throws DBException
Search and retrieve in a particular order

Specified by:
searchAndRetrieveList in interface DataObject
Parameters:
sortKeyString - A pipe-delimited list of key fields to sort the returned set by
Returns:
Vector A vector of new database objects retrieved by the search
Throws:
DBException - If the search could not be completed

setAttribute

public void setAttribute(String attribName,
                         Object attribValue)
Set an attribute. Attributes are temporary (e.g. not stored in the DBMS) values associated with this particular DB object instance.

Specified by:
setAttribute in interface DataObject
Parameters:
attribName - The name of the attribute being defined
attribValue - The object to store under this attribute name

setCacheSize

public void setCacheSize()
Read the configuration table to determine the max size of the cache for this db object. The way we go about it is like so:
  1. Check if setCacheSize(int) has been set before. If so, return that
  2. Check if a specific entry exists for this object in the ControllerDefaults table if so return that
  3. Try to read the default entries in the table. If it doesn't exist you're going to see a log warning. Return that value
  4. And finally if that all fails, set the default cache size to zero

setCharset

public void setCharset(String newCharSet)
                throws DBException
Set a characterset for a particular field. for more information on Filters and implementing Filters for your own characterset.

Sets the characterset expected for a this DB object. A Table's default is "ISO-8859-1"

Parameters:
newCharSet - The name of the characterset that you will filter against. For Western-Latin character sets use "ISO-8859-1" as the parameter. Currently, no other charactersets are implemented.
Throws:
DBException - upon error.
See Also:
FilterManager, Filter, ISO_8859_1

getCheckZeroUpdate

public boolean getCheckZeroUpdate()
                           throws DBException
Gets the check zero update flags for this DBObject.

Returns:
boolean value that denotes if check zero update is on or off.
Throws:
DBException - upon error.
See Also:
getCheckZeroUpdate(), JDBCConfig.checkZeroUpdate(), DBConnectionPool.getCheckZeroUpdate()

setCheckZeroUpdate

public void setCheckZeroUpdate(boolean newFlag)
                        throws DBException
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
Throws:
DBException - upon error.

setConnection

public void setConnection(DBConnection newConnection)
                   throws DBException
Set a specific DB connection for use with this db object. If you do not set a connection, the db object will request it's own connection from the appropriate connection pool & release it again after every operation (e.g. add, update, etc). It is important to use your own explicit connection when dealing with a database transactional environment (e.g. commit(), rollback()).

Overrides:
setConnection in class JDBCDataObject
Parameters:
newConnection - The new DBConnection object to be used by this DB Object
Throws:
DBException - upon error.

setConnection

public void setConnection(DBConnection newConnection,
                          String setupTablesContext)
                   throws DBException

Set a specific DB connection for use with this db object. If you do not set a connection, the db object will request it's own connection from the appropriate connection pool & release it again after every operation (e.g. add, update, etc). It is important to use your own explicit connection when dealing with a database transactional environment (e.g. commit(), rollback()).

The difference between this and setConnection(DBConnection) is that this is used for using otherDB capabilities within a transaction. So you use a dbconnection from your other pool, but the setup tables are in a different context

Overrides:
setConnection in class JDBCDataObject
Parameters:
newConnection - The new DBConnection object to be used by this DB Object
setupTablesContext - the data context that is used for the expresso setup tables.
Throws:
DBException - upon error.
See Also:
setConnection(DBConnection)

setCustomWhereClause

public void setCustomWhereClause(String newCustomWhere)
Specify a custom "where" clause for the SQL used to retrieve records for this object. The where clause 'reset' after each call to searchAndRetrieve() or other retrieval methods, so it must be set just before the call to retrieve the records is made. If no custom where clause is specified by this method, the where clause is built from the field values in the object.

Parameters:
newCustomWhere - java.lang.String string with clause. Do NOT add 'WHERE' keyword--this is prepended by system, so that multiple calls to append can be made

setCustomWhereClause

public void setCustomWhereClause(String newCustomWhere,
                                 boolean append)
Allows us to specify a custom WHERE clause and have it appended to the one built from the field values in the object

Parameters:
newCustomWhere - java.lang.String string with clause. Do NOT add 'WHERE' keyword--this is prepended by system, so that multiple calls to append can be made
append - if true, custom WHERE clause is appended

getCustomWhereClause

public String getCustomWhereClause()
Allows us to query the custom where clause (if any). ' WHERE ' has been prepended to the clause. You may want to remove this prepended info for reuse, e.g. getCustomWhereClause().substring(WHERE_KEYWORD.length())

Returns:
java.lang.String or null if no custom where clause has been set.

setDefaultValue

protected void setDefaultValue(String fieldName,
                               String fieldValue)
                        throws DBException
Define a "default" value for a field - to be used for the field when the user does not specify a value.

Parameters:
fieldName - the field to set
fieldValue - the default value to set
Throws:
DBException - upon error.

setDescription

public void setDescription(String newDescription)
                    throws DBException
Set the description of this object

Parameters:
newDescription - A description of this database object
Throws:
DBException - upon error.

setField

public void setField(String fieldName,
                     byte fieldValue)
              throws DBException
Byte primitive integer Typesafe version of setField. Convenience method to set the field values.

Parameters:
fieldName - The name to set
fieldValue - the byte integer field value to set
Throws:
DBException - upon error.

setField

public void setField(String fieldName,
                     byte[] fieldValue)
              throws DBException
Byte primitive integer Typesafe version of setField. Convenience method to set the field values.

Parameters:
fieldName - The name to set
fieldValue - the byte integer field value to set
Throws:
DBException - upon error.

setField

public void setField(String fieldName,
                     short fieldValue)
              throws DBException
Short primitive integer Typesafe version of setField. Convenience method to set the field values.

Parameters:
fieldName - The name to set
fieldValue - the short integer field value to set
Throws:
DBException - upon error.

setField

public void setField(String fieldName,
                     int fieldValue)
              throws DBException
Integer primitive Typesafe version of setField. Convenience method to set the field value.

Parameters:
fieldName - The name to set
fieldValue - the integer field value to set
Throws:
DBException - upon invalid parameters.

setField

public void setField(String fieldName,
                     long fieldValue)
              throws DBException
Long primitive Typesafe version of setField. Convenience method to set the field value.

Parameters:
fieldName - The name to set
fieldValue - the long integer field value to set
Throws:
DBException - upon invalid parameters.

setField

public void setField(String fieldName,
                     double fieldValue)
              throws DBException
Double primitive Typesafe version of setField. Convenience method to set the field values.

Parameters:
fieldName - The name to set
fieldValue - the double field value to set
Throws:
DBException - upon invalid values.

setField

public void setField(String fieldName,
                     BigDecimal fieldValue)
              throws DBException
BigDecimal object Typesafe version of setField. Convenience method to set the field values.

Parameters:
fieldName - The name to set
fieldValue - the big decimal value to set
Throws:
DBException - upon error.

setField

public void setField(String fieldName,
                     boolean fieldValue)
              throws DBException
Boolean typesafe version of setField

Parameters:
fieldName - The field name to set
fieldValue - the new boolean Field Value to set
Throws:
DBException - upon error.

getBooleanFieldValue

protected String getBooleanFieldValue(boolean fieldValue)
                               throws DBException
Internal refactoring for getting what a boolean field should be set to.

Parameters:
fieldValue - The target value
Returns:
the string value
Throws:
DBException - upon error.

setField

public void setField(String fieldName,
                     String fieldValue)
              throws DBException
Set the given field to a given value. Call checkField before setting the value to verify that it is allowed for this field The subclass must override checkField as required

Parameters:
fieldName - The name of the field
fieldValue - The value to set the field
Throws:
DBException - If the given field does not exist in this object or the value supplied is not allowed for this field

setField

public void setField(String fieldName,
                     Date fieldValue)
              throws DBException
Date object Typesafe version of setField. Convenience method to set the field values.

Parameters:
fieldName - The name to set
fieldValue - the Java date value to set
Throws:
DBException - upon error.

logChange

protected void logChange(DBField oneField,
                         String fieldValue)
Helper Function: If Change Logging is enabled, then this logs what has changed

Parameters:
oneField - The field to set the data to.
fieldValue - The value to set the field to.

setFieldData

protected void setFieldData(String fieldName,
                            String fieldValue)
Helper function that doesn't fire all the processing... just set's the field data in raw form and forgets it.

Parameters:
fieldName - The name of the field to set
fieldValue - the value to set it to.

setFieldData

protected void setFieldData(String fieldName,
                            byte[] fieldValue)
Helper function that doesn't fire all the processing... just set's the field data in raw form and forgets it.

Parameters:
fieldName - The name of the field to set
fieldValue - the value to set it to.

setFieldDistinct

public void setFieldDistinct(String fieldName,
                             boolean flag)
                      throws DBException
Convenience method to set a field to be distinct or not within this database object.

Parameters:
fieldName - the name of the field
flag - boolean value true if the field is set distinct.
Throws:
DBException - If the operation could not be completed

author Peter Pilgrim

See Also:
isFieldDistinct(java.lang.String), isDistinct()

setFieldsToRetrieve

public void setFieldsToRetrieve(String fieldNames)
                         throws DBException
Convenience method to set the fields to be retrieved within this database object. NOTE AS OF EXPRESSO 5.0 setFieldsToRetrieve() could cause you some problems if you're attempting to retrieve long objects since everything will be converted to a STRING. Please use caution :).

Parameters:
fieldNames - contain the name of the fields separate by "|"
Throws:
DBException - If the operation could not be completed

author Yves Henri Amaizo

See Also:
isFieldsToRetrieve()

setKeys

public void setKeys(String keyValues)
             throws DBException
Set the values for each of the key fields of this object from a /-delimited string

Parameters:
keyValues - The string containing one value for each key field in the object
Throws:
DBException - If the key fields cannot be set

setLookupObject

public void setLookupObject(String fieldName,
                            String objectName)
                     throws DBException
Set 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. This value is used by the DBMaint servlet to provide automatic lookup ability for related fields. Side-effect: adds a listener for this object to cache manager in order to maintain caches for valid values

Parameters:
fieldName - The field name that this lookup is associated with
objectName - The db object used to look up valid values for this field.
Throws:
DBException - upon error.

setLookupField

public void setLookupField(String fieldName,
                           String lookupFieldName)
Sets the lookup field name. This field allows automatic lookups to be performed by matching the field name given with the primary key of the lookup object. Note to use this feature, the lookup object can only have one and only one primary key field at this time.

Parameters:
fieldName - the name to set the lookup field value for.
lookupFieldName - the field name in the lookup object to map.

setMask

protected void setMask(String fieldName,
                       String newMask)
                throws DBException
Set a "mask", or regular expresso to be matched, for the named field. This regular expression is then checked whenever the field is validated

Note: Masks are used to validate a field's data type to prevent sql injections. So, when setting your own mask, make sure it excludes thwarts sql injections.

Parameters:
fieldName - The field name to set
newMask - the regular expression to apply to this field
Throws:
DBException - upon error.

setMaxRecords

public void setMaxRecords(int newMax)
                   throws DBException
Specify a maximum number of records to be retrieved in any subsequent searchAndRetrieve() call. Records will be retrieved (in the specified sort order) until the specified maximum is reached, then the remainder of the result set is discarded. Specifying zero indicates that all records are to be retrieved.

Specified by:
setMaxRecords in interface DataObject
Parameters:
newMax - The maximum number of records to retrieve.
Throws:
DBException - If the max number is less than 0

setMultiValued

protected void setMultiValued(String fieldName)
                       throws DBException
Set this field to be multi-valued - e.g. there is a specific list of values that are valid for this field. There should be code in the getValidValues method that returns the valid values for the specified multi-valued field.

Parameters:
fieldName - The name of the field to specify as multi-valued
Throws:
DBException - If the field name given is not valid, or is a virtual field

setName

protected void setName(String theName)
                throws DBException
Set the name of this object - this name is used to identify the db object with a more human-readable description

Parameters:
theName - New name for this object
Throws:
DBException - upon error.

setOffsetRecord

public void setOffsetRecord(int newOffset)
                     throws DBException
Specifies the number of records that should be skipped over before any data from the ResultSet is retrieved in any subsequent searchAndRetrieve() call. Records will be skipped over (in the specified sort order) until the record counts is equal to or greater than the offset record. Specifying zero indicates that no records should be skipped over and the ResultSet immediately from the start.

Specified by:
setOffsetRecord in interface DataObject
Parameters:
newOffset - The maximum number of records to retrieve.
Throws:
DBException - If the max number is less than 0

author Peter Pilgrim


setReadOnly

public void setReadOnly(String fieldName)
                 throws DBException
Set a field as read-only - these fields are not offered for update when a form is produced by the generic database maintenance servlet (DBMaint). It does not otherwise affect the use of the field.

Typical uses are for serial-numbered fields and timestamps

Parameters:
fieldName - The name of the field to be reserved as normally read-only.
Throws:
DBException - If there is no such field.

setSchema

public void setSchema(Schema schema)
               throws DBException
Specify which schema this DB object belongs to. This is necessary when using the local-langauge strings in the DB object for field names, descriptions, etc. The schema will be assumed to be Expresso's schema if not otherwise set. From expresso 5.3, this method is called in ConfigManager at startup. You probably do not need to call it. (Previously, developers had to call it within each DBObject's setup().)

Parameters:
schema - The schema to set
Throws:
DBException - upon error.

setSecret

public void setSecret(String fieldName)
               throws DBException
Set a field as 'secret' - these fields are not shown when a list is produced by the generic database maintenance servlet. In this way, only users with update permission to the object can view the values of "secret" fields.

Parameters:
fieldName - The name of the field to set as 'secret'
Throws:
DBException - I fthe field does not exist

setStringFilter

public String setStringFilter(String fieldName,
                              String filterMethod)
                       throws DBException
Set a filter for a particular field, permanently for all instances of this class. for a means to set a filter on just a single instance, see setFilterClass

Parameters:
fieldName - The name of the field to set a particular filter for.
filterMethod - The name of the filter method to use when calling a filter. Can be one of three values:
See FilterManager.filterString(java.lang.String, java.lang.Class, java.lang.String) for more information on this parameter.
Returns:
old filter just replaced
Throws:
DBException - if: fieldName doesn't exist, or filterType String isn't a valid value.
See Also:
FilterManager, for a means to set a filter on just an instance

getStringFilter

public String getStringFilter(String fieldName)
                       throws DBException
get the current filter for a particular field. This is the 'static', permanent filter.

Parameters:
fieldName - The name of the field to set a particular filter for.
Returns:
java.lang.String the current filter method.
Throws:
DBException - if: fieldName doesn't exist, or filterType String isn't a valid value.
See Also:
for a means to get a filter on just an instance, FilterManager

setTargetTable

public void setTargetTable(String theTable)
                    throws DBException
Set the target table for this DBObject. Note that an object can span tables by the use of virtual fields, but that this table is the default table for the object.

Parameters:
theTable - Table for this object
Throws:
DBException - upon error.

setTargetDbSchema

public void setTargetDbSchema(String theDbSchema)
                       throws DBException
Set the target table for this DBObject. Note that an object can span tables by the use of virtual fields, but that this table is the default table for the object.

Parameters:
theDbSchema - Table for this object
Throws:
DBException - upon error.

setupFields

protected void setupFields()
                    throws DBException
Method to set up the fields for this database object. This method should be defined in the implementing object and should make calls to addField, addKey, setMultiValued, etc. as required to define the content of the DBObject. Each setupFields method should call "super.setupFields()" so that field definitions can be "inheritcable"

Throws:
DBException - If there is an error setting up the fields as requested. For example, if a field allowing null is requested as part of the key

sqlAggrFunction

protected double sqlAggrFunction(String func,
                                 String fieldName)
                          throws DBException
This allows the invocation of the SQL AVG, MIN, MAX and SUM aggregate functions on one of the DB's columns (the DBObject fieldname is supplied). This function is not meant to be used directly, but is here as the common/shared code used by the following methods in DBObject: avg(String), min(String), max(String), sum(String).

Parameters:
func - String The SQL aggregate function - must be one of AVG, MIN, MAX, SUM
fieldName - String The DBObject fieldName to use for the aggregate function
Returns:
double The result of the SQL function invocation
Throws:
DBException - If the function could not be completed Modify by Yves Henri AMAIZO

sum

public double sum(String fieldName)
           throws DBException
Find the sum of the values in the specified field of records selected by the DBObject selection criteria.

Parameters:
fieldName - String DBObject fieldName to average
Returns:
double Sum of the records matching the criteria
Throws:
DBException - If the search could not be completed

update

public void update()
            throws DBException
Update the database with the new info. Update affects only one record, and uses the current field values to write to the DBMS.

by default, updates all fields each time.

for efficiency, developers who are confident that their code does not have any 'blind updates' can set the Setup value UPDATE_CHANGED_ONLY to true (a blind update is where the object is not retieved before values in it are reset)

Specified by:
update in interface DataObject
Throws:
DBException - if the update to the database fails due to a database error
See Also:
update(boolean)

update

public void update(boolean updateChangedFieldsOnly)
            throws DBException
Update the database with the new info. Update affects only one record, and uses the current field values to write to the DBMS.

if param updateChangedFieldsOnly is true, only changed fields are updated. this assumes that the entire object has been retrieved from DB prior to resetting any field.

Parameters:
updateChangedFieldsOnly - if true only modified fields (isChanged = true) will be included in the update
Throws:
DBException - if the update to the database fails due to a database error

toDebugString

public String toDebugString()
Generate a debuggable string for suitable printing out in an interactive Java IDE. Write the string in PERL hash structure style. Primary key field are denoted with (*) asterisks.

 com.bar.foo.AcmePayroll@1234BABE{
   id* => 7, fullname => Peter Pilgrim,
   city => country => England }
 

This is a method is not the standard toString() because some times a data object used professionally can have dozens of data fields. We also dont want to overwhelm you with useless information!

Returns:
java.lang.String

updateAll

public void updateAll()
               throws DBException
Update all of the records specified by the current search criteria. If you use a blank DBObject, then all the records in the table will be deleted

Throws:
DBException - upon error

updateAll

public void updateAll(boolean oneByOne)
               throws DBException
Update the database with the new info. Update affects all records, and uses the current field values to write to the DBMS.

Parameters:
oneByOne - if true the records will be modifed one by one and will be included in the cache
Throws:
DBException - if the update to the database fails due to a database error

verify

public void verify()
            throws DBException
Verify that this object is working correctly by selecting all records, running a validation on each of them. The validation consists of verifying the referential integrity against all objects defined as being referred to by this object in the checkAllRefs method

Throws:
DBException - If the validation fails

equals

public boolean equals(Object parm1)
Equals implementation. this == parm1 If and only if:
1 - The two classes are of the same classname
2 - All the data fields in the two classes are the same
3 - The data contexts are the same

Specified by:
equals in interface DataObject
Parameters:
parm1 - The object to compare to
Returns:
true if the two objects being compared are equal

getDataField

public DataField getDataField(String fieldName)
                       throws DBException
Same as getField, but works with the DataObject interface for now. Will eventually return something other than Strings. For example, dates, times, etc

Specified by:
getDataField in interface DataObject
Parameters:
fieldName - name of the field to get the object for.
Returns:
DataField or null if the field doesn't exist yet.
Throws:
DBException - upon error.

get

public Object get(String fieldName)
           throws DataException
Directly gets the DataField Data without having to deal with the DataField itself

Specified by:
get in interface DataObject
Parameters:
fieldName - the name of the field to get
Returns:
Object or null.
Throws:
DataException - upon error.

set

public void set(String fieldName,
                Object o)
         throws DataException
sets the field value by using 'instanceof' operator; convenient for template methods, but less efficient than calling setField()

Specified by:
set in interface DataObject
Parameters:
fieldName - the name of the field to set
o - the object value to set it to.
Throws:
DataException - upon error.
See Also:
setField(java.lang.String, byte)

setDataField

public void setDataField(String fieldName,
                         DataField o)
                  throws DataException
Same as setField, but works with the DataObject Interface

Parameters:
fieldName - the name of the field to set.
o - the object to set the field to... currently should be java.lang.Strings only.
Throws:
DataException - upon error.
Since:
Expresso 5.0

setDataContext

public void setDataContext(String newContext)
Sets the data context that this object is residing in. This is identical to the pre-Expresso 5.0 setDBName()

Specified by:
setDataContext in interface ContextNested
Parameters:
newContext - the new name of the data context.
Throws:
IllegalArgumentException - if the DataContext does not exist

getDataContext

public String getDataContext()
Returns the name of the currently set DataContext

Specified by:
getDataContext in interface ContextNested
Returns:
java.lang.String

getAllAttributes

public Map getAllAttributes()
Returns a Read Only Map containing all the current attributes set for this particular data object instance.

Specified by:
getAllAttributes in interface DataObject
Returns:
Read Only java.util.Map

setStringFiltersOnAll

public void setStringFiltersOnAll(String filter)
                           throws DBException
set string filters to the given filter on ALL fields that are quoted text fields

Parameters:
filter - filter to set
Throws:
DBException - upon error

getFilterClass

public Class getFilterClass()
the INSTANCE value of filter class that will be used for all string filtering for THIS INSTANCE. defaults to null, which means that there is no instance filter, so static filter will be used. If this instance returns null, static value in DBField.getFilterClass() filter class will be used. This method only returns the local data member, not the static value from DBField

Returns:
the current filter (a subclass of Filter), or null to indicate default (HTML) filter
See Also:
DBField.getFilterClass(), HtmlFilter

setFilterClass

public Class setFilterClass(Class filter)
Deprecated. use setFilterClass(Filter)

set the filter class that will be used for all string filtering for this object instance ONLY.

Parameters:
filter - class which is subclass of Filter
Returns:
old Class that was just replaced
See Also:
Filter, DBField.setFilterClass(java.lang.Class)

setFilterClass

public Filter setFilterClass(Filter filter)
set the filter class that will be used for all string filtering for this object instance ONLY.

Parameters:
filter - which is subclass of Filter; we will persist only the class name, NOT the instance passed in
Returns:
old filter that was just replaced; can be null
See Also:
for a means to set "permanenent" filters in metadata for all objects of this class, DBField.setFilterClass(java.lang.Class)

getLogger

public org.apache.log4j.Logger getLogger()
convenience for getting logger for current (sub) class

Returns:
Category for logging

isChanged

public boolean isChanged()
                  throws DBException
summarize DataField.isChanged() for all fields. isChanged() per field means that setField() has been called twice for that field, once presumably by retrieval from DB, once to change a value (with new value != former value)

Returns:
true if any field has been changed--i.e., setField() for that field has been called twice, once presumably by retrieval from DB, once to change a value
Throws:
DBException - upon error.
See Also:
DataField.isChanged()

Expresso 5-6

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