You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by ro...@apache.org on 2006/07/11 05:58:06 UTC

svn commit: r420698 - in /incubator/abdera/java/trunk: build/ extensions/src/main/java/org/apache/abdera/ext/opensearch/ extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/ extensions/src/main/resources/META-INF/services/ extensions/src/tes...

Author: rooneg
Date: Mon Jul 10 20:58:05 2006
New Revision: 420698

URL: http://svn.apache.org/viewvc?rev=420698&view=rev
Log:
Add support for enough OpenSearch elements to allow you to use Abdera
to parse GData search results.

* build/build.xml: Build and run extension tests for OpenSearch.

[ in extensions/src/main/resources/META-INF/services ]

* org.apache.abdera.factory.ExtensionFactory: Add OpenSearch factory.

[ in extensions/src/main/java/org/apache/abdera/ext/opensearch ]

* OpenSearchConstants.java: New file.
* TotalResults.java: New file.
* StartIndex.java: New file.
* ItemsPerPage.java: New file.
* OpenSearchExtensionFactory.java: New file.

[ in extensions/src/main/java/org/apache/abdera/ext/opensearch/impl ]

* FOMTotalResults.java: New file.
* FOMStartIndex.java: New file.
* FOMItemsPerPage.java: New file.

[ in extensions/src/test/java/org/apache/abdera/test/ext/opensearch ]

* OpenSearchTest.java: New tests.
* TestSuite.java: New test driver.

[ in extensions/src/test/resources ]

* opensearch.xml: Test case for opensearch support.

Added:
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/ItemsPerPage.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/StartIndex.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/TotalResults.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMItemsPerPage.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMStartIndex.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMTotalResults.java
    incubator/abdera/java/trunk/extensions/src/test/
    incubator/abdera/java/trunk/extensions/src/test/java/
    incubator/abdera/java/trunk/extensions/src/test/java/org/
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/OpenSearchTest.java
    incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
    incubator/abdera/java/trunk/extensions/src/test/resources/
    incubator/abdera/java/trunk/extensions/src/test/resources/opensearch.xml
Modified:
    incubator/abdera/java/trunk/build/build.xml
    incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?rev=420698&r1=420697&r2=420698&view=diff
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Mon Jul 10 20:58:05 2006
@@ -33,6 +33,8 @@
   <property name="extensions.src" value="${extensions}/src/main/java" />
   <property name="extensions.resources" value="${extensions}/src/main/resources" />
   <property name="extensions.work" value="${work}/extensions" />
+  <property name="extensions.test.java" value="${extensions}/src/test/java" />
+  <property name="extensions.test.resources" value="${extensions}/src/test/resources" />
   <property name="extensions.jar" value="${dist}/${ant.project.name}.extensions.${version}.jar" />
   <property name="server" value="${basedir}/server" />
   <property name="server.src" value="${server}/src/main/java" />
@@ -119,9 +121,16 @@
            destdir="${extensions.work}"
            classpathref="jar.dependencies"
            classpath="${core.work};${parser.work}" />
+    <javac srcdir="${extensions.test.java}"
+           destdir="${test}"
+           classpathref="jar.dependencies"
+           classpath="${core.work};${parser.work};${extensions.work}" />
     <copy todir="${extensions.work}">
       <fileset dir="${extensions.resources}" includes="**/*" />
     </copy>
+    <copy todir="${test}">
+      <fileset dir="${extensions.test.resources}" includes="**/*" />
+    </copy>
   </target>
   
   <target name="compile.server" depends="init, compile.core">
@@ -155,6 +164,12 @@
     <java classpathref="jar.dependencies" 
           classpath="${core.work}:${parser.work}:${server.work}:${test}"
           classname="org.apache.abdera.test.parser.stax.TestSuite"
