abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r718752 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ extensions/opensearch/ extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/ extensions/opensearch/src/test/java/org/apache/abdera/t...
Date Tue, 18 Nov 2008 22:50:47 GMT
Author: calavera
Date: Tue Nov 18 14:50:46 2008
New Revision: 718752

URL: http://svn.apache.org/viewvc?rev=718752&view=rev
Log:
[ABDERA-194]: FOMXPath selectNodes() accepts a Base argument but requires an Axiom object
to work properly.
now FOMXPath class uses the internal element when the base parameter is an ElementWrapper.

I've also fixed some compilation problems due to having a method in two interfaces that accept
the same parameters but return different types.



Added:
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/TestSelectNodes.java
Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
    incubator/abdera/java/trunk/extensions/opensearch/pom.xml
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java?rev=718752&r1=718751&r2=718752&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java Tue
Nov 18 14:50:46 2008
@@ -218,7 +218,7 @@
    * Set the Text value of this element
    * @param text The text value
    */
-  <T extends Element>T setText(String text);
+  void setText(String text);
   
   /**
    * Set the Text value of this element using the data handler

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java?rev=718752&r1=718751&r2=718752&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
Tue Nov 18 14:50:46 2008
@@ -206,9 +206,8 @@
     return (T)this;
   }
 
-  public <T extends Element>T setText(String text) {
+  public void setText(String text) {
     internal.setText(text);
-    return (T)this;
   }
 
   public <T extends Element>T setText(DataHandler handler) {

Modified: incubator/abdera/java/trunk/extensions/opensearch/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/pom.xml?rev=718752&r1=718751&r2=718752&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/pom.xml (original)
+++ incubator/abdera/java/trunk/extensions/opensearch/pom.xml Tue Nov 18 14:50:46 2008
@@ -64,5 +64,11 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+        <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-json</artifactId>
+      <version>0.5.0-incubating-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency> 
     </dependencies>
 </project>

Modified: incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java?rev=718752&r1=718751&r2=718752&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
(original)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
Tue Nov 18 14:50:46 2008
@@ -19,6 +19,7 @@
 
 import org.apache.abdera.test.ext.opensearch.model.OpenSearchAtomTest;
 import org.apache.abdera.test.ext.opensearch.model.OpenSearchDescriptionTest;
+import org.apache.abdera.test.ext.opensearch.model.TestSelectNodes;
 import org.apache.abdera.test.ext.opensearch.server.impl.AbstractOpenSearchUrlAdapterTest;
 import org.apache.abdera.test.ext.opensearch.server.impl.SimpleOpenSearchInfoTest;
 import org.apache.abdera.test.ext.opensearch.server.processors.OpenSearchDescriptionRequestProcessorTest;
@@ -36,6 +37,7 @@
       AbstractOpenSearchUrlAdapterTest.class,
       SimpleOpenSearchInfoTest.class,
       OpenSearchDescriptionRequestProcessorTest.class,
-      OpenSearchUrlRequestProcessorTest.class);
+      OpenSearchUrlRequestProcessorTest.class,
+      TestSelectNodes.class);
   }
 }
\ No newline at end of file

Added: incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/TestSelectNodes.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/TestSelectNodes.java?rev=718752&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/TestSelectNodes.java
(added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/TestSelectNodes.java
Tue Nov 18 14:50:46 2008
@@ -0,0 +1 @@
+package org.apache.abdera.test.ext.opensearch.model;

import java.io.IOException;
import
java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;

import org.apache.abdera.Abdera;
import
org.apache.abdera.ext.opensearch.OpenSearchConstants;
import org.apache.abdera.ext.opensearch.model.IntegerElement;
import
org.apache.abdera.model.Feed;
import org.apache.abdera.writer.Writer;
import org.apache.abdera.xpath.XPath;
import
org.junit.Assert;
import org.junit.Test;


public class TestSelectNodes extends Assert{
	
@Test
	public void testXPath() throws IOException {
		Feed f = Abdera.getInstance().newFeed();
	IntegerElement ext = f.addExtension(OpenSearchConstants.START_INDEX);
		ext.setValue(101);
	XPath path = Abdera.getNewXPath();
		List result = path.selectNodes("node()", ext);
		assertTrue(result.size()
> 0);
	}
	
	@Test
	public void testJson() throws IOException {
		Abdera abdera = Abdera.getInstance();
	Feed f = abdera.newFeed();
		IntegerElement ext = f
 .addExtension(OpenSearchConstants.START_INDEX);
		ext.setValue(101);
		Writer json = abdera.getWriterFactory().getWriter("json");
	
		StringWriter stWriter = new StringWriter();
		PrintWriter pWriter = new PrintWriter(stWriter);
	f.writeTo(json, pWriter);
		assertTrue(stWriter.toString().contains("101"));
		assertTrue(stWriter.toString().contains("os:startIndex"));
}
	
}
\ No newline at end of file

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=718752&r1=718751&r2=718752&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Tue Nov 18 14:50:46 2008
@@ -516,7 +516,7 @@
     return text;
   }
   
-  public <T extends Element>T setText(String text) {
+  public void setText(String text) {
     complete();
     if (text != null) {
       OMNode child = this.getFirstOMChild();
@@ -529,7 +529,7 @@
       getOMFactory().createOMText(this, text);
     } else 
       _removeAllChildren();
-    return (T)this;
+    //return (T)this;
   }
 
   public String getText() {

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java?rev=718752&r1=718751&r2=718752&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
Tue Nov 18 14:50:46 2008
@@ -25,6 +25,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.abdera.model.Base;
+import org.apache.abdera.model.ElementWrapper;
 import org.apache.abdera.parser.stax.util.ResolveFunction;
 import org.apache.abdera.util.AbstractXPath;
 import org.apache.abdera.xpath.XPathException;
@@ -157,6 +158,7 @@
     Map<QName,Object> variables) 
       throws XPathException {
     try {
+      base = getElementWrapped(base);
       List nodes = new ArrayList();
       XPath xpath = getXPath(path, namespaces, functions, variables);
       List results = xpath.selectNodes(base);
@@ -187,6 +189,7 @@
     Map<QName,Function> functions,
     Map<QName,Object> variables) throws XPathException {
     try {
+      base = getElementWrapped(base);
       XPath xpath = getXPath(path, namespaces, functions, variables);
       Object obj = xpath.selectSingleNode(base);
       if (obj instanceof OMAttribute) obj = new FOMAttribute((OMAttribute) obj);
@@ -210,6 +213,7 @@
     Map<QName,Function> functions,
     Map<QName,Object> variables) throws XPathException {
     try {
+      base = getElementWrapped(base);
       XPath xpath = getXPath(path, namespaces, functions, variables);
       return xpath.evaluate(base);
     } catch (JaxenException e) {
@@ -232,6 +236,7 @@
     Map<QName,Object> variables) 
       throws XPathException {
     try {
+      base = getElementWrapped(base);
       XPath xpath = getXPath(path, namespaces, functions, variables);
       return xpath.stringValueOf(base);
     } catch (JaxenException e) {
@@ -255,6 +260,7 @@
     Map<QName,Object> variables) 
       throws XPathException {
     try {
+      base = getElementWrapped(base);
       XPath xpath = getXPath(path, namespaces, functions, variables);
       return xpath.booleanValueOf(base);
     } catch (JaxenException e) {
@@ -278,6 +284,7 @@
     Map<QName,Object> variables) 
       throws XPathException {
     try {
+      base = getElementWrapped(base);
       XPath xpath = getXPath(path, namespaces, functions, variables);
       return xpath.numberValueOf(base);
     } catch (JaxenException e) {
@@ -310,4 +317,11 @@
     this.variables.clear();
     this.variables.putAll(variables);
   }
+  
+  private Base getElementWrapped(Base base) {
+	  if (base instanceof ElementWrapper) {
+		  base = ((ElementWrapper)base).getInternal();
+	  }
+	  return base;
+  }
 }



Mime
View raw message