Java Doc for BrokerHelper.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » db ojb » org.apache.ojb.broker.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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 $


Field Summary
final public static  StringREPOSITORY_NAME_SEPARATOR
    

Constructor Summary
public  BrokerHelper(PersistenceBrokerImpl broker)
    

Method Summary
public  booleanassertValidPkForDelete(ClassDescriptor cld, Object obj)
     returns true if the primary key fields are valid for delete, else false.
public  booleanassertValidPksForStore(FieldDescriptor[] fieldDescriptors, Object[] pkValues)
     returns true if the primary key fields are valid for store, else false.
public static  PBKeycrossCheckPBKey(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  booleandoesExist(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  PBKeyextractAllTokens(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  IteratorgetCollectionIterator(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  QuerygetCountQuery(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  booleanhasAnonymousKeyReference(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  booleanhasNullPKField(ClassDescriptor cld, Object obj)
     Detect if the given object has a PK field represents a 'null' value.
public  voidlink(Object obj, boolean insert)
     This method concatenate the main object with all reference objects (1:1, 1:n and m:n) by hand.
public  voidlink(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  booleanlink(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  booleanlink(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  voidlink(Object source, CollectionDescriptor cds, List referencesToLink)
     Link a bunch of 1:n or m:n objects.
public  voidlink(Object source, CollectionDescriptor cds, Object referenceToLink)
     Link a single 1:n or m:n object.
public  booleanrepresentsNull(FieldDescriptor fld, Object aValue)
    
public  voidunlink(Object obj)
     Unlink all references from this object.
public  booleanunlink(Object source, String attributeName, Object target)
     Unlink the specified reference object.
public  booleanunlink(Object source, String attributeName)
     Unlink all referenced objects of the specified field.
public  voidunlink(Object obj, ObjectReferenceDescriptor ord, boolean insert)
     Unlink the specified reference from this object.
public  voidunlink(Object source, CollectionDescriptor cds, List referencesToUnlink)
     Unlink a bunch of 1:n or m:n objects.
public  voidunlink(Object source, CollectionDescriptor cds, Object referenceToUnlink)
     Unlink a single 1:n or m:n object.

Field Detail
REPOSITORY_NAME_SEPARATOR
final public static String REPOSITORY_NAME_SEPARATOR(Code)




Constructor Detail
BrokerHelper
public BrokerHelper(PersistenceBrokerImpl broker)(Code)




Method Detail
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().



doesExist
public boolean doesExist(ClassDescriptor cld, Identity oid, Object obj)(Code)
TODO: This method should be moved to org.apache.ojb.broker.accesslayer.JdbcAccess before 1.1 release. This method checks if the requested object can be found in database (without object materialization).
Parameters:
  cld - The org.apache.ojb.broker.metadata.ClassDescriptor of theobject/org.apache.ojb.broker.Identity to check.
Parameters:
  obj - The object to check.
Parameters:
  oid - The associated org.apache.ojb.broker.Identity.org.apache.ojb.broker.Identity of the object Return true if the object is already persisted, false if the object is transient.



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



extractValueArray
public Object[] extractValueArray(ValueContainer[] containers)(Code)
Extract an value array of the given ValueContainer array.
Parameters:
  containers - An object array



getAllRwValues
public ValueContainer[] getAllRwValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException(Code)
Returns an array containing values for all READ/WRITE attributes of the object based on the specified org.apache.ojb.broker.metadata.ClassDescriptor .
NOTE: This method doesn't do any checks on the specified org.apache.ojb.broker.metadata.ClassDescriptor the caller is reponsible to pass a valid descriptor.
Parameters:
  cld - The org.apache.ojb.broker.metadata.ClassDescriptor to extract the RW-fields
Parameters:
  obj - The object with target fields to extract.
throws:
  MetadataException - if there is an erros accessing obj field values



getCollectionArray
public static Object[] getCollectionArray(Object collectionOrArray)(Code)
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. Object array able to handle given collection or array object



getCollectionIterator
public static Iterator getCollectionIterator(Object collectionOrArray)(Code)
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. Iterator able to handle given collection object



getCountQuery
public Query getCountQuery(Query aQuery)(Code)
Build a Count-Query based on aQuery
Parameters:
  aQuery - The count query



getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy, boolean convertToSql) throws PersistenceBrokerException(Code)
Returns an Array with an Objects PK VALUES if convertToSql is true, any associated java-to-sql conversions are applied. If the Object is a Proxy or a VirtualProxy NO conversion is necessary.
Parameters:
  objectOrProxy -
Parameters:
  convertToSql - Object[]
throws:
  PersistenceBrokerException -



getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid) throws PersistenceBrokerException(Code)
Return primary key values of given Identity object.
Parameters:
  cld -
Parameters:
  oid - Object[]
throws:
  PersistenceBrokerException -



getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid, boolean convertToSql) throws PersistenceBrokerException(Code)
Return key Values of an Identity
Parameters:
  cld -
Parameters:
  oid -
Parameters:
  convertToSql - Object[]
throws:
  PersistenceBrokerException -



getKeyValues
public ValueContainer[] getKeyValues(ClassDescriptor cld, Object objectOrProxy) throws PersistenceBrokerException(Code)
returns an Array with an Objects PK VALUES, with any java-to-sql FieldConversion applied. If the Object is a Proxy or a VirtualProxy NO conversion is necessary.
Parameters:
  objectOrProxy - Object[]
throws:
  PersistenceBrokerException -



getNonKeyRwValues
public ValueContainer[] getNonKeyRwValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException(Code)
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 .
NOTE: This method doesn't do any checks on the specified org.apache.ojb.broker.metadata.ClassDescriptor the caller is reponsible to pass a valid descriptor.
Parameters:
  cld - The org.apache.ojb.broker.metadata.ClassDescriptor to extract the RW-fields
Parameters:
  obj - The object with target fields to extract.
throws:
  MetadataException - if there is an erros accessing obj field values



getValuesForObject
public ValueContainer[] getValuesForObject(FieldDescriptor[] fields, Object obj, boolean convertToSql, boolean assignAutoincrement) throws PersistenceBrokerException(Code)
Get the values of the fields for an obj Autoincrement values are automatically set.
Parameters:
  fields -
Parameters:
  obj -
throws:
  PersistenceBrokerException -



getValuesForObject
public ValueContainer[] getValuesForObject(FieldDescriptor[] fields, Object obj, boolean convertToSql) throws PersistenceBrokerException(Code)



hasAnonymousKeyReference
public static boolean hasAnonymousKeyReference(ClassDescriptor cld, ObjectReferenceDescriptor rds)(Code)
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. true if one or more anonymous FK fields are used for specified reference.



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



link
public void link(Object source, CollectionDescriptor cds, List referencesToLink)(Code)
Link a bunch of 1:n or m:n objects.
Parameters:
  source - The source object with reference.
Parameters:
  cds - The org.apache.ojb.broker.metadata.CollectionDescriptor of the relation.
Parameters:
  referencesToLink - List of referenced objects to link.



link
public void link(Object source, CollectionDescriptor cds, Object referenceToLink)(Code)
Link a single 1:n or m:n object.
Parameters:
  source - The source object with the declared reference.
Parameters:
  cds - The org.apache.ojb.broker.metadata.CollectionDescriptor of the relation declared in source object.
Parameters:
  referenceToLink - The referenced object to link.



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



unlink
public void unlink(Object source, CollectionDescriptor cds, List referencesToUnlink)(Code)
Unlink a bunch of 1:n or m:n objects.
Parameters:
  source - The source object with reference.
Parameters:
  cds - The org.apache.ojb.broker.metadata.CollectionDescriptor of the relation.
Parameters:
  referencesToUnlink - List of referenced objects to unlink.



unlink
public void unlink(Object source, CollectionDescriptor cds, Object referenceToUnlink)(Code)
Unlink a single 1:n or m:n object.
Parameters:
  source - The source object with reference.
Parameters:
  cds - The org.apache.ojb.broker.metadata.CollectionDescriptor of the relation.
Parameters:
  referenceToUnlink - The referenced object to link.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.