+          fork="yes" />
+
+    <echo>Running Extension Tests...</echo>
+    <java classpathref="jar.dependencies"
+          classpath="${core.work}:${parser.work}:${server.work}:${extensions.work}:${test}"
+          classname="org.apache.abdera.test.ext.opensearch.TestSuite"
           fork="yes" />
   </target>
 

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/ItemsPerPage.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/ItemsPerPage.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/ItemsPerPage.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/ItemsPerPage.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch;
+
+import org.apache.abdera.model.Element;
+
+public interface ItemsPerPage extends Element {
+  public int getCount();
+
+  public void setCount(int count);
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,34 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch;
+
+import javax.xml.namespace.QName;
+
+public final class OpenSearchConstants {
+  private OpenSearchConstants() {}
+
+  public static final String OPENSEARCH_NS = "http://a9.com/-/spec/opensearchrss/1.0/";
+
+  public static final String TOTAL_RESULTS_LN  = "totalResults";
+  public static final String ITEMS_PER_PAGE_LN = "itemsPerPage";
+  public static final String START_INDEX_LN    = "startIndex";
+
+  public static final QName TOTAL_RESULTS  = new QName(OPENSEARCH_NS, TOTAL_RESULTS_LN);
+  public static final QName ITEMS_PER_PAGE = new QName(OPENSEARCH_NS, ITEMS_PER_PAGE_LN);
+  public static final QName START_INDEX    = new QName(OPENSEARCH_NS, START_INDEX_LN);
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,84 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch;
+
+import org.apache.abdera.factory.ExtensionFactory;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.parser.stax.FOMExtensionFactory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Base;
+import org.apache.abdera.ext.opensearch.impl.FOMTotalResults;
+import org.apache.abdera.ext.opensearch.impl.FOMItemsPerPage;
+import org.apache.abdera.ext.opensearch.impl.FOMStartIndex;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+import javax.xml.namespace.QName;
+
+public class OpenSearchExtensionFactory implements ExtensionFactory, FOMExtensionFactory {
+  public boolean handlesNamespace(String ns)
+  {
+    return OpenSearchConstants.OPENSEARCH_NS.equals(ns);
+  }
+
+  public String getNamespace()
+  {
+    return OpenSearchConstants.OPENSEARCH_NS;
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T extends Element> T newExtensionElement(QName qname,
+                                                   Base base,
+                                                   Factory factory)
+  {
+    if (OpenSearchConstants.TOTAL_RESULTS.equals(qname)) {
+      return (T) new FOMTotalResults(qname, (OMContainer) base, (OMFactory) factory);
+    }
+    else if (OpenSearchConstants.ITEMS_PER_PAGE.equals(qname)) {
+      return (T) new FOMItemsPerPage(qname, (OMContainer) base, (OMFactory) factory);
+    }
+    else if (OpenSearchConstants.START_INDEX.equals(qname)) {
+      return (T) new FOMStartIndex(qname, (OMContainer) base, (OMFactory) factory);
+    }
+    else {
+      return null;
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T extends Element> T newExtensionElement(QName qname,
+                                                   Base base,
+                                                   Factory factory,
+                                                   OMXMLParserWrapper parserWrapper)
+  {
+    if (OpenSearchConstants.TOTAL_RESULTS.equals(qname)) {
+      return (T) new FOMTotalResults(qname, (OMContainer) base, (OMFactory) factory, parserWrapper);
+    }
+    else if (OpenSearchConstants.ITEMS_PER_PAGE.equals(qname)) {
+      return (T) new FOMItemsPerPage(qname, (OMContainer) base, (OMFactory) factory, parserWrapper);
+    }
+    else if (OpenSearchConstants.START_INDEX.equals(qname)) {
+      return (T) new FOMStartIndex(qname, (OMContainer) base, (OMFactory) factory, parserWrapper);
+    }
+    else {
+      return null;
+    }
+  }
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/StartIndex.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/StartIndex.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/StartIndex.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/StartIndex.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch;
+
+import org.apache.abdera.model.Element;
+
+public interface StartIndex extends Element {
+  public int getIndex();
+
+  public void setIndex(int idx);
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/TotalResults.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/TotalResults.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/TotalResults.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/TotalResults.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch;
+
+import org.apache.abdera.model.Element;
+
+public interface TotalResults extends Element {
+  public int getCount();
+
+  public void setCount(int count);
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMItemsPerPage.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMItemsPerPage.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMItemsPerPage.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMItemsPerPage.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch.impl;
+
+import org.apache.abdera.parser.stax.FOMElement;
+
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.ext.opensearch.ItemsPerPage;
+import org.apache.abdera.factory.Factory;
+
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMException;
+
+import javax.xml.namespace.QName;
+
+public class FOMItemsPerPage extends FOMElement implements ItemsPerPage {
+  public FOMItemsPerPage()
+  {
+    super(OpenSearchConstants.ITEMS_PER_PAGE, null, (OMFactory) Factory.INSTANCE);
+  }
+
+  public FOMItemsPerPage(String name,
+                         OMNamespace namespace,
+                         OMContainer parent,
+                         OMFactory factory)
+    throws OMException
+  {
+    super(name, namespace, parent, factory);
+  }
+
+  public FOMItemsPerPage(QName qname,
+                         OMContainer parent,
+                         OMFactory factory)
+  {
+    super(qname, parent, factory);
+  }
+
+  public FOMItemsPerPage(OMContainer parent,
+                         OMFactory factory)
+    throws OMException
+  {
+    super(OpenSearchConstants.ITEMS_PER_PAGE, parent, factory);
+  }
+
+  public FOMItemsPerPage(QName qname,
+                         OMContainer parent,
+                         OMFactory factory,
+                         OMXMLParserWrapper builder)
+    throws OMException
+  {
+    super(qname, parent, factory, builder);
+  }
+
+  public int getCount()
+  {
+    return Integer.parseInt(getText());
+  }
+
+  public void setCount(int count)
+  {
+    setText(String.valueOf(count));
+  }
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMStartIndex.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMStartIndex.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMStartIndex.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMStartIndex.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch.impl;
+
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.ext.opensearch.StartIndex;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.parser.stax.FOMElement;
+
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+import javax.xml.namespace.QName;
+
+public class FOMStartIndex extends FOMElement implements StartIndex {
+  public FOMStartIndex()
+  {
+    super(OpenSearchConstants.START_INDEX, null, (OMFactory) Factory.INSTANCE);
+  }
+
+  public FOMStartIndex(String name,
+                       OMNamespace namespace,
+                       OMContainer parent,
+                       OMFactory factory)
+    throws OMException
+  {
+    super(name, namespace, parent, factory);
+  }
+
+  public FOMStartIndex(QName qname,
+                       OMContainer parent,
+                       OMFactory factory)
+  {
+    super(qname, parent, factory);
+  }
+
+  public FOMStartIndex(OMContainer parent,
+                       OMFactory factory)
+    throws OMException
+  {
+    super(OpenSearchConstants.START_INDEX, parent, factory);
+  }
+
+  public FOMStartIndex(QName qname,
+                       OMContainer parent,
+                       OMFactory factory,
+                       OMXMLParserWrapper builder)
+    throws OMException
+  {
+    super(qname, parent, factory, builder);
+  }
+
+  public int getIndex()
+  {
+    return Integer.parseInt(getText());
+  }
+
+  public void setIndex(int idx)
+  {
+    setText(String.valueOf(idx));
+  }
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMTotalResults.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMTotalResults.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMTotalResults.java (added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/opensearch/impl/FOMTotalResults.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch.impl;
+
+import org.apache.abdera.parser.stax.FOMElement;
+
+import org.apache.abdera.ext.opensearch.TotalResults;
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.factory.Factory;
+
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMException;
+
+import javax.xml.namespace.QName;
+
+public class FOMTotalResults extends FOMElement implements TotalResults {
+  public FOMTotalResults()
+  {
+    super(OpenSearchConstants.TOTAL_RESULTS, null, (OMFactory) Factory.INSTANCE);
+  }
+
+  public FOMTotalResults(String name,
+                         OMNamespace namespace,
+                         OMContainer parent,
+                         OMFactory factory)
+    throws OMException
+  {
+    super(name, namespace, parent, factory);
+  }
+
+  public FOMTotalResults(QName qname,
+                         OMContainer parent,
+                         OMFactory factory)
+  {
+    super(qname, parent, factory);
+  }
+
+  public FOMTotalResults(OMContainer parent,
+                         OMFactory factory)
+    throws OMException
+  {
+    super(OpenSearchConstants.TOTAL_RESULTS, parent, factory);
+  }
+
+  public FOMTotalResults(QName qname,
+                         OMContainer parent,
+                         OMFactory factory,
+                         OMXMLParserWrapper builder)
+    throws OMException
+  {
+    super(qname, parent, factory, builder);
+  }
+
+  public int getCount()
+  {
+    return Integer.parseInt(getText());
+  }
+
+  public void setCount(int count)
+  {
+    setText(String.valueOf(count));
+  }
+}

Modified: incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory?rev=420698&r1=420697&r2=420698&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory (original)
+++ incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory Mon Jul 10 20:58:05 2006
@@ -1 +1,2 @@
-org.apache.abdera.ext.thread.ThreadExtensionFactory
\ No newline at end of file
+org.apache.abdera.ext.thread.ThreadExtensionFactory
+org.apache.abdera.ext.opensearch.OpenSearchExtensionFactory
\ No newline at end of file

Added: incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/OpenSearchTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/OpenSearchTest.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/OpenSearchTest.java (added)
+++ incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/OpenSearchTest.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,52 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.ext.opensearch;
+
+import junit.framework.TestCase;
+
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Document;
+
+import org.apache.abdera.parser.Parser;
+
+import org.apache.abdera.ext.opensearch.TotalResults;
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.ext.opensearch.ItemsPerPage;
+import org.apache.abdera.ext.opensearch.StartIndex;
+
+import java.io.InputStream;
+
+public class OpenSearchTest extends TestCase {
+  public void testBasics()
+  {
+    InputStream stream = OpenSearchTest.class.getResourceAsStream("/opensearch.xml");
+    Document<Element> doc = Parser.INSTANCE.parse(stream);
+
+    TotalResults tr = doc.getRoot().getFirstChild(OpenSearchConstants.TOTAL_RESULTS);
+    assertNotNull(tr);
+    assertEquals(tr.getCount(), 47);
+
+    ItemsPerPage ipp = doc.getRoot().getFirstChild(OpenSearchConstants.ITEMS_PER_PAGE);
+    assertNotNull(ipp);
+    assertEquals(ipp.getCount(), 1);
+
+    StartIndex si = doc.getRoot().getFirstChild(OpenSearchConstants.START_INDEX);
+    assertNotNull(si);
+    assertEquals(si.getIndex(), 1);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java (added)
+++ incubator/abdera/java/trunk/extensions/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java Mon Jul 10 20:58:05 2006
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.ext.opensearch;
+
+import org.apache.abdera.test.ext.opensearch.*;
+
+public class TestSuite extends junit.framework.TestSuite {
+  public static void main(String[] args)
+  {
+    junit.textui.TestRunner.run(new TestSuite());
+  }
+
+  public TestSuite()
+  {
+    addTestSuite(OpenSearchTest.class);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/src/test/resources/opensearch.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/test/resources/opensearch.xml?rev=420698&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/test/resources/opensearch.xml (added)
+++ incubator/abdera/java/trunk/extensions/src/test/resources/opensearch.xml Mon Jul 10 20:58:05 2006
@@ -0,0 +1,21 @@
+<feed xmlns="http://www.w3.org/2005/Atom"
+      xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
+  <title>An OpenSearch Example</title>
+  <link href="http://example.com/opensearch+example"/>
+  <updated>1978-12-13T18:30:02Z</updated>
+  <author>
+    <name>Garrett Rooney</name>
+  </author>
+  <id>http;//example.com/opensearch+example</id>
+  <opensearch:totalResults>47</opensearch:totalResults>
+  <opensearch:startIndex>1</opensearch:startIndex>
+  <opensearch:itemsPerPage>1</opensearch:itemsPerPage>
+  <entry>
+    <title>The entry's title</title>
+    <id>http://example.com/opensearch+example/entry</id>
+    <updated>2003-11-13T18:30:02Z</updated>
+    <content type="text">
+      Some content goes here...
+    </content>
+  </entry>
+</feed>