abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r423144 - in /incubator/abdera/java/branches/0.1.0: ./ build/ core/src/main/java/org/apache/abdera/factory/ core/src/main/java/org/apache/abdera/model/ dependencies/ dependencies/json/ dependencies/json/src/ dependencies/json/src/main/ depe...
Date Tue, 18 Jul 2006 17:32:13 GMT
Author: jmsnell
Date: Tue Jul 18 10:32:11 2006
New Revision: 423144

URL: http://svn.apache.org/viewvc?rev=423144&view=rev
Log:
Updating the branch to reflect the latest changes (json build in maven, performance fixes).  I will reroll the zips
in a few minutes

Added:
    incubator/abdera/java/branches/0.1.0/dependencies/json/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/
    incubator/abdera/java/branches/0.1.0/dependencies/json/pom.xml
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/pom.xml
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/src/
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/CDL.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/CDL.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/Cookie.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/Cookie.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/CookieList.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/CookieList.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/HTTP.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/HTTP.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/HTTPTokener.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/HTTPTokener.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONArray.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONArray.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONException.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONException.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONObject.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONObject.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONString.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONString.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONStringer.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONStringer.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONTokener.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONTokener.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/JSONWriter.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/JSONWriter.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/Test.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/Test.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/XML.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/XML.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/java/org/json/XMLTokener.java
      - copied unchanged from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/java/org/json/XMLTokener.java
    incubator/abdera/java/branches/0.1.0/dependencies/json/src/main/resources/
      - copied from r423138, incubator/abdera/java/trunk/dependencies/json/src/main/resources/
Removed:
    incubator/abdera/java/branches/0.1.0/dependencies/src/
Modified:
    incubator/abdera/java/branches/0.1.0/build/build.xml
    incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/factory/Factory.java
    incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/model/Content.java
    incubator/abdera/java/branches/0.1.0/dependencies/   (props changed)
    incubator/abdera/java/branches/0.1.0/docs/building.html
    incubator/abdera/java/branches/0.1.0/docs/gettingstarted.html
    incubator/abdera/java/branches/0.1.0/docs/index.html
    incubator/abdera/java/branches/0.1.0/extensions/pom.xml
    incubator/abdera/java/branches/0.1.0/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java
    incubator/abdera/java/branches/0.1.0/parser/pom.xml
    incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
    incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java
    incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/util/PeekAheadInputStream.java
    incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java
    incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
    incubator/abdera/java/branches/0.1.0/pom.xml

Modified: incubator/abdera/java/branches/0.1.0/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/build/build.xml?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/build/build.xml (original)
+++ incubator/abdera/java/branches/0.1.0/build/build.xml Tue Jul 18 10:32:11 2006
@@ -51,11 +51,12 @@
       
   <property name="dependencies" value="${basedir}/dependencies" />
   <property name="dependencies.work" value="${dependencies}/work" />
-  <property name="dependencies.src" value="${dependencies}/src" />
-  <property name="dependencies.src.java"
-            value="${dependencies.src}/main/java" />
+  <property name="json.src" value="${dependencies}/json/src" />
+  <property name="json.src.java"
+            value="${json.src}/main/java" />
+  <property name="json.version" value="1.0" />
 
-  <property name="json.jar" value="${dependencies}/json.jar" />
+  <property name="json.jar" value="${dependencies}/json-${json.version}.jar" />
 
   <property file="${dependencies}/deps.properties" />
   
@@ -64,13 +65,17 @@
   </path>
  
   <target name="compile.dependencies">
-    <mkdir dir="${dependencies.work}" />
+    <mkdir dir="${dependencies.work}/json" />
 
-    <javac srcdir="${dependencies.src.java}" destdir="${dependencies.work}" />
+    <!-- build json -->
+    <javac srcdir="${json.src.java}" destdir="${dependencies.work}/json" />
 
     <jar destfile="${json.jar}"
-         basedir="${dependencies.work}"
+         basedir="${dependencies.work}/json"
          includes="org/json/*.class" />
+    
+    <delete dir="${dependencies.work}" />
+    
   </target>
  
   <target name="dependencies">
@@ -266,6 +271,7 @@
       <fileset dir="${dist}">
         <include name="**/*.jar" />
         <include name="**/legal/*" />
+        <exclude name="**/json/*" />
         <exclude name="**/*.retro.jar" />
         <exclude name="**/retroweaver-rt-1.2.3.jar" />
       </fileset>
@@ -280,6 +286,7 @@
         <fileset dir="${dist}">
           <include name="**/*.jar" />
           <include name="**/legal/*" />
+          <exclude name="**/json/*" />
           <exclude name="**/*.${version}.jar" />
         </fileset>
         <fileset dir="${docs}" includes="**/*" />

Modified: incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/factory/Factory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/factory/Factory.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/factory/Factory.java (original)
+++ incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/factory/Factory.java Tue Jul 18 10:32:11 2006
@@ -222,11 +222,5 @@
    * Registers an extension factory for this Factory instance only
    */
   void registerExtension(ExtensionFactory extensionFactory);
-  
-  /**
-   * Registers an alternative implementation class for the specified base
-   * for this Factory instance.  The alternative MUST extend the base
-   */
-  <T extends Base>void registerAlternative(Class<T> base, Class<? extends T> alternative);
-  
+    
 }

