| java.lang.Object org.apache.ojb.broker.util.BrokerHelper
BrokerHelper | public class BrokerHelper (Code) | | This class contains helper methods primarily used by the
org.apache.ojb.broker.PersistenceBroker implementation (e.g. contains methods to assign the the values of 'autoincrement' fields).
Furthermore it was used to introduce new features related to
org.apache.ojb.broker.PersistenceBroker - these
new features and services (if they stand the test of time) will be moved to separate services in future.
author: Armin Waibel version: $Id: BrokerHelper.java,v 1.57.2.23 2005/12/21 22:27:47 tomdz Exp $ |
Method Summary | |
public boolean | assertValidPkForDelete(ClassDescriptor cld, Object obj) returns true if the primary key fields are valid for delete, else false. | public boolean | assertValidPksForStore(FieldDescriptor[] fieldDescriptors, Object[] pkValues) returns true if the primary key fields are valid for store, else false. | public static PBKey | crossCheckPBKey(PBKey key) Check if the user of the given PBKey was null , if so we try to
get user/password from the jdbc-connection-descriptor matching the given
PBKey.getAlias(). | public boolean | doesExist(ClassDescriptor cld, Identity oid, Object obj) TODO: This method should be moved to
org.apache.ojb.broker.accesslayer.JdbcAccess before 1.1 release. | public static PBKey | extractAllTokens(String name) splits up the name string and extract db url,
user name and password and build a new PBKey
instance - the token '#' is used to separate
the substrings. | public Object[] | extractValueArray(ValueContainer[] containers) Extract an value array of the given
ValueContainer array. | public ValueContainer[] | getAllRwValues(ClassDescriptor cld, Object obj) Returns an array containing values for all READ/WRITE attributes of the object
based on the specified
org.apache.ojb.broker.metadata.ClassDescriptor . | public static Object[] | getCollectionArray(Object collectionOrArray) Returns an object array for
java.util.Collection , array or
org.apache.ojb.broker.ManageableCollection instances.
Parameters: collectionOrArray - a none null object of type java.util.Collection,Array or org.apache.ojb.broker.ManageableCollection. | public static Iterator | getCollectionIterator(Object collectionOrArray) Returns an Iterator instance for
java.util.Collection , object Array or
org.apache.ojb.broker.ManageableCollection instances.
Parameters: collectionOrArray - a none null object of type java.util.Collection,Array or org.apache.ojb.broker.ManageableCollection. | public Query | getCountQuery(Query aQuery) | public ValueContainer[] | getKeyValues(ClassDescriptor cld, Object objectOrProxy, boolean convertToSql) Returns an Array with an Objects PK VALUES if convertToSql is true, any
associated java-to-sql conversions are applied. | public ValueContainer[] | getKeyValues(ClassDescriptor cld, Identity oid) Return primary key values of given Identity object. | public ValueContainer[] | getKeyValues(ClassDescriptor cld, Identity oid, boolean convertToSql) | public ValueContainer[] | getKeyValues(ClassDescriptor cld, Object objectOrProxy) returns an Array with an Objects PK VALUES, with any java-to-sql
FieldConversion applied. | public ValueContainer[] | getNonKeyRwValues(ClassDescriptor cld, Object obj) Returns an array containing values for all non PK field READ/WRITE attributes of the object
based on the specified
org.apache.ojb.broker.metadata.ClassDescriptor . | public ValueContainer[] | getValuesForObject(FieldDescriptor[] fields, Object obj, boolean convertToSql, boolean assignAutoincrement) Get the values of the fields for an obj
Autoincrement values are automatically set. | public ValueContainer[] | getValuesForObject(FieldDescriptor[] fields, Object obj, boolean convertToSql) | public static boolean | hasAnonymousKeyReference(ClassDescriptor cld, ObjectReferenceDescriptor rds) Returns true if one or more anonymous FK fields are used.
Parameters: cld - The org.apache.ojb.broker.metadata.ClassDescriptor of the main object. Parameters: rds - The org.apache.ojb.broker.metadata.ObjectReferenceDescriptor of the referenced object. | public boolean | hasNullPKField(ClassDescriptor cld, Object obj) Detect if the given object has a PK field represents a 'null' value. | public void | link(Object obj, boolean insert) This method concatenate the main object with all reference
objects (1:1, 1:n and m:n) by hand. | public void | link(Object obj, ObjectReferenceDescriptor ord, boolean insert) This method concatenate the main object and the specified reference
object (1:1 reference a referenced object, 1:n and m:n reference a
collection of referenced objects) by hand. | public boolean | link(Object obj, String attributeName, boolean insert) This method concatenate the main object and the specified reference
object (1:1 reference a referenced object, 1:n and m:n reference a
collection of referenced objects) by hand. | public boolean | link(Object obj, String attributeName, Object reference, boolean insert) This method concatenate the main object and the specified reference
object (1:1 reference a referenced object, 1:n and m:n reference a
collection of referenced objects) by hand. | public void | link(Object source, CollectionDescriptor cds, List referencesToLink) Link a bunch of 1:n or m:n objects. | public void | link(Object source, CollectionDescriptor cds, Object referenceToLink) Link a single 1:n or m:n object. | public boolean | representsNull(FieldDescriptor fld, Object aValue) | public void | unlink(Object obj) Unlink all references from this object. | public boolean | unlink(Object source, String attributeName, Object target) Unlink the specified reference object. | public boolean | unlink(Object source, String attributeName) Unlink all referenced objects of the specified field. | public void | unlink(Object obj, ObjectReferenceDescriptor ord, boolean insert) Unlink the specified reference from this object. | public void | unlink(Object source, CollectionDescriptor cds, List referencesToUnlink) Unlink a bunch of 1:n or m:n objects. | public void | unlink(Object source, CollectionDescriptor cds, Object referenceToUnlink) Unlink a single 1:n or m:n object. |
REPOSITORY_NAME_SEPARATOR | final public static String REPOSITORY_NAME_SEPARATOR(Code) | | |
assertValidPkForDelete | public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj)(Code) | | returns true if the primary key fields are valid for delete, else false.
PK fields are valid if each of them contains a valid non-null value
Parameters: cld - the ClassDescriptor Parameters: obj - the object boolean |
assertValidPksForStore | public boolean assertValidPksForStore(FieldDescriptor[] fieldDescriptors, Object[] pkValues)(Code) | | returns true if the primary key fields are valid for store, else false.
PK fields are valid if each of them is either an OJB managed
attribute (autoincrement or locking) or if it contains
a valid non-null value
Parameters: fieldDescriptors - the array of PK fielddescriptors Parameters: pkValues - the array of PK values boolean |
crossCheckPBKey | public static PBKey crossCheckPBKey(PBKey key)(Code) | | Check if the user of the given PBKey was null , if so we try to
get user/password from the jdbc-connection-descriptor matching the given
PBKey.getAlias().
|
extractAllTokens | public static PBKey extractAllTokens(String name)(Code) | | splits up the name string and extract db url,
user name and password and build a new PBKey
instance - the token '#' is used to separate
the substrings.
throws: PersistenceBrokerException - if given name was null |
getCountQuery | public Query getCountQuery(Query aQuery)(Code) | | Build a Count-Query based on aQuery
Parameters: aQuery - The count query |
hasNullPKField | public boolean hasNullPKField(ClassDescriptor cld, Object obj)(Code) | | Detect if the given object has a PK field represents a 'null' value.
|
link | public void link(Object obj, boolean insert)(Code) | | This method concatenate the main object with all reference
objects (1:1, 1:n and m:n) by hand. This method is needed when
in the reference metadata definitions the auto-xxx setting was disabled.
More info see OJB doc.
|
link | public void link(Object obj, ObjectReferenceDescriptor ord, boolean insert)(Code) | | This method concatenate the main object and the specified reference
object (1:1 reference a referenced object, 1:n and m:n reference a
collection of referenced objects) by hand. This method is needed when
in the reference metadata definitions the auto-xxx setting was disabled.
More info see OJB doc.
Parameters: obj - Object with reference Parameters: ord - the ObjectReferenceDescriptor of the reference Parameters: insert - flag signals insert operation |
link | public boolean link(Object obj, String attributeName, boolean insert)(Code) | | This method concatenate the main object and the specified reference
object (1:1 reference a referenced object, 1:n and m:n reference a
collection of referenced objects) by hand. This method is needed when
in the reference metadata definitions the auto-xxx setting was disabled.
More info see OJB doc.
Parameters: obj - Object with reference Parameters: attributeName - field name of the reference Parameters: insert - flag signals insert operation true if the specified reference was found and linking was successful |
link | public boolean link(Object obj, String attributeName, Object reference, boolean insert)(Code) | | This method concatenate the main object and the specified reference
object (1:1 reference a referenced object, 1:n and m:n reference a
collection of referenced objects) by hand. This method is needed when
in the reference metadata definitions the auto-xxx setting was disabled.
More info see OJB doc.
Parameters: obj - Object with reference Parameters: attributeName - field name of the reference Parameters: reference - The referenced object Parameters: insert - flag signals insert operation true if the specified reference was found and linking was successful |
representsNull | public boolean representsNull(FieldDescriptor fld, Object aValue)(Code) | | Decide if the given object value represents 'null'.
- If given value is 'null' itself, true will be returned
- If given value is instance of Number with value 0 and the field-descriptor
represents a primitive field, true will be returned
- If given value is instance of String with length 0 and the field-descriptor
is a primary key, true will be returned
|
unlink | public void unlink(Object obj)(Code) | | Unlink all references from this object.
More info see OJB doc.
Parameters: obj - Object with reference |
unlink | public boolean unlink(Object source, String attributeName, Object target)(Code) | | Unlink the specified reference object.
More info see OJB doc.
Parameters: source - The source object with the specified reference field. Parameters: attributeName - The field name of the reference to unlink. Parameters: target - The referenced object to unlink. |
unlink | public boolean unlink(Object source, String attributeName)(Code) | | Unlink all referenced objects of the specified field.
More info see OJB doc.
Parameters: source - The source object with the specified reference. Parameters: attributeName - The field name of the reference to unlink. |
unlink | public void unlink(Object obj, ObjectReferenceDescriptor ord, boolean insert)(Code) | | Unlink the specified reference from this object.
More info see OJB doc.
Parameters: obj - Object with reference Parameters: ord - the ObjectReferenceDescriptor of the reference Parameters: insert - flag signals insert operation |
|
|