You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2003/04/06 21:27:28 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
brj 2003/04/06 12:27:28
Modified: src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
Log:
use pathHints in getAttributeDescriptorsForPath
Revision Changes Path
1.54 +46 -7 db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
Index: ClassDescriptor.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- ClassDescriptor.java 3 Apr 2003 20:35:26 -0000 1.53
+++ ClassDescriptor.java 6 Apr 2003 19:27:27 -0000 1.54
@@ -624,11 +624,12 @@
* using relationships <br>
* ie: name, avg(price), adress.street
* @param aPath the path to the attribute
+ * @param pathHints a Map containing the class to be used for a segment
* @return the FieldDescriptor or null (ie: for m:n queries)
*/
- public FieldDescriptor getFieldDescriptorForPath(String aPath)
+ public FieldDescriptor getFieldDescriptorForPath(String aPath, Map pathHints)
{
- ArrayList desc = getAttributeDescriptorsForPath(aPath);
+ ArrayList desc = getAttributeDescriptorsForPath(aPath, pathHints);
FieldDescriptor fld = null;
Object temp;
@@ -644,6 +645,19 @@
}
/**
+ * return the FieldDescriptor for the Attribute referenced in the path<br>
+ * the path may contain simple attribut names, functions and path expressions
+ * using relationships <br>
+ * ie: name, avg(price), adress.street
+ * @param aPath the path to the attribute
+ * @return the FieldDescriptor or null (ie: for m:n queries)
+ */
+ public FieldDescriptor getFieldDescriptorForPath(String aPath)
+ {
+ return getFieldDescriptorForPath(aPath, new HashMap());
+ }
+
+ /**
*
* @return this classes FieldDescriptor's as well as it's parents and so on and so on
*/
@@ -957,7 +971,7 @@
*/
public ArrayList getAttributeDescriptorsForPath(String aPath)
{
- return getAttributeDescriptorsForCleanPath(SqlHelper.cleanPath(aPath));
+ return getAttributeDescriptorsForPath(aPath, new HashMap());
}
/**
@@ -967,9 +981,26 @@
* ie: partner.addresses returns a Collection of 2 AttributeDescriptors
* (ObjectReferenceDescriptor, CollectionDescriptor)
* @param aPath the cleaned path to the attribute
+ * @param pathHints a Map containing the class to be used for a segment
* @return ArrayList of AttributeDescriptors
*/
- private ArrayList getAttributeDescriptorsForCleanPath(String aPath)
+ public ArrayList getAttributeDescriptorsForPath(String aPath, Map pathHints)
+ {
+ return getAttributeDescriptorsForCleanPath(SqlHelper.cleanPath(aPath), pathHints);
+ }
+
+
+ /**
+ * return all AttributeDescriptors for the path<br>
+ * ie: partner.addresses.street returns a Collection of 3 AttributeDescriptors
+ * (ObjectReferenceDescriptor, CollectionDescriptor, FieldDescriptor)<br>
+ * ie: partner.addresses returns a Collection of 2 AttributeDescriptors
+ * (ObjectReferenceDescriptor, CollectionDescriptor)
+ * @param aPath the cleaned path to the attribute
+ * @param pathHints a Map containing the class to be used for a segment
+ * @return ArrayList of AttributeDescriptors
+ */
+ private ArrayList getAttributeDescriptorsForCleanPath(String aPath, Map pathHints)
{
ArrayList result = new ArrayList();
ClassDescriptor cld = this;
@@ -978,7 +1009,8 @@
String currPath = aPath;
String segment;
int sepPos;
-
+ Class itemClass = null;
+
while (currPath.length() > 0)
{
sepPos = currPath.indexOf(".");
@@ -1003,7 +1035,14 @@
if (ord != null)
{
- cld = cld.getRepository().getDescriptorFor(ord.getItemClass());
+ // BRJ : look for hint
+ itemClass = (Class)pathHints.get(segment);
+ if (itemClass == null)
+ {
+ itemClass = ord.getItemClass();
+ }
+
+ cld = cld.getRepository().getDescriptorFor(itemClass);
result.add(ord);
}
else