Modified: incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/model/Content.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/model/Content.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/model/Content.java (original)
+++ incubator/abdera/java/branches/0.1.0/core/src/main/java/org/apache/abdera/model/Content.java Tue Jul 18 10:32:11 2006
@@ -102,7 +102,7 @@
 
   public enum Type { 
     TEXT, HTML, XHTML, XML, MEDIA;
-  
+    
     public static Type typeFromString(String val) {
       Type type = TEXT;
       if (val != null) {

Propchange: incubator/abdera/java/branches/0.1.0/dependencies/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jul 18 10:32:11 2006
@@ -1,4 +1,6 @@
+
 work
 .classpath
 .project
 *.jar
+bin

Modified: incubator/abdera/java/branches/0.1.0/docs/building.html
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/docs/building.html?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/docs/building.html (original)
+++ incubator/abdera/java/branches/0.1.0/docs/building.html Tue Jul 18 10:32:11 2006
@@ -9,7 +9,7 @@
   <!-- Header -->
   <div id="banner">
     <h1><a href="http://incubator.apache.org/abdera">Apache Abdera</a></h1>
-    <p>Version 0.1-SNAPSHOT (Incubating)</p>
+    <p>Version 0.1 (Incubating)</p>
     <hr/>
   </div>
   <div id="divider"></div>

Modified: incubator/abdera/java/branches/0.1.0/docs/gettingstarted.html
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/docs/gettingstarted.html?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/docs/gettingstarted.html (original)
+++ incubator/abdera/java/branches/0.1.0/docs/gettingstarted.html Tue Jul 18 10:32:11 2006
@@ -8,7 +8,7 @@
   <!-- Header -->
   <div id="banner">
     <h1><a href="http://incubator.apache.org/abdera">Apache Abdera</a></h1>
-    <p>Version 0.1-SNAPSHOT (Incubating)</p>
+    <p>Version 0.1 (Incubating)</p>
     <hr/>
   </div>
   <div id="divider"></div>

Modified: incubator/abdera/java/branches/0.1.0/docs/index.html
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/docs/index.html?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/docs/index.html (original)
+++ incubator/abdera/java/branches/0.1.0/docs/index.html Tue Jul 18 10:32:11 2006
@@ -12,7 +12,7 @@
 <body>
   <div id="banner">
     <h1><a href="http://incubator.apache.org/abdera">Apache Abdera</a></h1>
-    <p>Version 0.1-SNAPSHOT (Incubating)</p>
+    <p>Version 0.1 (Incubating)</p>
     <hr/>
   </div>
   <div id="divider"></div>

Modified: incubator/abdera/java/branches/0.1.0/extensions/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/extensions/pom.xml?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/extensions/pom.xml (original)
+++ incubator/abdera/java/branches/0.1.0/extensions/pom.xml Tue Jul 18 10:32:11 2006
@@ -29,6 +29,12 @@
       <scope>compile</scope>
     </dependency>   
     <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>json</artifactId>
+      <version>1.0</version>
+      <scope>compile</scope>
+    </dependency>   
+    <dependency>
       <groupId>ws-commons</groupId>
       <artifactId>axiom-api</artifactId>
     </dependency>
@@ -45,7 +51,7 @@
       <artifactId>stax</artifactId>
     </dependency>
     <dependency>
-      <groupId>wstx</groupId>
+      <groupId>woodstox</groupId>
       <artifactId>wstx-asl</artifactId>
     </dependency> 
   </dependencies>

Modified: incubator/abdera/java/branches/0.1.0/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java (original)
+++ incubator/abdera/java/branches/0.1.0/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java Tue Jul 18 10:32:11 2006
@@ -26,6 +26,7 @@
 import org.apache.abdera.model.Category;
 import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.model.Generator;
@@ -79,6 +80,8 @@
       return toJSON((Entry) object);
     } else if(object instanceof Service) {
       return toJSON((Service) object);
+    } else if(object instanceof Document) {
+      return toJSON(((Document)object).getRoot());
     }
     return new IllegalArgumentException("Element is not supported by JSONWriter.");
   }
@@ -109,12 +112,21 @@
     
     JSONArray jscategories = new JSONArray();
     List<Category> categories = entry.getCategories();
-    for(Category category : categories) {
-      JSONObject jscategory = new JSONObject();
-      jscategory.put("scheme", category.getScheme().toString());
-      jscategory.put("term", category.getTerm());
-      jscategory.put("label", category.getLabel());
-      jscategories.put(jscategory);
+    for(Category category : categories) {      
+      if(category.getScheme() != null || 
+          category.getLabel() != null ||
+          category.getTerm() != null) {
+        JSONObject jscategory = new JSONObject();
+        if(category.getScheme() != null)
+          jscategory.put("scheme", category.getScheme().toString());
+        
+        if(category.getTerm() != null)
+          jscategory.put("term", category.getTerm());
+        
+        if(category.getLabel() != null)
+          jscategory.put("label", category.getLabel());
+        jscategories.put(jscategory);
+      }
     }
     jsentry.put("categories", jscategories);
     

Modified: incubator/abdera/java/branches/0.1.0/parser/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/parser/pom.xml?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/parser/pom.xml (original)
+++ incubator/abdera/java/branches/0.1.0/parser/pom.xml Tue Jul 18 10:32:11 2006
@@ -43,7 +43,7 @@
       <artifactId>stax</artifactId>
     </dependency>
     <dependency>
-      <groupId>wstx</groupId>
+      <groupId>woodstox</groupId>
       <artifactId>wstx-asl</artifactId>
     </dependency>
     <dependency>

Modified: incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java (original)
+++ incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java Tue Jul 18 10:32:11 2006
@@ -63,39 +63,8 @@
 
 public class FOMFactory 
   extends OMLinkedListImplFactory 
-  implements Factory, Constants {
+  implements Factory, Constants, ExtensionFactory, FOMExtensionFactory {
 
-  private final static Map<QName,Class> qclasses = new HashMap<QName,Class>();
-  static {
-    qclasses.put(FEED, FOMFeed.class);
-    qclasses.put(SERVICE, FOMService.class);
-    qclasses.put(ENTRY, FOMEntry.class);
-    qclasses.put(AUTHOR, FOMPerson.class);
-    qclasses.put(CATEGORY, FOMCategory.class);
-    qclasses.put(CONTENT, FOMContent.class);
-    qclasses.put(CONTRIBUTOR, FOMPerson.class);
-    qclasses.put(GENERATOR, FOMGenerator.class);
-    qclasses.put(ICON, FOMIRI.class);
-    qclasses.put(ID, FOMIRI.class);
-    qclasses.put(LOGO, FOMIRI.class);
-    qclasses.put(LINK, FOMLink.class);
-    qclasses.put(PUBLISHED, FOMDateTime.class);
-    qclasses.put(RIGHTS, FOMText.class);
-    qclasses.put(SOURCE, FOMSource.class);
-    qclasses.put(SUBTITLE, FOMText.class);
-    qclasses.put(SUMMARY, FOMText.class);
-    qclasses.put(TITLE, FOMText.class);
-    qclasses.put(UPDATED, FOMDateTime.class);
-    qclasses.put(WORKSPACE, FOMWorkspace.class);
-    qclasses.put(COLLECTION, FOMCollection.class);
-    qclasses.put(NAME, FOMElement.class);
-    qclasses.put(EMAIL, FOMElement.class);
-    qclasses.put(URI, FOMIRI.class);
-    qclasses.put(CONTROL, FOMControl.class);
-    qclasses.put(DIV, FOMDiv.class);
-  }
-  
-  private Map<Class,Class> alternatives = null;
   private Map<QName,Class> extensions = null;
   private List<ExtensionFactory> factories = null;
   
@@ -105,13 +74,13 @@
   
   @SuppressWarnings("unchecked")
   public <T extends Element>Document<T> newDocument() {
-    return _newInstance(FOMDocument.class, CONSTRUCTORS[8], this);
+    return new FOMDocument(this);
   }
   
   @SuppressWarnings("unchecked")
   public <T extends Element>Document<T> newDocument(
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMDocument.class, CONSTRUCTORS[9], this, parserWrapper);
+      return new FOMDocument(parserWrapper, this);
   }
   
   @SuppressWarnings("unchecked")
@@ -127,19 +96,19 @@
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMService.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMService(qname, parent, this, parserWrapper);
   }
 
   public Service newService(
     Base parent) {
-      return _newInstance(FOMService.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMService((OMContainer) parent,this);
   }
 
   public Workspace newWorkspace(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMWorkspace.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMWorkspace(qname,parent, this, parserWrapper);
   }
   
   public Workspace newWorkspace() {
@@ -148,14 +117,14 @@
   
   public Workspace newWorkspace(
     Element parent) {
-      return _newInstance(FOMWorkspace.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMWorkspace((OMContainer)parent, this);
   }
 
   public Collection newCollection(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMCollection.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMCollection(qname, parent, this, parserWrapper);
   }
   
   public Collection newCollection() {
@@ -164,7 +133,7 @@
   
   public Collection newCollection(
     Element parent) {
-      return _newInstance(FOMCollection.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMCollection((OMContainer)parent,this);
   }
 
   public Feed newFeed() {
@@ -186,31 +155,31 @@
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMFeed.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMFeed(qname,parent,this,parserWrapper);
   }
   
   public Feed newFeed(
     Base parent) {
-      return _newInstance(FOMFeed.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMFeed((OMContainer)parent,this);
   }
 
   public Entry newEntry(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMEntry.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMEntry(qname,parent,this,parserWrapper);
   }
   
   public Entry newEntry(
     Base parent) {
-      return _newInstance(FOMEntry.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMEntry((OMContainer)parent,this);
   }
 
   public Category newCategory(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMCategory.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMCategory(qname,parent,this,parserWrapper);
   }
   
   public Category newCategory() {
@@ -219,7 +188,7 @@
   
   public Category newCategory(
     Element parent) {
-      return _newInstance(FOMCategory.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMCategory((OMContainer)parent,this);
   }
 
   public Content newContent(
@@ -228,8 +197,7 @@
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
       if (type == null) type = Content.Type.TEXT;
-      return _newInstance(FOMContent.class, CONSTRUCTORS[2], 
-          qname, type, parent, this, parserWrapper);
+      return new FOMContent(qname,type,parent,this,parserWrapper);
   }
   
   public Content newContent() {
@@ -246,8 +214,7 @@
     Element parent) {
       if (type == null) type = Content.Type.TEXT;
       Content content = 
-        _newInstance(
-          FOMContent.class, CONSTRUCTORS[3], type, (OMContainer)parent, this);
+        new FOMContent(type, (OMContainer)parent,this);
       try {
         if (type.equals(Content.Type.XML))
           content.setMimeType("application/xml");
@@ -276,20 +243,20 @@
     QName qname,
     OMContainer parent,
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMDateTime.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMDateTime(qname,parent,this,parserWrapper);
   }
   
   public DateTime newDateTime(
     QName qname, 
     Element parent) {
-      return _newInstance(FOMDateTime.class, CONSTRUCTORS[4], qname, (OMContainer)parent, this);
+      return new FOMDateTime(qname, (OMContainer)parent,this);
   }
 
   public Generator newGenerator(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMGenerator.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMGenerator(qname,parent,this,parserWrapper);
   }
   
   public Generator newDefaultGenerator() {
@@ -313,14 +280,14 @@
   
   public Generator newGenerator(
       Element parent) {
-    return _newInstance(FOMGenerator.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+    return new FOMGenerator((OMContainer)parent,this);
   }
 
   public IRI newID(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMIRI.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMIRI(qname,parent,this,parserWrapper);
   }
   
   public IRI newID() {
@@ -329,31 +296,27 @@
   
   public IRI newID(
     Element parent) {
-      return _newInstance(
-          FOMIRI.class, CONSTRUCTORS[4], 
-          Constants.ID, (OMContainer)parent, this);
+      return new FOMIRI(Constants.ID, (OMContainer)parent, this);
   }
 
   public IRI newURIElement(
     QName qname,
     OMContainer parent,
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMIRI.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMIRI(qname,parent,this,parserWrapper);
   }
   
   public IRI newIRIElement(
     QName qname, 
     Element parent) {
-      return _newInstance(
-        FOMIRI.class, CONSTRUCTORS[4], 
-        qname, (OMContainer)parent, this);
+      return new FOMIRI(qname, (OMContainer)parent, this);
   }
 
   public Link newLink(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMLink.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMLink(qname,parent,this,parserWrapper);
   }
   
   public Link newLink() {
@@ -362,29 +325,27 @@
   
   public Link newLink(
     Element parent) {
-      return _newInstance(FOMLink.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMLink((OMContainer)parent,this);
   }
 
   public Person newPerson(
     QName qname,
     OMContainer parent,
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMPerson.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMPerson(qname, parent, this, parserWrapper);
   }
   
   public Person newPerson(
     QName qname, 
     Element parent) {
-      return _newInstance(
-        FOMPerson.class, CONSTRUCTORS[4], 
-        qname, (OMContainer)parent, this);
+      return new FOMPerson(qname, (OMContainer)parent,this);
   }
 
   public Source newSource(
     QName qname, 
     OMContainer parent, 
-    OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMSource.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+    OMXMLParserWrapper parserWrapper) { 
+      return new FOMSource(qname,parent,this,parserWrapper);
   }
   
   public Source newSource() {
@@ -393,7 +354,7 @@
   
   public Source newSource(
     Element parent) {
-      return _newInstance(FOMSource.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+      return new FOMSource((OMContainer)parent,this);
   }
 
   public Text newText(
@@ -402,8 +363,7 @@
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
     if (type == null) type = Text.Type.TEXT;
-    return _newInstance(FOMText.class, CONSTRUCTORS[5], 
-        type, qname, parent, this, parserWrapper);
+    return new FOMText(type, qname, parent, this, parserWrapper);
   }
   
   public Text newText(
@@ -417,8 +377,7 @@
     Text.Type type, 
     Element parent) {
     if (type == null) type = Text.Type.TEXT;
-    return _newInstance(FOMText.class, CONSTRUCTORS[6], 
-        type, qname,(OMContainer)parent, this);
+    return new FOMText(type, qname, (OMContainer)parent,this);
   }
   
   public Element newElement(QName qname) {
@@ -428,9 +387,7 @@
   public Element newElement(
     QName qname, 
     Base parent) {
-      return _newInstance(
-        FOMElement.class, CONSTRUCTORS[4], 
-        qname, (OMContainer)parent, this);
+      return new FOMElement(qname, (OMContainer)parent,this);
   }
   
   public Element newExtensionElement(QName qname) {
@@ -454,6 +411,7 @@
       factories = new ArrayList<ExtensionFactory>(
         org.apache.abdera.util.ServiceUtil.loadExtensionFactories());
     }
+    factories.add(0, this);
     return factories;
   }
   
@@ -464,52 +422,40 @@
     OMXMLParserWrapper parserWrapper) {
     Element element = null;
     List<ExtensionFactory> factories = getExtensionFactories();
-    Class _class = getExtensionClass(qname);
-    if (_class == null && factories != null) {
-      for (ExtensionFactory factory : factories) {
-        if (factory instanceof FOMExtensionFactory &&
-            factory.handlesNamespace(qname.getNamespaceURI())) {
-            if (parserWrapper != null) {
-              element = ((FOMExtensionFactory)factory).newExtensionElement(
-                qname, (Base)parent, this, parserWrapper);
-            } else {
-              element = factory.newExtensionElement(qname, (Base)parent, this); 
-            }
+    for (ExtensionFactory factory : factories) {
+      if (factory instanceof FOMExtensionFactory &&
+        factory.handlesNamespace(qname.getNamespaceURI())) {
+        if (parserWrapper != null) {
+          element = ((FOMExtensionFactory)factory).newExtensionElement(
+            qname, (Base)parent, this, parserWrapper);
+        } else {
+          element = factory.newExtensionElement(qname, (Base)parent, this); 
         }
       }
     }
-    if (_class == null) _class = FOMElement.class;
     if (element == null) {
-      if (parserWrapper != null) {
-        element = (Element) _newInstance(_class, CONSTRUCTORS[0], qname, (OMContainer)parent, this, parserWrapper);
+      if (parserWrapper == null) {
+        element = new FOMElement(qname, (OMContainer)parent, this);
       } else {
-        element = (Element) _newInstance(
-          _class, CONSTRUCTORS[4], 
-          qname, (OMContainer)parent, this);
+        element = new FOMElement(qname, (OMContainer)parent, this, parserWrapper);
       }
     }
     return element;
   }
   
-  @SuppressWarnings("unchecked")
-  private Class<Base> getExtensionClass(QName qname) {
-    return (extensions != null && extensions.containsKey(qname)) ? 
-      extensions.get(qname) : null;
-  }
-  
   public Control newControl() {
     return newControl(null);
   }
    
   public Control newControl(Element parent) {
-    return _newInstance(FOMControl.class, CONSTRUCTORS[1], (OMContainer)parent, this);
+    return new FOMControl((OMContainer)parent,this);
   }
   
   public Control newControl(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMControl.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMControl(qname, parent,this,parserWrapper);
   }
 
   public DateTime newPublished() {
@@ -654,36 +600,21 @@
   }
   
   public Div newDiv(Base parent) {
-    return _newInstance(
-      FOMDiv.class, CONSTRUCTORS[4], 
-      Constants.DIV, (OMContainer)parent, this);
+    return new FOMDiv(DIV, (OMContainer)parent,this);
   }
   
   public Div newDiv(
     QName qname,
     OMContainer parent, 
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMDiv.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
+      return new FOMDiv(qname,parent,this,parserWrapper);
   }
   
   public Element newElement(
     QName qname,
     OMContainer parent,
     OMXMLParserWrapper parserWrapper) {
-      return _newInstance(FOMElement.class, CONSTRUCTORS[0], qname, parent, this, parserWrapper);
-  }
-
-  
-  
-  private boolean isContent(QName qname) {
-    return CONTENT.equals(qname);
-  }
-  
-  private boolean isText(QName qname) {
-    return TITLE.equals(qname) ||
-           SUMMARY.equals(qname) ||
-           SUBTITLE.equals(qname) ||
-           RIGHTS.equals(qname);
+      return new FOMElement(qname,parent,this,parserWrapper);
   }
   
   @SuppressWarnings("unchecked")
@@ -697,24 +628,63 @@
         this.createOMNamespace(
           qname.getNamespaceURI(), 
           qname.getPrefix());
-      if (qclasses.containsKey(qname)) {
-        if (isContent(qname)) {
-          Content.Type type = (Content.Type)objecttype;
-          element = (OMElement) _newInstance(
-            qclasses.get(qname), CONSTRUCTORS[10], 
-            qname.getLocalPart(), namespace, type, parent, this);
-        } else if (isText(qname)) {
-          Text.Type type = (Text.Type)objecttype;
-          element = (OMElement) _newInstance(
-            qclasses.get(qname), 
-            CONSTRUCTORS[11], 
-            type, qname.getLocalPart(), 
-            namespace, parent, this);
-        } else {
-          element = (OMElement) _newInstance(
-            qclasses.get(qname), CONSTRUCTORS[7], 
-            qname.getLocalPart(), namespace, parent, this);
-        }
+      if (FEED.equals(qname)) {
+        element = (OMElement) new FOMFeed(qname.getLocalPart(), namespace, parent, factory);
+      } else if (SERVICE.equals(qname)) {
+        element = (OMElement) new FOMService(qname.getLocalPart(), namespace, parent, factory);
+      } else if (ENTRY.equals(qname)) {
+        element = (OMElement) new FOMEntry(qname.getLocalPart(), namespace, parent, factory);
+      } else if (AUTHOR.equals(qname)) {
+        element = (OMElement) new FOMPerson(qname.getLocalPart(), namespace, parent, factory);
+      } else if (CATEGORY.equals(qname)) {
+        element = (OMElement) new FOMCategory(qname.getLocalPart(), namespace, parent, factory);
+      } else if (CONTENT.equals(qname)) {
+        Content.Type type = (Content.Type) objecttype;
+        element = (OMElement) new FOMContent(qname.getLocalPart(), namespace, type, parent, factory);
+      } else if (CONTRIBUTOR.equals(qname)) {
+        element = (OMElement) new FOMPerson(qname.getLocalPart(), namespace, parent, factory);
+      } else if (GENERATOR.equals(qname)) {
+        element = (OMElement) new FOMGenerator(qname.getLocalPart(), namespace, parent, factory);
+      } else if (ICON.equals(qname)) {
+        element = (OMElement) new FOMIRI(qname.getLocalPart(), namespace, parent, factory);
+      } else if (ID.equals(qname)) {
+        element = (OMElement) new FOMIRI(qname.getLocalPart(), namespace, parent, factory);
+      } else if (LOGO.equals(qname)) {
+        element = (OMElement) new FOMIRI(qname.getLocalPart(), namespace, parent, factory);
+      } else if (LINK.equals(qname)) {
+        element = (OMElement) new FOMLink(qname.getLocalPart(), namespace, parent, factory);
+      } else if (PUBLISHED.equals(qname)) {
+        element = (OMElement) new FOMDateTime(qname.getLocalPart(), namespace, parent, factory);
+      } else if (RIGHTS.equals(qname)) {
+        Text.Type type = (Text.Type) objecttype;
+        element = (OMElement) new FOMText(type, qname.getLocalPart(), namespace, parent, factory);
+      } else if (SOURCE.equals(qname)) {
+        element = (OMElement) new FOMSource(qname.getLocalPart(), namespace, parent, factory);
+      } else if (SUBTITLE.equals(qname)) {
+        Text.Type type = (Text.Type) objecttype;
+        element = (OMElement) new FOMText(type, qname.getLocalPart(), namespace, parent, factory);
+      } else if (SUMMARY.equals(qname)) {
+        Text.Type type = (Text.Type) objecttype;
+        element = (OMElement) new FOMText(type, qname.getLocalPart(), namespace, parent, factory);
+      } else if (TITLE.equals(qname)) {
+        Text.Type type = (Text.Type) objecttype;
+        element = (OMElement) new FOMText(type, qname.getLocalPart(), namespace, parent, factory);
+      } else if (UPDATED.equals(qname)) {
+        element = (OMElement) new FOMDateTime(qname.getLocalPart(), namespace, parent, factory);          
+      } else if (WORKSPACE.equals(qname)) {
+        element = (OMElement) new FOMWorkspace(qname.getLocalPart(), namespace, parent, factory);
+      } else if (COLLECTION.equals(qname)) {
+        element = (OMElement) new FOMCollection(qname.getLocalPart(), namespace, parent, factory);
+      } else if (NAME.equals(qname)) {
+        element = (OMElement) new FOMElement(qname.getLocalPart(), namespace, parent, factory);
+      } else if (EMAIL.equals(qname)) {
+        element = (OMElement) new FOMElement(qname.getLocalPart(), namespace, parent, factory);
+      } else if (URI.equals(qname)) {
+        element = (OMElement) new FOMIRI(qname.getLocalPart(), namespace, parent, factory);
+      } else if (CONTROL.equals(qname)) {
+        element = (OMElement) new FOMControl(qname.getLocalPart(), namespace, parent, factory);
+      } else if (DIV.equals(qname)) {
+        element = (OMElement) new FOMDiv(qname.getLocalPart(), namespace, parent, factory);
       } else if (parent instanceof ExtensibleElement || 
                  parent instanceof Document) {
         element = (OMElement) newExtensionElement(qname, parent);
@@ -728,26 +698,63 @@
     OMContainer parent, 
     FOMBuilder builder) {
     OMElement element = null;    
-    if (qclasses.containsKey(qname)) {
-      if (isContent(qname)) {
-        Content.Type type = builder.getContentType();
-        element = (OMElement) _newInstance(
-          qclasses.get(qname), CONSTRUCTORS[2], 
-          qname, type, parent, this, builder);
-      } else if (isText(qname)) {
-        Text.Type type = builder.getTextType();
-        element = (OMElement) _newInstance(
-            qclasses.get(qname), CONSTRUCTORS[5], 
-            type, qname, parent, this, builder);
-      } else {
-        element = (OMElement) _newInstance(
-          qclasses.get(qname), 
-          CONSTRUCTORS[0], 
-          qname, 
-          parent, 
-          this, 
-          builder);
-      }
+    if (FEED.equals(qname)) {
+      element = (OMElement) newFeed(qname, parent, builder);
+    } else if (SERVICE.equals(qname)) {
+      element = (OMElement) newService(qname, parent, builder);
+    } else if (ENTRY.equals(qname)) {
+      element = (OMElement) newEntry(qname, parent, builder);
+    } else if (AUTHOR.equals(qname)) {
+      element = (OMElement) newPerson(qname, parent, builder);
+    } else if (CATEGORY.equals(qname)) {
+      element = (OMElement) newCategory(qname, parent, builder);
+    } else if (CONTENT.equals(qname)) {
+      Content.Type type = builder.getContentType();
+      element = (OMElement) newContent(qname, type, parent, builder);
+    } else if (CONTRIBUTOR.equals(qname)) {
+      element = (OMElement) newPerson(qname, parent, builder);
+    } else if (GENERATOR.equals(qname)) {
+      element = (OMElement) newGenerator(qname, parent, builder);
+    } else if (ICON.equals(qname)) {
+      element = (OMElement) newURIElement(qname, parent, builder);
+    } else if (ID.equals(qname)) {
+      element = (OMElement) newID(qname, parent, builder);
+    } else if (LOGO.equals(qname)) {
+      element = (OMElement) newURIElement(qname, parent, builder);
+    } else if (LINK.equals(qname)) {
+      element = (OMElement) newLink(qname, parent, builder);
+    } else if (PUBLISHED.equals(qname)) {
+      element = (OMElement) newDateTimeElement(qname, parent, builder);
+    } else if (RIGHTS.equals(qname)) {
+      Text.Type type = builder.getTextType();
+      element = (OMElement) newText(qname, type, parent, builder);
+    } else if (SOURCE.equals(qname)) {
+      element = (OMElement) newSource(qname, parent, builder);
+    } else if (SUBTITLE.equals(qname)) {
+      Text.Type type = builder.getTextType();
+      element = (OMElement) newText(qname, type, parent, builder);
+    } else if (SUMMARY.equals(qname)) {
+      Text.Type type = builder.getTextType();
+      element = (OMElement) newText(qname, type, parent, builder);
+    } else if (TITLE.equals(qname)) {
+      Text.Type type = builder.getTextType();
+      element = (OMElement) newText(qname, type, parent, builder);
+    } else if (UPDATED.equals(qname)) {
+      element = (OMElement) newDateTimeElement(qname, parent, builder);          
+    } else if (WORKSPACE.equals(qname)) {
+      element = (OMElement) newWorkspace(qname, parent, builder);
+    } else if (COLLECTION.equals(qname)) {
+      element = (OMElement) newCollection(qname, parent, builder);
+    } else if (NAME.equals(qname)) {
+      element = (OMElement) newElement(qname, parent, builder);
+    } else if (EMAIL.equals(qname)) {
+      element = (OMElement) newElement(qname, parent, builder);
+    } else if (URI.equals(qname)) {
+      element = (OMElement) newURIElement(qname, parent, builder);
+    } else if (CONTROL.equals(qname)) {
+      element = (OMElement) newControl(qname, parent, builder);
+    } else if (DIV.equals(qname)) {
+      element = (OMElement) newDiv(qname, parent, builder);
     } else if (parent instanceof ExtensibleElement || parent instanceof Document) {
       element = (OMElement) newExtensionElement(qname, parent, builder);
     }
@@ -762,101 +769,71 @@
   public void registerExtension(ExtensionFactory factory) {
     getExtensionFactories().add(factory);
   }
-  
+
+  public List<String> getNamespaces() {
+    List<String> namespaces = new ArrayList<String>();
+    if (extensions != null) {
+      for (QName qname : extensions.keySet()) {
+        if (!namespaces.contains(qname.getNamespaceURI()))
+          namespaces.add(qname.getNamespaceURI());
+      }
+    }
+    return namespaces;
+  }
+
+  public boolean handlesNamespace(String namespace) {
+    return getNamespaces().contains(namespace);
+  }
+
   @SuppressWarnings("unchecked")
-  public <T extends Base>void registerAlternative(Class<T> base, Class<? extends T> extension) {
-    if (!base.isAssignableFrom(extension))
-      throw new IllegalArgumentException("The extension must extend the base");
-    if (alternatives == null) alternatives = new HashMap<Class,Class>();
-    if (extension != null)
-      alternatives.put(base, extension);
-    else if (alternatives.containsKey(base))
-      alternatives.remove(base);
-  }
-  
-  // Internals for Alternative creation
-  
-  private Class _getAlternative(Class _class) {
-    if (alternatives == null) alternatives = new HashMap<Class,Class>();
-    return (alternatives.containsKey(_class)) ? alternatives.get(_class) : _class;
-  }
-  
-  private static final Class[][] CONSTRUCTORS = {
-    new Class[] {
-      QName.class, 
-      OMContainer.class,
-      OMFactory.class,
-      OMXMLParserWrapper.class},
-    new Class[] {
-      OMContainer.class,
-      OMFactory.class},
-    new Class[] {
-      QName.class,
-      Content.Type.class,
-      OMContainer.class,
-      OMFactory.class,
-      OMXMLParserWrapper.class},
-    new Class[] {
-      Content.Type.class,
-      OMContainer.class,
-      OMFactory.class}, 
-    new Class[] {
-      QName.class,
-      OMContainer.class,
-      OMFactory.class}, 
-    new Class[] {
-      Text.Type.class,
-      QName.class,
-      OMContainer.class,
-      OMFactory.class,
-      OMXMLParserWrapper.class},
-    new Class[] {
-      Text.Type.class,
-      QName.class,
-      OMContainer.class,
-      OMFactory.class},
-    new Class[] {
-      String.class, 
-      OMNamespace.class, 
-      OMContainer.class, 
-      OMFactory.class},
-    new Class[] {
-      OMFactory.class},
-    new Class[] {
-      OMFactory.class,
-      OMXMLParserWrapper.class},
-    new Class[] {
-      String.class, 
-      OMNamespace.class,
-      Content.Type.class,
-      OMContainer.class, 
-      OMFactory.class},
-    new Class[] {
-      Text.Type.class,
-      String.class, 
-      OMNamespace.class, 
-      OMContainer.class, 
-      OMFactory.class}
-  };
-    
-  /**
-   * This likely has some class loader issues we need to be concerned about
-   */
+  public <T extends Element> T newExtensionElement(
+    QName qname, 
+    Base parent, 
+    Factory factory) {
+      if (extensions != null) {
+        Class _class = extensions.get(qname);
+        if (_class != null) {
+          try {
+            return (T)_class.getConstructor(
+              new Class[] {
+                QName.class,
+                OMContainer.class,
+                OMFactory.class}).newInstance(
+                  new Object[] {
+                    qname, 
+                    parent, 
+                    factory});
+          } catch (Exception e) {}
+        }
+      }
+      return null;
+  }
+
   @SuppressWarnings("unchecked")
-  private <T extends Base>T _newInstance(
-    Class<T> _class, 
-    Class[] argtypes, 
-    Object... args) {
-    Class _altclass = _getAlternative(_class);
-    try {
-      return (T) _altclass.getConstructor(argtypes).newInstance(args);
-    } catch (Exception e) {
-      try {
-        return _class.getConstructor(argtypes).newInstance(args);
-      } catch (Exception ex) {
-        ex.printStackTrace();
+  public <T extends Element> T newExtensionElement(
+    QName qname, 
+    Base parent, 
+    Factory factory, 
+    OMXMLParserWrapper parserWrapper) {
+      if (extensions != null) {
+        Class _class = extensions.get(qname);
+        if (_class != null) {
+          try {
+            return (T)_class.getConstructor(
+              new Class[] {
+                QName.class,
+                OMContainer.class,
+                OMFactory.class,
+                OMXMLParserWrapper.class}).newInstance(
+                  new Object[] {
+                    qname, 
+                    parent, 
+                    factory,
+                    parserWrapper});
+          } catch (Exception e) {}
+        }
       }
-    }
-    return null;
+      return null;
   }
+  
 }

Modified: incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java (original)
+++ incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java Tue Jul 18 10:32:11 2006
@@ -18,11 +18,9 @@
 package org.apache.abdera.parser.stax;
 
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URI;
 
-import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.abdera.factory.Factory;
@@ -33,8 +31,8 @@
 import org.apache.abdera.parser.ParserOptions;
 import org.apache.abdera.parser.stax.util.FOMSniffingInputStream;
 import org.apache.abdera.util.AbstractParser;
-//import org.apache.abdera.util.SniffingInputStream;
 import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.util.StAXUtils;
 
 public class FOMParser 
   extends AbstractParser 
@@ -86,14 +84,12 @@
         charset = sin.getEncoding();
         in = sin;
       }
-      Reader isr = null;
-      if (charset == null) {
-        isr = new InputStreamReader(in);
-      } else {
-        isr = new InputStreamReader(in,charset);
-      }
+      XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in);
       if (options != null && charset != null) options.setCharset(charset);
-      document = parse(isr, base, options);
+      FOMFactory factory = getFomFactory(options);
+      FOMBuilder builder = new FOMBuilder(factory, xmlreader, options);
+      document = getDocument(builder, base);
+      setCharset(options, xmlreader.getCharacterEncodingScheme(), document);
     } catch (Exception e) {
       if (!(e instanceof ParseException))
         e = new ParseException(e);
@@ -112,8 +108,7 @@
       throw new IllegalArgumentException("Reader must not be null");
     try {
       FOMFactory factory = getFomFactory(options);
-      XMLStreamReader xmlreader = 
-        XMLInputFactory.newInstance().createXMLStreamReader(in);
+      XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in);
       FOMBuilder builder = new FOMBuilder(factory, xmlreader, options);
       document = getDocument(builder, base);
       setCharset(options, xmlreader.getCharacterEncodingScheme(), document);

Modified: incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/util/PeekAheadInputStream.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/util/PeekAheadInputStream.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/util/PeekAheadInputStream.java (original)
+++ incubator/abdera/java/branches/0.1.0/parser/src/main/java/org/apache/abdera/parser/stax/util/PeekAheadInputStream.java Tue Jul 18 10:32:11 2006
@@ -122,6 +122,7 @@
 
   @Override
   public int read(byte[] b, int off, int len) throws IOException {
+    this.available(); // workaround for a problem in PushbackInputStream, without this, the amount of bytes read from some streams will be incorrect
     int r = super.read(b, off, len);
     if (pos >= buf.length && buf.length > origsize) shrink();
     return r;

Modified: incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java (original)
+++ incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/AtomConformanceTest.java Tue Jul 18 10:32:11 2006
@@ -295,11 +295,13 @@
           break;
         case 7:
           Div div = title.getValueElement();
-          assertEquals(div.getValue(), "&lt;title>");
+          assertTrue(div.getValue().equals("&lt;title>") || 
+                     div.getValue().equals("&lt;title&gt;"));
           break;
         case 8:
           div = title.getValueElement();
-          assertEquals(div.getValue(), "&lt;title>");
+          assertTrue(div.getValue().equals("&lt;title>") ||
+                     div.getValue().equals("&lt;title&gt;"));
           break;
       }
       n++;

Modified: incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java (original)
+++ incubator/abdera/java/branches/0.1.0/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java Tue Jul 18 10:32:11 2006
@@ -20,7 +20,6 @@
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.ByteArrayOutputStream;
-import java.net.URI;
 import java.net.URL;
 import java.util.Calendar;
 import java.util.Date;
@@ -58,8 +57,6 @@
 import org.apache.abdera.model.Workspace;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.parser.ParserOptions;
-import org.apache.abdera.parser.stax.FOMEntry;
-import org.apache.abdera.parser.stax.FOMFactory;
 import org.apache.abdera.util.AbderaSource;
 import org.apache.abdera.util.BlackListParseFilter;
 import org.apache.abdera.util.Constants;
@@ -68,12 +65,6 @@
 import org.apache.abdera.util.WhiteListParseFilter;
 import org.apache.abdera.xpath.XPath;
 import org.apache.axiom.attachments.ByteArrayDataSource;
-import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMXMLParserWrapper;
-
 
 import junit.framework.TestCase;
 
@@ -134,13 +125,15 @@
     entry2.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5b", false);
     entry2.setSummary("A response");
     
-    String compare = "<?xml version='1.0' encoding='UTF-8'?><a:feed xmlns:a=\"http://www.w3.org/2005/Atom\" xml:base=\"http://example.org\" xml:lang=\"en-US\"><a:title type=\"text\">Example Feed</a:title><a:link href=\"http://example.org/\" /><a:author><a:name>John Doe</a:name></a:author><a:id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</a:id><a:contributor><a:name>Bob Jones</a:name></a:contributor><a:category term=\"example\" /><a:entry><a:title type=\"text\">re: Atom-Powered Robots Run Amok</a:title><a:link href=\"/2003/12/13/atom03/1\" /><a:id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5b</a:id><a:summary type=\"text\">A response</a:summary></a:entry><a:entry><a:title type=\"text\">Atom-Powered Robots Run Amok</a:title><a:link href=\"http://example.org/2003/12/13/atom03\" /><a:id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</a:id><a:summary type=\"text\">Some text.</a:summary></a:entry></a:feed>";
-    
-    ByteArrayOutputStream out = new ByteArrayOutputStream(512);
-    feed.getDocument().writeTo(out);
-    String actual = out.toString();
+    //TODO: we can't compare the serializations.  different 
+    // stax impls serialize with slight variances
+    //String compare = "<?xml version='1.0' encoding='UTF-8'?><a:feed xmlns:a=\"http://www.w3.org/2005/Atom\" xml:base=\"http://example.org\" xml:lang=\"en-US\"><a:title type=\"text\">Example Feed</a:title><a:link href=\"http://example.org/\" /><a:author><a:name>John Doe</a:name></a:author><a:id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</a:id><a:contributor><a:name>Bob Jones</a:name></a:contributor><a:category term=\"example\" /><a:entry><a:title type=\"text\">re: Atom-Powered Robots Run Amok</a:title><a:link href=\"/2003/12/13/atom03/1\" /><a:id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5b</a:id><a:summary type=\"text\">A response</a:summary></a:entry><a:entry><a:title type=\"text\">Atom-Powered Robots Run Amok</a:title><a:link href=\"http://example.org/2003/12/13/atom03\" /><a:id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</a:id><a:summary type=\"text\">Some text.</a:summary></a:entry></a:feed>";
+    
+    //ByteArrayOutputStream out = new ByteArrayOutputStream(512);
+    //feed.getDocument().writeTo(out);
+    //String actual = out.toString();
     
-    assertEquals(actual, compare);
+    //assertEquals(actual, compare);
     
     assertEquals(feed.getEntries().get(0).getId().toString(), "urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5b");
     assertEquals(feed.getEntries().get(1).getId().toString(), "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
@@ -712,20 +705,6 @@
     assertEquals(entry.getSummary(), "Some text.");
   }
   
-  public void testAlternatives() throws Exception {
-     Factory factory = new MyFactory();
-     Entry entry = factory.newEntry();
-     assertTrue(entry instanceof MyEntry);
-     
-     ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
-     options.setFactory(factory);
-     InputStream in = FOMTest.class.getResourceAsStream("/simple.xml");
-     Document<Feed> doc = Parser.INSTANCE.parse(in, (URI)null, options);
-     Feed feed = doc.getRoot();
-     entry = feed.getEntries().get(0);
-     assertTrue(entry instanceof MyEntry);
-  }
-  
   public void testSourceResult() throws Exception {
     try {
       // Apply an XSLT transform to the entire Feed
@@ -757,53 +736,4 @@
     }
   }
   
-  public static class MyFactory extends FOMFactory {
-    public MyFactory() {
-      registerAlternative(FOMEntry.class, MyEntry.class);
-    }
-  }
-  
-  @SuppressWarnings("serial")
-  public static class MyEntry extends FOMEntry{
-
-    public MyEntry(
-      OMContainer parent, 
-      OMFactory factory, 
-      OMXMLParserWrapper builder) 
-        throws OMException {
-      super(parent, factory, builder);
-    }
-
-    public MyEntry(
-      OMContainer parent, 
-      OMFactory factory) 
-        throws OMException {
-      super(parent, factory);
-    }
-
-    public MyEntry(
-      QName qname, 
-      OMContainer parent, 
-      OMFactory factory, 
-      OMXMLParserWrapper builder) {
-        super(qname, parent, factory, builder);
-    }
-
-    public MyEntry(
-      QName qname, 
-      OMContainer parent, 
-      OMFactory factory) {
-        super(qname, parent, factory);
-    }
-
-    public MyEntry(
-      String name, 
-      OMNamespace namespace, 
-      OMContainer parent, 
-      OMFactory factory) 
-        throws OMException {
-      super(name, namespace, parent, factory);
-    }
-    
-  }
 }

Modified: incubator/abdera/java/branches/0.1.0/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/0.1.0/pom.xml?rev=423144&r1=423143&r2=423144&view=diff
==============================================================================
--- incubator/abdera/java/branches/0.1.0/pom.xml (original)
+++ incubator/abdera/java/branches/0.1.0/pom.xml Tue Jul 18 10:32:11 2006
@@ -98,7 +98,7 @@
       </dependency>
       
       <dependency>
-        <groupId>wstx</groupId>
+        <groupId>woodstox</groupId>
         <artifactId>wstx-asl</artifactId>
         <version>2.0.5</version>
         <scope>runtime</scope>	    
@@ -135,6 +135,7 @@
   </dependencyManagement>
   
   <modules>
+    <module>dependencies/json</module>
     <module>core</module>
     <module>parser</module>
     <module>security</module>



Mime
View raw message