juergen 2004/06/23 03:56:13
Modified:
proposals/tamino/src/store/org/apache/slide/store/tamino/datastore/search
Tag: TWS421_BRANCH XResourceImpl.java
Log:
Support of the plain=true feature. xpath valued properties are now sorted in the
plain und "unplain" situation.
Revision Changes Path
No revision
No revision
1.1.4.2 +49 -14
jakarta-slide/proposals/tamino/src/store/org/apache/slide/store/tamino/datastore/search/XResourceImpl.java
Index: XResourceImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/tamino/src/store/org/apache/slide/store/tamino/datastore/search/XResourceImpl.java,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -r1.1.4.1 -r1.1.4.2
--- XResourceImpl.java 2 Jun 2004 13:44:40 -0000 1.1.4.1
+++ XResourceImpl.java 23 Jun 2004 10:56:13 -0000 1.1.4.2
@@ -27,6 +27,7 @@
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -41,6 +42,7 @@
import org.apache.slide.util.XMLValue;
import org.jdom.Document;
import org.jdom.Element;
+import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
@@ -241,17 +243,12 @@
int result = 0;
try {
-
- List thisList =
XPath.newInstance("string(//"+hint.getSortBy()+")").selectNodes(getElementAsElement((Element)(thisResource.getList().get(1))));
- List otherList =
XPath.newInstance("string(//"+hint.getSortBy()+")").selectNodes(getElementAsElement((Element)(otherResource.getList().get(1))));
+// System.out.println("\n====================================");
+ List thisList = getTaminoValue(thisResource, hint);
+// System.out.println("====================================");
+ List otherList = getTaminoValue(otherResource, hint);
+// System.out.println("\n====================================");
-// System.out.println( );
-// System.out.println("Element 1\n" +
getElementAsString((Element)(thisResource.getList().get(1))));
-// System.out.println("Element 2\n" +
getElementAsString((Element)(otherResource.getList().get(1))));
-// System.out.println("Comparing " );
-// System.out.println("String1 = " + otherList.get(0) );
-// System.out.println("String2 = " + thisList.get(0) );
-
int thisSize = thisList.size();
int otherSize = otherList.size();
@@ -266,6 +263,7 @@
String thatString = (String)otherList.get(i);
if (!thisString.equals(thatString)) {
+ //System.out.println(thisString +
getOperator(thisString.compareTo(thatString)) + thatString );
return thisString.compareTo(thatString);
}
}
@@ -279,10 +277,47 @@
}
+ private String getOperator(int value) {
+ if (value < 0) {
+ return " < ";
+ } else if (value > 0) {
+ return " > ";
+ } else{
+ return " = ";
+ }
+ }
+
+
+ /**
+ * @param thisResource
+ * @param hint
+ * @return
+ * @throws JDOMException
+ */
+ private static final List EMPTY_LIST = new ArrayList();
+ private List getTaminoValue(XMLValue thisResource, XCompareHint hint) throws
JDOMException {
+
+ int theSize = thisResource.getList().size();
+// System.out.println("Element size = " + theSize);
+ if (theSize == 2) {
+// System.out.println("Element \n" +
getElementAsString((Element)(thisResource.getList().get(0))));
+// System.out.println("Element \n" +
getElementAsString((Element)(thisResource.getList().get(1))));
+ List thisList =
XPath.newInstance("string(//"+hint.getSortBy()+")").selectNodes(getElementAsElement((Element)(thisResource.getList().get(1))));
+// System.out.println("Result = " + thisList.get(0));
+ return thisList;
+ } else if (theSize == 1) {
+// System.out.println("Element \n" +
getElementAsString((Element)(thisResource.getList().get(0))));
+ List thisList =
XPath.newInstance("string(//"+hint.getSortBy()+")").selectNodes(getElementAsElement((Element)(thisResource.getList().get(0))));
+// System.out.println("Result = " + thisList.get(0));
+ return thisList;
+ } else {
+ return EMPTY_LIST;
+ }
+ }
/**
* @throws IOException
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]