abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [24/49] - in /abdera/abdera2: ./ .settings/ activities/ activities/src/ activities/src/main/ activities/src/main/java/ activities/src/main/java/org/ activities/src/main/java/org/apache/ activities/src/main/java/org/apache/abdera2/ ...
Date Tue, 20 Sep 2011 15:57:20 GMT
Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,885 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import java.util.HashSet;
+
+import javax.activation.MimeType;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Categories;
+import org.apache.abdera2.model.Category;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Content;
+import org.apache.abdera2.model.Control;
+import org.apache.abdera2.model.DateTime;
+import org.apache.abdera2.model.Div;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.ExtensibleElement;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.model.Generator;
+import org.apache.abdera2.model.IRIElement;
+import org.apache.abdera2.model.Link;
+import org.apache.abdera2.model.Person;
+import org.apache.abdera2.model.Service;
+import org.apache.abdera2.model.Source;
+import org.apache.abdera2.model.Text;
+import org.apache.abdera2.model.Workspace;
+import org.apache.abdera2.model.Content.Type;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.anno.AnnoUtil;
+import org.apache.abdera2.common.anno.Version;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.factory.ExtensionFactory;
+import org.apache.abdera2.factory.ExtensionFactoryMap;
+import org.apache.abdera2.factory.Factory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMComment;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMProcessingInstruction;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
+
+@SuppressWarnings( {"unchecked", "deprecation"})
+public class FOMFactory extends OMLinkedListImplFactory 
+    implements Factory, Constants, ExtensionFactory {
+
+    private final ExtensionFactoryMap factoriesMap;
+    private final Abdera abdera;
+
+    public static void registerAsDefault() {
+        System.setProperty(
+          OMAbstractFactory.META_FACTORY_NAME_PROPERTY, 
+          FOMFactory.class.getName());
+    }
+
+    
+    /** 
+     * This is a bit of a trick to speed up runtime performance during parse.
+     * Basically, in the old model, whenever we'd encounter an element during
+     * parsing, we would run through and do an if (qname.equals(whatever)) 
+     * check against each of the core known qnames. Each would be checked in
+     * sequence until a match was found, then the appropriate object would be 
+     * created. That approach meant that for every element parsed, there were
+     * we were potentially performing equals checks for every known qname 
+     * every time, which is just silly and slows performance during the parse.
+     * With this approach, we take a little bit of a hit during class init 
+     * and index the Constructors for each of the main types and map those to
+     * their qnames. Now, as we parse each element, we only need to look up 
+     * the qname in the hashmap and grab the appropriate constructor and invoke
+     * it. There are some variations with FOMContent and FOMText elements
+     * since their constructors are not identical to the others, but this 
+     * approach gives us constant time performance during parse (at least for 
+     * the object creation portion of it) and eliminates the need for checking
+     * every qname on every iteration... albeit, at a cost of a bit more 
+     * complexity
+     */
+    private static java.util.Map<QName,java.lang.reflect.Constructor<?>> conmap =
+      new java.util.HashMap<QName,java.lang.reflect.Constructor<?>>();
+    private static java.util.Map<QName,java.lang.reflect.Constructor<?>> conmap2 =
+      new java.util.HashMap<QName,java.lang.reflect.Constructor<?>>();
+    private static java.util.Set<QName> textset = new java.util.HashSet<QName>();
+    private static java.lang.reflect.Constructor<?> confrom(Class<?> _class, Class<?>... _types) {
+      try {
+        return _class.getConstructor(_types);
+      } catch (Throwable t) {
+        throw new RuntimeException(t);
+      }
+    }
+    private static <T>T create(QName qname, Object... params) {
+      try {
+        return (T)(conmap.containsKey(qname) ? 
+          conmap.get(qname).newInstance(params) : null);
+      } catch (Throwable t) {
+        return null;
+      }
+    }
+    private static <T>T create2(QName qname, Object... params) {
+      try {
+        return (T)(conmap2.containsKey(qname) ? 
+          conmap2.get(qname).newInstance(params) : null);
+      } catch (Throwable t) {
+        t.printStackTrace();
+        return null;
+      }
+    }
+    private static boolean is_content(QName qname) {
+      return qname.equals(CONTENT);
+    }
+    private static boolean is_text(QName qname) {
+      return textset.contains(qname);
+    }
+    static {
+      // these are text elements.. they'll have a different constructor
+      textset.add(RIGHTS);
+      textset.add(SUBTITLE);
+      textset.add(SUMMARY);
+      textset.add(TITLE);
+      
+      conmap.put(FEED, confrom(FOMFeed.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(SERVICE, confrom(FOMService.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class));
+      conmap.put(PRE_RFC_SERVICE, confrom(FOMService.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(ENTRY, confrom(FOMEntry.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(AUTHOR, confrom(FOMPerson.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(CATEGORY, confrom(FOMCategory.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(CONTENT, confrom(FOMContent.class, String.class, OMNamespace.class, Content.Type.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(CONTRIBUTOR, confrom(FOMPerson.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(GENERATOR, confrom(FOMGenerator.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(ICON, confrom(FOMIRI.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(ID, confrom(FOMIRI.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(LOGO, confrom(FOMIRI.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(LINK, confrom(FOMLink.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(PUBLISHED, confrom(FOMDateTime.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(SOURCE, confrom(FOMSource.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(RIGHTS, confrom(FOMText.class, Text.Type.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(SUBTITLE, confrom(FOMText.class, Text.Type.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(SUMMARY, confrom(FOMText.class, Text.Type.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(TITLE, confrom(FOMText.class, Text.Type.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(UPDATED, confrom(FOMDateTime.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(WORKSPACE, confrom(FOMWorkspace.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(PRE_RFC_WORKSPACE, confrom(FOMWorkspace.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(COLLECTION, confrom(FOMCollection.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(PRE_RFC_COLLECTION, confrom(FOMCollection.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(NAME, confrom(FOMElement.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(EMAIL, confrom(FOMElement.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(URI, confrom(FOMIRI.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(CONTROL, confrom(FOMControl.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class));
+      conmap.put(PRE_RFC_CONTROL, confrom(FOMControl.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(DIV, confrom(FOMDiv.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(CATEGORIES, confrom(FOMCategories.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(PRE_RFC_CATEGORIES, confrom(FOMCategories.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+      conmap.put(EDITED, confrom(FOMDateTime.class, String.class, OMNamespace.class, OMContainer.class, OMFactory.class)); 
+
+      conmap2.put(FEED, confrom(FOMFeed.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(SERVICE, confrom(FOMService.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class));
+      conmap2.put(PRE_RFC_SERVICE, confrom(FOMService.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(ENTRY, confrom(FOMEntry.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(AUTHOR, confrom(FOMPerson.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(CATEGORY, confrom(FOMCategory.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(CONTENT, confrom(FOMContent.class, QName.class, Content.Type.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(CONTRIBUTOR, confrom(FOMPerson.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(GENERATOR, confrom(FOMGenerator.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(ICON, confrom(FOMIRI.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(ID, confrom(FOMIRI.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(LOGO, confrom(FOMIRI.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(LINK, confrom(FOMLink.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(PUBLISHED, confrom(FOMDateTime.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(SOURCE, confrom(FOMSource.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(RIGHTS, confrom(FOMText.class, Text.Type.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(SUBTITLE, confrom(FOMText.class, Text.Type.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(SUMMARY, confrom(FOMText.class, Text.Type.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(TITLE, confrom(FOMText.class, Text.Type.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(UPDATED, confrom(FOMDateTime.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(WORKSPACE, confrom(FOMWorkspace.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(PRE_RFC_WORKSPACE, confrom(FOMWorkspace.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(COLLECTION, confrom(FOMCollection.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(PRE_RFC_COLLECTION, confrom(FOMCollection.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(URI, confrom(FOMIRI.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(CONTROL, confrom(FOMControl.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class));
+      conmap2.put(PRE_RFC_CONTROL, confrom(FOMControl.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(DIV, confrom(FOMDiv.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(CATEGORIES, confrom(FOMCategories.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(PRE_RFC_CATEGORIES, confrom(FOMCategories.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(EDITED, confrom(FOMDateTime.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(NAME, confrom(FOMElement.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+      conmap2.put(EMAIL, confrom(FOMElement.class, QName.class, OMContainer.class, OMFactory.class, OMXMLParserWrapper.class)); 
+    }
+    
+    /***********************************************************************/
+    
+    public FOMFactory() {
+        this(Abdera.getInstance());
+    }
+
+    public FOMFactory(Abdera abdera) {
+        Iterable<ExtensionFactory> f = 
+          abdera.getConfiguration().getExtensionFactories();
+        factoriesMap = 
+          new ExtensionFactoryMap(
+              f != null ? f : new HashSet<ExtensionFactory>());
+        this.abdera = abdera;
+    }
+
+    public Parser newParser() {
+        return new FOMParser(abdera);
+    }
+
+    public <T extends Element> Document<T> newDocument() {
+        return new FOMDocument<T>(this);
+    }
+
+    public <T extends Element> Document<T> newDocument(OMXMLParserWrapper parserWrapper) {
+        return new FOMDocument<T>(parserWrapper, this);
+    }
+
+    public <T extends Element> Document<T> newDocument(T root, OMXMLParserWrapper parserWrapper) {
+        FOMDocument<T> doc = (FOMDocument<T>)newDocument(parserWrapper);
+        doc.setRoot(root);
+        return doc;
+    }
+
+    public Service newService(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMService(qname, parent, this, parserWrapper);
+    }
+
+    public Service newService(Base parent) {
+        return new FOMService((OMContainer)parent, this);
+    }
+
+    public Workspace newWorkspace(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMWorkspace(qname, parent, this, parserWrapper);
+    }
+
+    public Workspace newWorkspace() {
+        return newWorkspace(null);
+    }
+
+    public Workspace newWorkspace(Element parent) {
+        return new FOMWorkspace((OMContainer)parent, this);
+    }
+
+    public Collection newCollection(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMCollection(qname, parent, this, parserWrapper);
+    }
+
+    public Collection newCollection() {
+        return newCollection(null);
+    }
+
+    public Collection newCollection(Element parent) {
+        return new FOMCollection((OMContainer)parent, this);
+    }
+
+    public Collection newMultipartCollection(Element parent) {
+        return new FOMMultipartCollection((OMContainer)parent, this);
+    }
+
+    public Feed newFeed() {
+        Document<Feed> doc = newDocument();
+        return newFeed(doc);
+    }
+
+    public Entry newEntry() {
+        Document<Entry> doc = newDocument();
+        return newEntry(doc);
+    }
+
+    public Service newService() {
+        Document<Service> doc = newDocument();
+        return newService(doc);
+    }
+
+    public Feed newFeed(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMFeed(qname, parent, this, parserWrapper);
+    }
+
+    public Feed newFeed(Base parent) {
+        return new FOMFeed((OMContainer)parent, this);
+    }
+
+    public Entry newEntry(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMEntry(qname, parent, this, parserWrapper);
+    }
+
+    public Entry newEntry(Base parent) {
+        return new FOMEntry((OMContainer)parent, this);
+    }
+
+    public Category newCategory(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMCategory(qname, parent, this, parserWrapper);
+    }
+
+    public Category newCategory() {
+        return newCategory(null);
+    }
+
+    public Category newCategory(Element parent) {
+        return new FOMCategory((OMContainer)parent, this);
+    }
+
+    public Content newContent(QName qname, Type type, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        if (type == null)
+            type = Content.Type.TEXT;
+        return new FOMContent(qname, type, parent, this, parserWrapper);
+    }
+
+    public Content newContent() {
+        return newContent(Content.Type.TEXT);
+    }
+
+    public Content newContent(Type type) {
+        if (type == null)
+            type = Content.Type.TEXT;
+        return newContent(type, null);
+    }
+
+    public Content newContent(Type type, Element parent) {
+        if (type == null)
+            type = Content.Type.TEXT;
+        Content content = new FOMContent(type, (OMContainer)parent, this);
+        if (type.equals(Content.Type.XML))
+            content.setMimeType(XML_MEDIA_TYPE);
+        return content;
+    }
+
+    public Content newContent(MimeType mediaType) {
+        return newContent(mediaType, null);
+    }
+
+    public Content newContent(MimeType mediaType, Element parent) {
+        Content.Type type = (MimeTypeHelper.isXml(mediaType.toString())) ? Content.Type.XML : Content.Type.MEDIA;
+        Content content = newContent(type, parent);
+        content.setMimeType(mediaType.toString());
+        return content;
+    }
+
+    public DateTime newDateTimeElement(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMDateTime(qname, parent, this, parserWrapper);
+    }
+
+    public DateTime newDateTime(QName qname, Element parent) {
+        return new FOMDateTime(qname, (OMContainer)parent, this);
+    }
+
+    public Generator newGenerator(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMGenerator(qname, parent, this, parserWrapper);
+    }
+
+    public Generator newDefaultGenerator() {
+        return newDefaultGenerator(null);
+    }
+
+    public Generator newDefaultGenerator(Element parent) {
+        Generator generator = newGenerator(parent);
+        Version version = AnnoUtil.getVersion(abdera);
+        generator.setVersion(version.value());
+        generator.setText(version.name());
+        generator.setUri(version.uri());
+        return generator;
+    }
+
+    public Generator newGenerator() {
+        return newGenerator(null);
+    }
+
+    public Generator newGenerator(Element parent) {
+        return new FOMGenerator((OMContainer)parent, this);
+    }
+
+    public IRIElement newID(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMIRI(qname, parent, this, parserWrapper);
+    }
+
+    public IRIElement newID() {
+        return newID(null);
+    }
+
+    public IRIElement newID(Element parent) {
+        return new FOMIRI(Constants.ID, (OMContainer)parent, this);
+    }
+
+    public IRIElement newURIElement(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMIRI(qname, parent, this, parserWrapper);
+    }
+
+    public IRIElement newIRIElement(QName qname, Element parent) {
+        return new FOMIRI(qname, (OMContainer)parent, this);
+    }
+
+    public Link newLink(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMLink(qname, parent, this, parserWrapper);
+    }
+
+    public Link newLink() {
+        return newLink(null);
+    }
+
+    public Link newLink(Element parent) {
+        return new FOMLink((OMContainer)parent, this);
+    }
+
+    public Person newPerson(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMPerson(qname, parent, this, parserWrapper);
+    }
+
+    public Person newPerson(QName qname, Element parent) {
+        return new FOMPerson(qname, (OMContainer)parent, this);
+    }
+
+    public Source newSource(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMSource(qname, parent, this, parserWrapper);
+    }
+
+    public Source newSource() {
+        return newSource(null);
+    }
+
+    public Source newSource(Element parent) {
+        return new FOMSource((OMContainer)parent, this);
+    }
+
+    public Text newText(QName qname, Text.Type type, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        if (type == null)
+            type = Text.Type.TEXT;
+        return new FOMText(type, qname, parent, this, parserWrapper);
+    }
+
+    public Text newText(QName qname, Text.Type type) {
+        return newText(qname, type, null);
+    }
+
+    public Text newText(QName qname, Text.Type type, Element parent) {
+        if (type == null)
+            type = Text.Type.TEXT;
+        return new FOMText(type, qname, (OMContainer)parent, this);
+    }
+
+    public <T extends Element> T newElement(QName qname) {
+        return (T)newElement(qname, null);
+    }
+
+    public <T extends Element> T newElement(QName qname, Base parent) {
+        return (T)newExtensionElement(qname, parent);
+    }
+
+    public <T extends Element> T newExtensionElement(QName qname) {
+        return (T)newExtensionElement(qname, (OMContainer)null);
+    }
+
+    public <T extends Element> T newExtensionElement(QName qname, Base parent) {
+        return (T)newExtensionElement(qname, (OMContainer)parent);
+    }
+
+    private <T extends Element> T newExtensionElement(QName qname, OMContainer parent) {
+        String ns = qname.getNamespaceURI();
+        Element el = newExtensionElement(qname, parent, null);
+        return (T)((ATOM_NS.equals(ns) || APP_NS.equals(ns)) ? el : factoriesMap.getElementWrapper(el));
+    }
+
+    private <T extends Element> T newExtensionElement(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        Element element =
+            (parserWrapper == null) ? 
+                (Element)createElement(qname, parent, this, null) : 
+            (Element)createElement(qname, parent, (FOMBuilder)parserWrapper);
+
+        return (T)element;
+    }
+
+    public Control newControl() {
+        return newControl(null);
+    }
+
+    public Control newControl(Element parent) {
+        return new FOMControl((OMContainer)parent, this);
+    }
+
+    public Control newControl(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMControl(qname, parent, this, parserWrapper);
+    }
+
+    public DateTime newPublished() {
+        return newPublished(null);
+    }
+
+    public DateTime newPublished(Element parent) {
+        return newDateTime(Constants.PUBLISHED, parent);
+    }
+
+    public DateTime newUpdated() {
+        return newUpdated(null);
+    }
+
+    public DateTime newUpdated(Element parent) {
+        return newDateTime(Constants.UPDATED, parent);
+    }
+
+    public DateTime newEdited() {
+        return newEdited(null);
+    }
+
+    public DateTime newEdited(Element parent) {
+        return newDateTime(Constants.EDITED, parent);
+    }
+
+    public IRIElement newIcon() {
+        return newIcon(null);
+    }
+
+    public IRIElement newIcon(Element parent) {
+        return newIRIElement(Constants.ICON, parent);
+    }
+
+    public IRIElement newLogo() {
+        return newLogo(null);
+    }
+
+    public IRIElement newLogo(Element parent) {
+        return newIRIElement(Constants.LOGO, parent);
+    }
+
+    public IRIElement newUri() {
+        return newUri(null);
+    }
+
+    public IRIElement newUri(Element parent) {
+        return newIRIElement(Constants.URI, parent);
+    }
+
+    public Person newAuthor() {
+        return newAuthor(null);
+    }
+
+    public Person newAuthor(Element parent) {
+        return newPerson(Constants.AUTHOR, parent);
+    }
+
+    public Person newContributor() {
+        return newContributor(null);
+    }
+
+    public Person newContributor(Element parent) {
+        return newPerson(Constants.CONTRIBUTOR, parent);
+    }
+
+    public Text newTitle() {
+        return newTitle(Text.Type.TEXT);
+    }
+
+    public Text newTitle(Element parent) {
+        return newTitle(Text.Type.TEXT, parent);
+    }
+
+    public Text newTitle(Text.Type type) {
+        return newTitle(type, null);
+    }
+
+    public Text newTitle(Text.Type type, Element parent) {
+        return newText(Constants.TITLE, type, parent);
+    }
+
+    public Text newSubtitle() {
+        return newSubtitle(Text.Type.TEXT);
+    }
+
+    public Text newSubtitle(Element parent) {
+        return newSubtitle(Text.Type.TEXT, parent);
+    }
+
+    public Text newSubtitle(Text.Type type) {
+        return newSubtitle(type, null);
+    }
+
+    public Text newSubtitle(Text.Type type, Element parent) {
+        return newText(Constants.SUBTITLE, type, parent);
+    }
+
+    public Text newSummary() {
+        return newSummary(Text.Type.TEXT);
+    }
+
+    public Text newSummary(Element parent) {
+        return newSummary(Text.Type.TEXT, parent);
+    }
+
+    public Text newSummary(Text.Type type) {
+        return newSummary(type, null);
+    }
+
+    public Text newSummary(Text.Type type, Element parent) {
+        return newText(Constants.SUMMARY, type, parent);
+    }
+
+    public Text newRights() {
+        return newRights(Text.Type.TEXT);
+    }
+
+    public Text newRights(Element parent) {
+        return newRights(Text.Type.TEXT, parent);
+    }
+
+    public Text newRights(Text.Type type) {
+        return newRights(type, null);
+    }
+
+    public Text newRights(Text.Type type, Element parent) {
+        return newText(Constants.RIGHTS, type, parent);
+    }
+
+    public Element newName() {
+        return newName(null);
+    }
+
+    public Element newName(Element parent) {
+        return newElement(Constants.NAME, parent);
+    }
+
+    public Element newEmail() {
+        return newEmail(null);
+    }
+
+    public Element newEmail(Element parent) {
+        return newElement(Constants.EMAIL, parent);
+    }
+
+    public Div newDiv() {
+        return newDiv(null);
+    }
+
+    public Div newDiv(Base parent) {
+        return new FOMDiv(DIV, (OMContainer)parent, this);
+    }
+
+    public Div newDiv(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMDiv(qname, parent, this, parserWrapper);
+    }
+
+    public Element newElement(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMExtensibleElement(qname, parent, this, parserWrapper);
+    }
+
+    protected OMElement createElement(QName qname, OMContainer parent, OMFactory factory, Object objecttype) {
+        OMElement element = null;
+        OMNamespace namespace = this.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix());
+        
+        if (conmap.containsKey(qname)) {
+          if (is_text(qname)) {
+            Text.Type type = (Text.Type)objecttype;
+            element = create(qname,qname.getLocalPart(),namespace,type,parent,factory);
+          } else if (is_content(qname)) {
+            Content.Type type = (Content.Type)objecttype;
+            element = create(qname,qname.getLocalPart(),namespace,type,parent,factory);
+          } else {
+            element = create(qname,qname.getLocalPart(),namespace,parent,factory);
+          }
+        } else if (parent instanceof ExtensibleElement || parent instanceof Document) {
+            element = (OMElement)new FOMExtensibleElement(qname, parent, this);
+        } else {
+            element = (OMElement)new FOMExtensibleElement(qname, null, this);
+        }
+        return element;
+    }
+
+    protected OMElement createElement(QName qname, OMContainer parent, FOMBuilder builder) {
+        OMElement element = null;
+        if (conmap2.containsKey(qname)) {
+          if (is_text(qname)) {
+            Text.Type type = builder.getTextType();
+            element = create2(qname,type,qname,(OMContainer)parent,(OMFactory)this,(OMXMLParserWrapper)builder);
+          } else if (is_content(qname)) {
+            Content.Type type = builder.getContentType();;
+            element = create2(qname,qname,type,(OMContainer)parent,(OMFactory)this,(OMXMLParserWrapper)builder);
+          } else {
+            element = create2(qname,qname,(OMContainer)parent,(OMFactory)this,(OMXMLParserWrapper)builder);
+          }
+        } else if (parent instanceof ExtensibleElement || parent instanceof Document) {
+            element = (OMElement)new FOMExtensibleElement(qname, parent, this, builder);
+        }
+        return element;
+    }
+
+    public Factory registerExtension(ExtensionFactory factory) {
+        factoriesMap.addFactory(factory);
+        return this;
+    }
+
+    public Categories newCategories() {
+        Document<Categories> doc = newDocument();
+        return newCategories(doc);
+    }
+
+    public Categories newCategories(Base parent) {
+        return new FOMCategories((OMContainer)parent, this);
+    }
+
+    public Categories newCategories(QName qname, OMContainer parent, OMXMLParserWrapper parserWrapper) {
+        return new FOMCategories(qname, parent, this, parserWrapper);
+    }
+
+    public String newUuidUri() {
+        return String.format("urn:uuid:%s",FOMElement.generateUuid());
+    }
+    
+    public <T extends Element> T getElementWrapper(Element internal) {
+        if (internal == null)
+            return null;
+        String ns = internal.getQName().getNamespaceURI();
+        return (T)((ATOM_NS.equals(ns) || APP_NS.equals(ns) || internal.getQName().equals(DIV)) ? internal
+            : factoriesMap.getElementWrapper(internal));
+    }
+
+    public Iterable<String> getNamespaces() {
+        return factoriesMap.getNamespaces();
+    }
+
+    public boolean handlesNamespace(String namespace) {
+        return factoriesMap.handlesNamespace(namespace);
+    }
+
+    public Abdera getAbdera() {
+        return abdera;
+    }
+
+    public <T extends Base> String getMimeType(T base) {
+        String type = factoriesMap.getMimeType(base);
+        return type;
+    }
+
+    public Iterable<ExtensionFactory> listExtensionFactories() {
+        return factoriesMap;
+    }
+
+    @Override
+    public OMText createOMText(Object arg0, boolean arg1) {
+        return new FOMTextValue(arg0, arg1, this);
+    }
+
+    @Override
+    public OMText createOMText(OMContainer arg0, char[] arg1, int arg2) {
+        return new FOMTextValue(arg0, arg1, arg2, this);
+    }
+
+    @Override
+    public OMText createOMText(OMContainer arg0, QName arg1, int arg2) {
+        return new FOMTextValue(arg0, arg1, arg2, this);
+    }
+
+    @Override
+    public OMText createOMText(OMContainer arg0, QName arg1) {
+        return new FOMTextValue(arg0, arg1, this);
+    }
+
+    @Override
+    public OMText createOMText(OMContainer arg0, String arg1, int arg2) {
+        return new FOMTextValue(arg0, arg1, arg2, this);
+    }
+
+    @Override
+    public OMText createOMText(OMContainer arg0, String arg1, String arg2, boolean arg3) {
+        return new FOMTextValue(arg0, arg1, arg2, arg3, this);
+    }
+
+    @Override
+    public OMText createOMText(OMContainer arg0, String arg1) {
+        return new FOMTextValue(arg0, arg1, this);
+    }
+
+    @Override
+    public OMText createOMText(String arg0, int arg1) {
+        return new FOMTextValue(arg0, arg1, this);
+    }
+
+    @Override
+    public OMText createOMText(String arg0, OMContainer arg1, OMXMLParserWrapper arg2) {
+        return new FOMTextValue(arg0, arg1, arg2, this);
+    }
+
+    @Override
+    public OMText createOMText(String arg0, String arg1, boolean arg2) {
+        return new FOMTextValue(arg0, arg1, arg2, this);
+    }
+
+    @Override
+    public OMText createOMText(String arg0) {
+        return new FOMTextValue(arg0, this);
+    }
+
+    @Override
+    public OMComment createOMComment(OMContainer arg0, String arg1) {
+        return new FOMComment(arg0, arg1, this);
+    }
+
+    @Override
+    public OMProcessingInstruction createOMProcessingInstruction(OMContainer arg0, String arg1, String arg2) {
+        return new FOMProcessingInstruction(arg0, arg1, arg2, this);
+    }
+
+    public DateTime newDateTime(Class<?> _class, Element parent) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newDateTime(qname,parent);
+    }
+
+    public IRIElement newIRIElement(Class<?> _class, Element parent) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newIRIElement(qname,parent);
+    }
+
+    public Person newPerson(Class<?> _class, Element parent) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newPerson(qname,parent);
+    }
+
+    public Text newText(Class<?> _class, org.apache.abdera2.model.Text.Type type) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newText(qname,type);
+    }
+
+    public Text newText(Class<?> _class,
+        org.apache.abdera2.model.Text.Type type, Element parent) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newText(qname,type,parent);
+    }
+
+    public <T extends Element> T newElement(Class<?> _class) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newElement(qname);
+    }
+
+    public <T extends Element> T newElement(Class<?> _class, Base parent) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newElement(qname,parent);
+    }
+
+    public <T extends Element> T newExtensionElement(Class<?> _class) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newExtensionElement(qname);
+    }
+
+    public <T extends Element> T newExtensionElement(Class<?> _class,
+        Base parent) {
+      QName qname = AnnoUtil.getQName(_class);
+      if (qname == null)
+        throw new IllegalArgumentException();
+      return newExtensionElement(qname,parent);
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,224 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.selector.Selector;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.model.Source;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+public class FOMFeed extends FOMSource implements Feed {
+
+    private static final long serialVersionUID = 4552921210185524535L;
+
+    public FOMFeed() {
+        super(Constants.FEED, new FOMDocument<Feed>(), new FOMFactory());
+    }
+
+    public FOMFeed(String name, OMNamespace namespace, OMContainer parent, OMFactory factory) throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMFeed(QName qname, OMContainer parent, OMFactory factory) {
+        super(qname, parent, factory);
+    }
+
+    public FOMFeed(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) {
+        super(qname, parent, factory, builder);
+    }
+
+    public FOMFeed(OMContainer parent, OMFactory factory) throws OMException {
+        super(FEED, parent, factory);
+    }
+
+    public FOMFeed(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(FEED, parent, factory, builder);
+    }
+
+    public List<Entry> getEntries() {
+        return _getChildrenAsSet(ENTRY);
+    }
+
+    public Feed addEntry(Entry entry) {
+        complete();
+        addChild((OMElement)entry);
+        return this;
+    }
+
+    public Entry addEntry() {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        return fomfactory.newEntry(this);
+    }
+
+    public Feed insertEntry(Entry entry) {
+        complete();
+        OMElement el = getFirstChildWithName(ENTRY);
+        if (el == null) {
+            addEntry(entry);
+        } else {
+            entry.setParentElement(this);
+            el.insertSiblingBefore((OMElement)entry);
+        }
+        return this;
+    }
+
+    public Entry insertEntry() {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Entry entry = fomfactory.newEntry((Feed)null);
+        insertEntry(entry);
+        return entry;
+    }
+
+    public Source getAsSource() {
+        FOMSource source = (FOMSource)((FOMFactory)factory).newSource(null);
+        for (Iterator<?> i = this.getChildElements(); i.hasNext();) {
+            FOMElement child = (FOMElement)i.next();
+            if (!child.getQName().equals(ENTRY)) {
+                source.addChild((OMNode)child.clone());
+            }
+        }
+        try {
+            if (this.getBaseUri() != null) {
+                source.setBaseUri(this.getBaseUri());
+            }
+        } catch (Exception e) {
+        }
+        return source;
+    }
+
+    @Override
+    public void addChild(OMNode node) {
+        if (isComplete() && node instanceof OMElement && !(node instanceof Entry)) {
+            OMElement el = this.getFirstChildWithName(ENTRY);
+            if (el != null) {
+                el.insertSiblingBefore(node);
+                return;
+            }
+        }
+        super.addChild(node);
+    }
+
+    public Feed sortEntriesByUpdated(boolean new_first) {
+        complete();
+        sortEntries(new UpdatedComparator(new_first));
+        return this;
+    }
+
+    public Feed sortEntriesByEdited(boolean new_first) {
+        complete();
+        sortEntries(new EditedComparator(new_first));
+        return this;
+    }
+
+    public Feed sortEntries(Comparator<Entry> comparator) {
+        complete();
+        if (comparator == null)
+            return this;
+        List<Entry> entries = this.getEntries();
+        Entry[] a = entries.toArray(new Entry[entries.size()]);
+        Arrays.sort(a, comparator);
+        for (Entry e : entries) {
+            e.discard();
+        }
+        for (Entry e : a) {
+            addEntry(e);
+        }
+        return this;
+    }
+
+    private static class EditedComparator implements Comparator<Entry> {
+        private boolean new_first = true;
+
+        EditedComparator(boolean new_first) {
+            this.new_first = new_first;
+        }
+
+        public int compare(Entry o1, Entry o2) {
+            Date d1 = o1.getEdited();
+            Date d2 = o2.getEdited();
+            if (d1 == null)
+                d1 = o1.getUpdated();
+            if (d2 == null)
+                d2 = o2.getUpdated();
+            if (d1 == null && d2 == null)
+                return 0;
+            if (d1 == null && d2 != null)
+                return -1;
+            if (d1 != null && d2 == null)
+                return 1;
+            int r = d1.compareTo(d2);
+            return (new_first) ? -r : r;
+        }
+    };
+
+    private static class UpdatedComparator implements Comparator<Entry> {
+        private boolean new_first = true;
+
+        UpdatedComparator(boolean new_first) {
+            this.new_first = new_first;
+        }
+
+        public int compare(Entry o1, Entry o2) {
+            Date d1 = o1.getUpdated();
+            Date d2 = o2.getUpdated();
+            if (d1 == null && d2 == null)
+                return 0;
+            if (d1 == null && d2 != null)
+                return -1;
+            if (d1 != null && d2 == null)
+                return 1;
+            int r = d1.compareTo(d2);
+            return (new_first) ? -r : r;
+        }
+    };
+
+    public Entry getEntry(String id) {
+        if (id == null)
+            return null;
+        List<Entry> l = getEntries();
+        for (Entry e : l) {
+            IRI eid = e.getId();
+            if (eid != null && eid.equals(new IRI(id)))
+                return e;
+        }
+        return null;
+    }
+
+    public List<Entry> getEntries(Selector selector) {
+      return _getChildrenAsSet(ENTRY,selector);
+    }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMGenerator.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMGenerator.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMGenerator.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMGenerator.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,91 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Generator;
+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;
+
+public class FOMGenerator extends FOMElement implements Generator {
+
+    private static final long serialVersionUID = -8441971633807437976L;
+
+    public FOMGenerator() {
+        super(Constants.GENERATOR);
+    }
+
+    public FOMGenerator(String value, String version, String uri) {
+        this();
+        ((Element)this).setText(value);
+        setVersion(version);
+        setUri(uri);
+    }
+
+    public FOMGenerator(String name, OMNamespace namespace, OMContainer parent, OMFactory factory)
+        throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMGenerator(QName qname, OMContainer parent, OMFactory factory) {
+        super(qname, parent, factory);
+    }
+
+    public FOMGenerator(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) {
+        super(qname, parent, factory, builder);
+    }
+
+    public FOMGenerator(OMContainer parent, OMFactory factory) throws OMException {
+        super(GENERATOR, parent, factory);
+    }
+
+    public FOMGenerator(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(GENERATOR, parent, factory, builder);
+    }
+
+    public IRI getUri() {
+        String value = getAttributeValue(AURI);
+        return (value != null) ? new IRI(value) : null;
+    }
+
+    public IRI getResolvedUri() {
+        return _resolve(getResolvedBaseUri(), getUri());
+    }
+
+    public Generator setUri(String uri) {
+      complete();
+      return setAttributeValue(AURI, uri==null?null:(new IRI(uri)).toString());
+    }
+
+    public String getVersion() {
+        return getAttributeValue(VERSION);
+    }
+
+    public Generator setVersion(String version) {
+      complete();
+       return setAttributeValue(VERSION,version);
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMIRI.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMIRI.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMIRI.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMIRI.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,80 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.IRIElement;
+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;
+
+public class FOMIRI extends FOMElement implements IRIElement {
+
+    private static final long serialVersionUID = -8434722753544181200L;
+
+    public FOMIRI(QName qname) {
+        super(qname);
+    }
+
+    public FOMIRI(QName qname, String value) {
+        this(qname);
+        setValue(value);
+    }
+
+    public FOMIRI(String name, OMNamespace namespace, OMContainer parent, OMFactory factory) throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMIRI(QName qname, OMContainer parent, OMFactory factory) throws OMException {
+        super(qname, parent, factory);
+    }
+
+    public FOMIRI(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(qname, parent, factory, builder);
+    }
+
+    public IRI getValue() {
+        return _getUriValue(getText());
+    }
+
+    public IRIElement setValue(String iri) {
+        complete();
+        if (iri != null)
+            ((Element)this).setText((new IRI(iri)).toString());
+        else
+            _removeAllChildren();
+        return this;
+    }
+
+    public IRI getResolvedValue() {
+        return _resolve(getResolvedBaseUri(), getValue());
+    }
+
+    public IRIElement setNormalizedValue(String uri) {
+        if (uri != null)
+            setValue(IRI.normalizeString(uri));
+        else
+            setValue(null);
+        return this;
+    }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMIRI.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMLink.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMLink.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMLink.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMLink.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,165 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import javax.activation.MimeType;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Link;
+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;
+
+public class FOMLink extends FOMExtensibleElement implements Link {
+
+    private static final long serialVersionUID = 2239772197929910635L;
+
+    public FOMLink() {
+        super(Constants.LINK);
+    }
+
+    public FOMLink(String href) {
+        this();
+        setHref(href);
+    }
+
+    public FOMLink(String href, String rel) {
+        this();
+        setHref(href);
+        setRel(rel);
+    }
+
+    public FOMLink(String name, OMNamespace namespace, OMContainer parent, OMFactory factory) throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMLink(OMContainer parent, OMFactory factory) throws OMException {
+        super(LINK, parent, factory);
+    }
+
+    public FOMLink(QName qname, OMContainer parent, OMFactory factory) throws OMException {
+        super(qname, parent, factory);
+    }
+
+    public FOMLink(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(LINK, parent, factory, builder);
+    }
+
+    public FOMLink(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder)
+        throws OMException {
+        super(qname, parent, factory, builder);
+    }
+
+    public IRI getHref() {
+        return _getUriValue(getAttributeValue(HREF));
+    }
+
+    public IRI getResolvedHref() {
+        return _resolve(getResolvedBaseUri(), getHref());
+    }
+
+    public Link setHref(String href) {
+      complete();
+      return setAttributeValue(HREF, href==null?null:(new IRI(href)).toString());
+    }
+    
+    public Link setHref(IRI href) {
+      complete();
+      return setAttributeValue(HREF, href==null?null:href.toString());
+    }
+
+    public String getRel() {
+        return getAttributeValue(REL);
+    }
+
+    public Link setRel(String rel) {
+      complete();
+        if (rel != null && rel.startsWith(IANA_BASE))
+          rel = Link.Helper.getRelEquiv(rel);
+        return setAttributeValue(REL, rel);
+    }
+
+    public MimeType getMimeType() {
+        try {
+            String type = getAttributeValue(TYPE);
+            return (type != null) ? new MimeType(type) : null;
+        } catch (javax.activation.MimeTypeParseException e) {
+            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
+        }
+    }
+
+    public void setMimeType(MimeType type) {
+      complete();
+        setAttributeValue(TYPE, (type != null) ? type.toString() : null);
+    }
+
+    public Link setMimeType(String type) {
+        try {
+          complete();
+          return setAttributeValue(TYPE,type==null?null:(new MimeType(type)).toString());
+        } catch (javax.activation.MimeTypeParseException e) {
+            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
+        }
+    }
+
+    public String getHrefLang() {
+        return getAttributeValue(HREFLANG);
+    }
+
+    public Link setHrefLang(String lang) {
+      complete();
+      return setAttributeValue(HREFLANG,lang);
+    }
+
+    public String getTitle() {
+        return getAttributeValue(ATITLE);
+    }
+
+    public Link setTitle(String title) {
+      complete();
+      return setAttributeValue(ATITLE,title);
+    }
+
+    public long getLength() {
+        String l = getAttributeValue(LENGTH);
+        return (l != null) ? Long.valueOf(l) : -1;
+    }
+
+    public Link setLength(long length) {
+      complete();
+      return setAttributeValue(LENGTH, length<0?null:Long.toString(length));
+    }
+
+    public String getValue() {
+        return getText();
+    }
+
+    public void setValue(String value) {
+        complete();
+        if (value != null)
+            ((Element)this).setText(value);
+        else
+            _removeAllChildren();
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMLink.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,138 @@
+package org.apache.abdera2.parser.axiom;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.activation.MimeType;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Element;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+@SuppressWarnings("deprecation")
+public class FOMMultipartCollection extends FOMCollection {
+
+    public FOMMultipartCollection() {
+        super();
+    }
+
+    public FOMMultipartCollection(String title, String href, Map<String, String> accepts) {
+        this();
+        setTitle(title);
+        setHref(href);
+        setAccept(accepts);
+    }
+
+    public FOMMultipartCollection(QName qname, OMContainer parent, OMFactory factory) {
+        super(qname, parent, factory);
+    }
+
+    public FOMMultipartCollection(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) {
+        super(qname, parent, factory, builder);
+    }
+
+    public FOMMultipartCollection(OMContainer parent, OMFactory factory) {
+        super(COLLECTION, parent, factory);
+    }
+
+    public FOMMultipartCollection(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) {
+        super(COLLECTION, parent, factory, builder);
+    }
+
+    public boolean acceptsMultipart(String mediaType) {
+        Map<String, String> accept = getAcceptMultiparted();
+        if (accept.size() == 0)
+            accept = Collections.singletonMap("application/atom+xml;type=entry", null);
+        for (Map.Entry<String, String> entry : accept.entrySet()) {
+            if (MimeTypeHelper.isMatch(entry.getKey(), mediaType) && entry.getValue() != null
+                && entry.getValue().equals(LN_ALTERNATE_MULTIPART_RELATED))
+                return true;
+        }
+        return false;
+    }
+
+    public boolean acceptsMultipart(MimeType mediaType) {
+        return accepts(mediaType.toString());
+    }
+
+    public Map<String, String> getAcceptMultiparted() {
+        Map<String, String> accept = new HashMap<String, String>();
+        Iterator<?> i = getChildrenWithName(ACCEPT);
+        if (i == null || !i.hasNext())
+            i = getChildrenWithName(PRE_RFC_ACCEPT);
+        while (i.hasNext()) {
+            Element e = (Element)i.next();
+            String t = e.getText();
+            if (t != null) {
+                if (e.getAttributeValue(ALTERNATE) != null && e.getAttributeValue(ALTERNATE).trim().length() > 0) {
+                    accept.put(t.trim(), e.getAttributeValue(ALTERNATE));
+                } else {
+                    accept.put(t.trim(), null);
+                }
+            }
+        }
+        return accept;
+    }
+
+    public Collection setAccept(String mediaRange, String alternate) {
+        return setAccept(Collections.singletonMap(mediaRange, alternate));
+    }
+
+    public Collection setAccept(Map<String, String> mediaRanges) {
+        complete();
+        if (mediaRanges != null && mediaRanges.size() > 0) {
+            _removeChildren(ACCEPT, true);
+            _removeChildren(PRE_RFC_ACCEPT, true);
+            if (mediaRanges.size() == 1 && mediaRanges.keySet().iterator().next().equals("")) {
+                addExtension(ACCEPT);
+            } else {
+                for (Map.Entry<String, String> entry : mediaRanges.entrySet()) {
+                    if (entry.getKey().equalsIgnoreCase("entry")) {
+                        addSimpleExtension(ACCEPT, "application/atom+xml;type=entry");
+                    } else {
+                        try {
+                            Element accept = addSimpleExtension(ACCEPT, new MimeType(entry.getKey()).toString());
+                            if (entry.getValue() != null) {
+                                accept.setAttributeValue(ALTERNATE, entry.getValue());
+                            }
+                        } catch (javax.activation.MimeTypeParseException e) {
+                            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
+                        }
+                    }
+                }
+            }
+        } else {
+            _removeChildren(ACCEPT, true);
+            _removeChildren(PRE_RFC_ACCEPT, true);
+        }
+        return this;
+    }
+
+    public Collection addAccepts(String mediaRange, String alternate) {
+        return addAccepts(Collections.singletonMap(mediaRange, alternate));
+    }
+
+    public Collection addAccepts(Map<String, String> mediaRanges) {
+        complete();
+        if (mediaRanges != null) {
+            for (Map.Entry<String, String> entry : mediaRanges.entrySet()) {
+                if (!accepts(entry.getKey())) {
+                    try {
+                        Element accept = addSimpleExtension(ACCEPT, new MimeType(entry.getKey()).toString());
+                        if (entry.getValue() != null) {
+                            accept.setAttributeValue(ALTERNATE, entry.getValue());
+                        }
+                    } catch (Exception e) {
+                    }
+                }
+            }
+        }
+        return this;
+    }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,191 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.Localizer;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.common.xml.XMLStreamSniffingInputStream;
+import org.apache.abdera2.common.xml.XmlRestrictedCharReader;
+import org.apache.abdera2.common.xml.XmlVersionReader;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.parser.AbstractParser;
+import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.parser.ParserOptions;
+
+import org.apache.axiom.om.util.StAXParserConfiguration;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.util.stax.dialect.StAXDialect;
+
+@Name("default")
+public class FOMParser extends AbstractParser implements Parser {
+    private static final StAXParserConfiguration ABDERA_PARSER_CONFIGURATION = new StAXParserConfiguration() {
+        public XMLInputFactory configure(XMLInputFactory factory, StAXDialect dialect) {
+            factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
+            return factory;
+        }
+        
+        // This is used in log statements inside Axiom
+        @Override
+        public String toString() {
+            return "ABDERA";
+        }
+    };
+
+    public FOMParser() {
+        super();
+    }
+
+    public FOMParser(Abdera abdera) {
+        super(abdera);
+    }
+
+    private FOMFactory getFomFactory(ParserOptions options) {
+        FOMFactory factory =
+            (options != null && options.getFactory() != null) ? (FOMFactory)options.getFactory() : null;
+        if (factory == null) {
+            Factory f = getFactory();
+            factory = (f instanceof FOMFactory) ? (FOMFactory)f : new FOMFactory();
+        }
+        return factory;
+    }
+
+    private <T extends Element> Document<T> getDocument(FOMBuilder builder, IRI base, ParserOptions options)
+        throws ParseException {
+        Document<T> document = builder.getFomDocument();
+        try {
+            if (base != null)
+                document.setBaseUri(base.toString());
+            if (options != null && options.getCharset() != null)
+                document.setCharset(options.getCharset());
+            if (options != null)
+                document.setMustPreserveWhitespace(options.getMustPreserveWhitespace());
+        } catch (Exception e) {
+            if (!(e instanceof ParseException))
+                e = new ParseException(e);
+            throw (ParseException)e;
+        }
+        return document;
+    }
+
+    public <T extends Element> Document<T> parse(InputStream in, String base, ParserOptions options)
+        throws ParseException {
+        if (in == null)
+            throw new IllegalArgumentException(Localizer.get("INPUTSTREAM.NOT.NULL"));
+        try {
+            if (options == null)
+                options = getDefaultParserOptions();
+            if (options.getCompressionCodecs() != null) {
+                in = Compression.wrap(in, options.getCompressionCodecs());
+            }
+            String charset = options.getCharset();
+            if (charset == null && options.getAutodetectCharset()) {
+                XMLStreamSniffingInputStream sin =
+                    (in instanceof XMLStreamSniffingInputStream) ? (XMLStreamSniffingInputStream)in
+                        : new XMLStreamSniffingInputStream(in);
+                charset = sin.getEncoding();
+                if (charset != null)
+                    options.setCharset(charset);
+                in = sin;
+            }
+            if (options.getFilterRestrictedCharacters()) {
+                Reader rdr =
+                    (charset == null)
+                        ? new XmlRestrictedCharReader(in, options.getFilterRestrictedCharacterReplacement())
+                        : new XmlRestrictedCharReader(in, charset, options.getFilterRestrictedCharacterReplacement());
+                return parse(StAXUtils.createXMLStreamReader(rdr), base, options);
+            } else {
+                XMLStreamReader xmlreader =
+                    (charset == null) ? createXMLStreamReader(in) : createXMLStreamReader(in, charset);
+                return parse(xmlreader, base, options);
+            }
+        } catch (Exception e) {
+            if (!(e instanceof ParseException))
+                e = new ParseException(e);
+            throw (ParseException)e;
+        }
+    }
+
+    public <T extends Element> Document<T> parse(Reader in, String base, ParserOptions options) throws ParseException {
+        if (in == null)
+            throw new IllegalArgumentException(Localizer.get("READER.NOT.NULL"));
+        try {
+            if (options == null)
+                options = getDefaultParserOptions();
+            if (options.getFilterRestrictedCharacters() && !(in instanceof XmlRestrictedCharReader)) {
+                XmlVersionReader vr = new XmlVersionReader(in);
+                in = new XmlRestrictedCharReader(vr, vr.getVersion(), options.getFilterRestrictedCharacterReplacement());
+            }
+            return parse(createXMLStreamReader(in), base, options);
+        } catch (Exception e) {
+            if (!(e instanceof ParseException))
+                e = new ParseException(e);
+            throw (ParseException)e;
+        }
+    }
+
+    private static XMLInputFactory getXMLInputFactory() {
+        return StAXUtils.getXMLInputFactory(ABDERA_PARSER_CONFIGURATION);
+    }
+
+    public static XMLStreamReader createXMLStreamReader(InputStream in, String encoding) throws XMLStreamException {
+        XMLInputFactory inputFactory = getXMLInputFactory();
+        return inputFactory.createXMLStreamReader(in, encoding);
+    }
+
+    public static XMLStreamReader createXMLStreamReader(InputStream in) throws XMLStreamException {
+        XMLInputFactory inputFactory = getXMLInputFactory();
+        return inputFactory.createXMLStreamReader(in);
+    }
+
+    private XMLStreamReader createXMLStreamReader(Reader in) throws XMLStreamException {
+        XMLInputFactory inputFactory = getXMLInputFactory();
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(in);
+        return reader;
+    }
+
+    public <T extends Element> Document<T> parse(XMLStreamReader reader, String base, ParserOptions options)
+        throws ParseException {
+        try {
+            FOMBuilder builder = new FOMBuilder(getFomFactory(options), reader, options);
+            return getDocument(builder, base != null ? new IRI(base) : null, options);
+        } catch (Exception e) {
+            if (!(e instanceof ParseException))
+                e = new ParseException(e);
+            throw (ParseException)e;
+        }
+    }
+
+    @Override
+    protected ParserOptions initDefaultParserOptions() {
+        return new FOMParserOptions(getFactory());
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserFactory.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserFactory.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserFactory.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserFactory.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,64 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.parser.AbstractParser;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.parser.ParserFactory;
+
+@SuppressWarnings("unchecked")
+public class FOMParserFactory implements ParserFactory {
+
+    private final Abdera abdera;
+    private final Map<String, Parser> parsers;
+
+    public FOMParserFactory() {
+        this(Abdera.getInstance());
+    }
+
+    public FOMParserFactory(Abdera abdera) {
+        this.abdera = abdera;
+        Map<String, Parser> p = getAbdera().getConfiguration().getParsers();
+        this.parsers = (p != null) ? p : new HashMap<String, Parser>();
+    }
+
+    protected Abdera getAbdera() {
+        return abdera;
+    }
+
+    public <T extends Parser> T getParser() {
+        return (T)getAbdera().getParser();
+    }
+
+    public <T extends Parser> T getParser(String name) {
+        Parser parser = (T)((name != null) ? getParsers().get(name.toLowerCase()) : getParser());
+        if (parser instanceof AbstractParser) {
+            ((AbstractParser)parser).setAbdera(abdera);
+        }
+        return (T)parser;
+    }
+
+    private Map<String, Parser> getParsers() {
+        return parsers;
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserOptions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserOptions.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserOptions.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserOptions.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import org.apache.abdera2.common.Localizer;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.parser.AbstractParserOptions;
+
+public class FOMParserOptions extends AbstractParserOptions {
+
+    public FOMParserOptions(Factory factory) {
+        this.factory = factory;
+        this.detect = true;
+    }
+
+    protected void initFactory() {
+        if (factory == null)
+            factory = new FOMFactory();
+    }
+
+    protected void checkFactory(Factory factory) {
+        if (!(factory instanceof FOMFactory))
+            throw new FOMException(Localizer.sprintf("WRONG.PARSER.INSTANCE", FOMFactory.class.getName()));
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMPerson.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMPerson.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMPerson.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMPerson.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,163 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.IRIElement;
+import org.apache.abdera2.model.Person;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+public class FOMPerson extends FOMExtensibleElement implements Person {
+
+    private static final long serialVersionUID = 2147684807662492625L;
+
+    public FOMPerson(QName qname) {
+        super(qname);
+    }
+
+    public FOMPerson(QName qname, String name) {
+        this(qname);
+        setName(name);
+    }
+
+    public FOMPerson(QName qname, String name, String email, String uri) {
+        this(qname);
+        setName(name);
+        setEmail(email);
+        setUri(uri);
+    }
+
+    public FOMPerson(String name, OMNamespace namespace, OMContainer parent, OMFactory factory) throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMPerson(QName qname, OMContainer parent, OMFactory factory) throws OMException {
+        super(qname, parent, factory);
+    }
+
+    public FOMPerson(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder)
+        throws OMException {
+        super(qname, parent, factory, builder);
+        setBuilder(builder);
+        done = false;
+    }
+
+    public Element getNameElement() {
+        return (Element)getFirstChildWithName(NAME);
+    }
+
+    public Person setNameElement(Element element) {
+        complete();
+        if (element != null)
+            _setChild(NAME, (OMElement)element);
+        else
+            _removeChildren(NAME, false);
+        return this;
+    }
+
+    public Element setName(String name) {
+        complete();
+        if (name != null) {
+            FOMFactory fomfactory = (FOMFactory)factory;
+            Element el = fomfactory.newName(null);
+            el.setText(name);
+            _setChild(NAME, (OMElement)el);
+            return el;
+        } else {
+            _removeChildren(NAME, false);
+            return null;
+        }
+    }
+
+    public String getName() {
+        Element name = getNameElement();
+        return (name != null) ? name.getText() : null;
+    }
+
+    public Element getEmailElement() {
+        return (Element)getFirstChildWithName(EMAIL);
+    }
+
+    public Person setEmailElement(Element element) {
+        complete();
+        if (element != null)
+            _setChild(EMAIL, (OMElement)element);
+        else
+            _removeChildren(EMAIL, false);
+        return this;
+    }
+
+    public Element setEmail(String email) {
+        complete();
+        if (email != null) {
+            FOMFactory fomfactory = (FOMFactory)factory;
+            Element el = fomfactory.newEmail(null);
+            el.setText(email);
+            _setChild(EMAIL, (OMElement)el);
+            return el;
+        } else {
+            _removeChildren(EMAIL, false);
+            return null;
+        }
+    }
+
+    public String getEmail() {
+        Element email = getEmailElement();
+        return (email != null) ? email.getText() : null;
+    }
+
+    public IRIElement getUriElement() {
+        return (IRIElement)getFirstChildWithName(URI);
+    }
+
+    public Person setUriElement(IRIElement uri) {
+        complete();
+        if (uri != null)
+            _setChild(URI, (OMElement)uri);
+        else
+            _removeChildren(URI, false);
+        return this;
+    }
+
+    public IRIElement setUri(String uri) {
+        complete();
+        if (uri != null) {
+            FOMFactory fomfactory = (FOMFactory)factory;
+            IRIElement el = fomfactory.newUri(null);
+            el.setValue(uri);
+            _setChild(URI, (OMElement)el);
+            return el;
+        } else {
+            _removeChildren(URI, false);
+            return null;
+        }
+    }
+
+    public IRI getUri() {
+        IRIElement iri = getUriElement();
+        return (iri != null) ? iri.getResolvedValue() : null;
+    }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMPerson.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMProcessingInstruction.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMProcessingInstruction.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMProcessingInstruction.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMProcessingInstruction.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,79 @@
+/*
+ * 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.abdera2.parser.axiom;
+
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.ProcessingInstruction;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.llom.OMProcessingInstructionImpl;
+
+@SuppressWarnings("unchecked")
+public class FOMProcessingInstruction extends OMProcessingInstructionImpl implements ProcessingInstruction {
+
+    public FOMProcessingInstruction(OMContainer arg0, OMFactory arg1) {
+        super(arg0, arg1);
+    }
+
+    public FOMProcessingInstruction(OMContainer arg0, String arg1, String arg2, OMFactory arg3) {
+        super(arg0, arg1, arg2, arg3);
+    }
+
+    public <T extends Base> T getParentElement() {
+        T parent = (T)super.getParent();
+        return (T)((parent instanceof Element) ? getWrapped((Element)parent) : parent);
+    }
+
+    protected Element getWrapped(Element internal) {
+        if (internal == null)
+            return null;
+        FOMFactory factory = (FOMFactory)getFactory();
+        return factory.getElementWrapper(internal);
+    }
+
+    public Factory getFactory() {
+        return (Factory)this.factory;
+    }
+
+    public String getText() {
+        return getValue();
+    }
+
+    public <T extends ProcessingInstruction> T setText(String text) {
+        if (!isComplete() && builder != null)
+            build();
+        setValue(text);
+        return (T)this;
+    }
+
+    public String toString() {
+        java.io.CharArrayWriter w = new java.io.CharArrayWriter();
+        try {
+            super.serialize(w);
+        } catch (Exception e) {
+        }
+        return w.toString();
+    }
+
+    public void setTarget(String target) {
+        super.setTarget(target);
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMProcessingInstruction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message