abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [25/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/FOMService.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMService.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMService.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMService.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 java.util.ArrayList;
+import java.util.List;
+
+import javax.activation.MimeType;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.selector.Selector;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Service;
+import org.apache.abdera2.model.Workspace;
+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;
+
+@SuppressWarnings("deprecation")
+public class FOMService extends FOMExtensibleElement implements Service {
+
+    private static final long serialVersionUID = 7982751563668891240L;
+
+    public FOMService() {
+        super(Constants.SERVICE, new FOMDocument<Service>(), new FOMFactory());
+        declareAtomNs();
+    }
+
+    public FOMService(String name, OMNamespace namespace, OMContainer parent, OMFactory factory) throws OMException {
+        super(name, namespace, parent, factory);
+        declareAtomNs();
+    }
+
+    public FOMService(QName qname, OMContainer parent, OMFactory factory) {
+        super(qname, parent, factory);
+        declareAtomNs();
+    }
+
+    public FOMService(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) {
+        super(qname, parent, factory, builder);
+        declareAtomNs();
+    }
+
+    public FOMService(OMContainer parent, OMFactory factory) throws OMException {
+        super(SERVICE, parent, factory);
+        declareAtomNs();
+    }
+
+    public FOMService(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(SERVICE, parent, factory, builder);
+        declareAtomNs();
+    }
+
+    private void declareAtomNs() {
+        declareDefaultNamespace(APP_NS);
+        declareNamespace(ATOM_NS, "atom");
+    }
+
+    public List<Workspace> getWorkspaces() {
+        List<Workspace> list = _getChildrenAsSet(WORKSPACE);
+        if (list == null || list.size() == 0)
+            list = _getChildrenAsSet(PRE_RFC_WORKSPACE);
+        return list;
+    }
+
+    public Workspace getWorkspace(String title) {
+        List<Workspace> workspaces = getWorkspaces();
+        Workspace workspace = null;
+        for (Workspace w : workspaces) {
+            if (w.getTitle().equals(title)) {
+                workspace = w;
+                break;
+            }
+        }
+        return workspace;
+    }
+
+    public Service addWorkspace(Workspace workspace) {
+        complete();
+        addChild((OMElement)workspace);
+        return this;
+    }
+
+    public Workspace addWorkspace(String title) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Workspace workspace = fomfactory.newWorkspace(this);
+        workspace.setTitle(title);
+        return workspace;
+    }
+
+    public Collection getCollection(String workspace, String collection) {
+        Collection col = null;
+        Workspace w = getWorkspace(workspace);
+        if (w != null) {
+            col = w.getCollection(collection);
+        }
+        return col;
+    }
+
+    public Collection getCollectionThatAccepts(MimeType... types) {
+        Collection collection = null;
+        for (Workspace workspace : getWorkspaces()) {
+            collection = workspace.getCollectionThatAccepts(types);
+            if (collection != null)
+                break;
+        }
+        return collection;
+    }
+
+    public Collection getCollectionThatAccepts(String... types) {
+        Collection collection = null;
+        for (Workspace workspace : getWorkspaces()) {
+            collection = workspace.getCollectionThatAccepts(types);
+            if (collection != null)
+                break;
+        }
+        return collection;
+    }
+
+    public List<Collection> getCollectionsThatAccept(MimeType... types) {
+        List<Collection> collections = new ArrayList<Collection>();
+        for (Workspace workspace : getWorkspaces()) {
+            List<Collection> colls = workspace.getCollectionsThatAccept(types);
+            collections.addAll(colls);
+        }
+        return collections;
+    }
+
+    public List<Collection> getCollectionsThatAccept(String... types) {
+        List<Collection> collections = new ArrayList<Collection>();
+        for (Workspace workspace : getWorkspaces()) {
+            List<Collection> colls = workspace.getCollectionsThatAccept(types);
+            collections.addAll(colls);
+        }
+        return collections;
+    }
+
+    public List<Workspace> getWorkspaces(Selector selector) {
+      List<Workspace> list = _getChildrenAsSet(WORKSPACE,selector);
+      if (list == null || list.size() == 0)
+          list = _getChildrenAsSet(PRE_RFC_WORKSPACE,selector);
+      return list;
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,660 @@
+/*
+ * 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.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.Categories;
+import org.apache.abdera2.model.Category;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.DateTime;
+import org.apache.abdera2.model.Div;
+import org.apache.abdera2.model.Element;
+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.Source;
+import org.apache.abdera2.model.Text;
+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;
+
+@SuppressWarnings( {"unchecked", "deprecation"})
+public class FOMSource extends FOMExtensibleElement implements Source {
+
+    private static final long serialVersionUID = 9153127297531238021L;
+
+    public FOMSource() {
+        super(Constants.SOURCE);
+    }
+
+    public FOMSource(String name, OMNamespace namespace, OMContainer parent, OMFactory factory) throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMSource(OMContainer parent, OMFactory factory) throws OMException {
+        super(SOURCE, parent, factory);
+    }
+
+    public FOMSource(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(SOURCE, parent, factory, builder);
+    }
+
+    public FOMSource(QName qname, OMContainer parent, OMFactory factory) throws OMException {
+        super(qname, parent, factory);
+    }
+
+    public FOMSource(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder)
+        throws OMException {
+        super(qname, parent, factory, builder);
+    }
+
+    public Person getAuthor() {
+        return (Person)getFirstChildWithName(AUTHOR);
+    }
+
+    public List<Person> getAuthors() {
+        return _getChildrenAsSet(AUTHOR);
+    }
+
+    public <T extends Source> T addAuthor(Person person) {
+        complete();
+        addChild((OMElement)person);
+        return (T)this;
+    }
+
+    public Person addAuthor(String name) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)this.factory;
+        Person person = fomfactory.newAuthor(this);
+        person.setName(name);
+        return person;
+    }
+
+    public Person addAuthor(String name, String email, String uri) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)this.factory;
+        Person person = fomfactory.newAuthor(this);
+        person.setName(name);
+        person.setEmail(email);
+        person.setUri(uri);
+        return person;
+    }
+
+    public List<Category> getCategories() {
+        return _getChildrenAsSet(CATEGORY);
+    }
+
+    public List<Category> getCategories(String scheme) {
+        return FOMElement.getCategories(this, scheme);
+    }
+
+    public <T extends Source> T addCategory(Category category) {
+        complete();
+        Element el = category.getParentElement();
+        if (el != null && el instanceof Categories) {
+            Categories cats = category.getParentElement();
+            category = (Category)category.clone();
+            try {
+                if (category.getScheme() == null && cats.getScheme() != null)
+                    category.setScheme(cats.getScheme().toString());
+            } catch (Exception e) {
+                // Do nothing, shouldn't happen
+            }
+        }
+        addChild((OMElement)category);
+        return (T)this;
+    }
+
+    public Category addCategory(String term) {
+        complete();
+        FOMFactory factory = (FOMFactory)this.factory;
+        Category category = factory.newCategory(this);
+        category.setTerm(term);
+        return category;
+    }
+
+    public Category addCategory(String scheme, String term, String label) {
+        complete();
+        FOMFactory factory = (FOMFactory)this.factory;
+        Category category = factory.newCategory(this);
+        category.setTerm(term);
+        category.setScheme(scheme);
+        category.setLabel(label);
+        return category;
+    }
+
+    public List<Person> getContributors() {
+        return _getChildrenAsSet(CONTRIBUTOR);
+    }
+
+    public <T extends Source> T addContributor(Person person) {
+        complete();
+        addChild((OMElement)person);
+        return (T)this;
+    }
+
+    public Person addContributor(String name) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)this.factory;
+        Person person = fomfactory.newContributor(this);
+        person.setName(name);
+        return person;
+    }
+
+    public Person addContributor(String name, String email, String uri) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)this.factory;
+        Person person = fomfactory.newContributor(this);
+        person.setName(name);
+        person.setEmail(email);
+        person.setUri(uri);
+        return person;
+    }
+
+    public IRIElement getIdElement() {
+        return (IRIElement)getFirstChildWithName(ID);
+    }
+
+    public <T extends Source> T setIdElement(IRIElement id) {
+        complete();
+        if (id != null)
+            _setChild(ID, (OMElement)id);
+        else
+            _removeChildren(ID, false);
+        return (T)this;
+    }
+
+    public IRI getId() {
+        IRIElement id = getIdElement();
+        return (id != null) ? id.getValue() : null;
+    }
+
+    public IRIElement setId(String value) {
+        complete();
+        return setId(value, false);
+    }
+
+    public IRIElement newId() {
+        return setId(this.getFactory().newUuidUri(), false);
+    }
+
+    public IRIElement setId(String value, boolean normalize) {
+        complete();
+        if (value == null) {
+            _removeChildren(ID, false);
+            return null;
+        }
+        IRIElement id = getIdElement();
+        if (id != null) {
+            if (normalize)
+                id.setNormalizedValue(value);
+            else
+                id.setValue(value);
+            return id;
+        } else {
+            FOMFactory fomfactory = (FOMFactory)factory;
+            IRIElement iri = fomfactory.newID(this);
+            iri.setValue((normalize) ? IRI.normalizeString(value) : value);
+            return iri;
+        }
+    }
+
+    public List<Link> getLinks() {
+        return _getChildrenAsSet(LINK);
+    }
+
+    public List<Link> getLinks(String rel) {
+        return getLinks(this, rel);
+    }
+
+    public List<Link> getLinks(String... rels) {
+        return FOMElement.getLinks(this, rels);
+    }
+
+    public <T extends Source> T addLink(Link link) {
+        complete();
+        addChild((OMElement)link);
+        return (T)this;
+    }
+
+    public Link addLink(String href) {
+        return addLink(href, null);
+    }
+
+    public Link addLink(String href, String rel) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Link link = fomfactory.newLink(this);
+        link.setHref(href);
+        if (rel != null)
+            link.setRel(rel);
+        return link;
+    }
+
+    public Link addLink(String href, String rel, String type, String title, String hreflang, long length) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Link link = fomfactory.newLink(this);
+        link.setHref(href);
+        link.setRel(rel);
+        link.setMimeType(type);
+        link.setTitle(title);
+        link.setHrefLang(hreflang);
+        link.setLength(length);
+        return link;
+    }
+
+    public Text getRightsElement() {
+        return getTextElement(RIGHTS);
+    }
+
+    public <T extends Source> T setRightsElement(Text text) {
+        complete();
+        setTextElement(RIGHTS, text, false);
+        return (T)this;
+    }
+
+    public Text setRights(String value) {
+        complete();
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newRights();
+        text.setValue(value);
+        setRightsElement(text);
+        return text;
+    }
+
+    public Text setRightsAsHtml(String value) {
+        return setRights(value, Text.Type.HTML);
+    }
+
+    public Text setRightsAsXhtml(String value) {
+        return setRights(value, Text.Type.XHTML);
+    }
+
+    public Text setRights(String value, Text.Type type) {
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newRights(type);
+        text.setValue(value);
+        setRightsElement(text);
+        return text;
+    }
+
+    public Text setRights(Div value) {
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newRights(Text.Type.XHTML);
+        text.setValueElement(value);
+        setRightsElement(text);
+        return text;
+    }
+
+    public String getRights() {
+        return getText(RIGHTS);
+    }
+
+    public Text getSubtitleElement() {
+        return getTextElement(SUBTITLE);
+    }
+
+    public <T extends Source> T setSubtitleElement(Text text) {
+        complete();
+        setTextElement(SUBTITLE, text, false);
+        return (T)this;
+    }
+
+    public Text setSubtitle(String value) {
+        complete();
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newSubtitle();
+        text.setValue(value);
+        setSubtitleElement(text);
+        return text;
+    }
+
+    public Text setSubtitleAsHtml(String value) {
+        return setSubtitle(value, Text.Type.HTML);
+    }
+
+    public Text setSubtitleAsXhtml(String value) {
+        return setSubtitle(value, Text.Type.XHTML);
+    }
+
+    public Text setSubtitle(String value, Text.Type type) {
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newSubtitle(type);
+        text.setValue(value);
+        setSubtitleElement(text);
+        return text;
+    }
+
+    public Text setSubtitle(Div value) {
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newSubtitle(Text.Type.XHTML);
+        text.setValueElement(value);
+        setSubtitleElement(text);
+        return text;
+    }
+
+    public String getSubtitle() {
+        return getText(SUBTITLE);
+    }
+
+    public Text getTitleElement() {
+        return getTextElement(TITLE);
+    }
+
+    public <T extends Source> T setTitleElement(Text text) {
+        complete();
+        setTextElement(TITLE, text, false);
+        return (T)this;
+    }
+
+    public Text setTitle(String value) {
+        complete();
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newTitle();
+        text.setValue(value);
+        setTitleElement(text);
+        return text;
+    }
+
+    public Text setTitleAsHtml(String value) {
+        return setTitle(value, Text.Type.HTML);
+    }
+
+    public Text setTitleAsXhtml(String value) {
+        return setTitle(value, Text.Type.XHTML);
+    }
+
+    public Text setTitle(String value, Text.Type type) {
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newTitle(type);
+        text.setValue(value);
+        setTitleElement(text);
+        return text;
+    }
+
+    public Text setTitle(Div value) {
+        FOMFactory factory = (FOMFactory)this.factory;
+        Text text = factory.newTitle(Text.Type.XHTML);
+        text.setValueElement(value);
+        setTitleElement(text);
+        return text;
+    }
+
+    public String getTitle() {
+        return getText(TITLE);
+    }
+
+    public DateTime getUpdatedElement() {
+        return (DateTime)getFirstChildWithName(UPDATED);
+    }
+
+    public <T extends Source> T setUpdatedElement(DateTime updated) {
+        complete();
+        if (updated != null)
+            _setChild(UPDATED, (OMElement)updated);
+        else
+            _removeChildren(UPDATED, false);
+        return (T)this;
+    }
+
+    public String getUpdatedString() {
+        DateTime dte = getUpdatedElement();
+        return (dte != null) ? dte.getString() : null;
+    }
+
+    public Date getUpdated() {
+        DateTime dte = getUpdatedElement();
+        return (dte != null) ? dte.getDate() : null;
+    }
+
+    private DateTime setUpdated(org.apache.abdera2.common.date.DateTime value) {
+        complete();
+        if (value == null) {
+            _removeChildren(UPDATED, false);
+            return null;
+        }
+        DateTime dte = getUpdatedElement();
+        if (dte != null) {
+            dte.setValue(value);
+            return dte;
+        } else {
+            FOMFactory fomfactory = (FOMFactory)factory;
+            DateTime dt = fomfactory.newUpdated(this);
+            dt.setValue(value);
+            return dt;
+        }
+    }
+
+    public DateTime setUpdated(Date value) {
+        return setUpdated((value != null) ? org.apache.abdera2.common.date.DateTime.valueOf(value) : null);
+    }
+
+    public DateTime setUpdated(String value) {
+        return setUpdated((value != null) ? org.apache.abdera2.common.date.DateTime.valueOf(value) : null);
+    }
+
+    public Generator getGenerator() {
+        return (Generator)getFirstChildWithName(GENERATOR);
+    }
+
+    public <T extends Source> T setGenerator(Generator generator) {
+        complete();
+        if (generator != null)
+            _setChild(GENERATOR, (OMElement)generator);
+        else
+            _removeChildren(GENERATOR, false);
+        return (T)this;
+    }
+
+    public Generator setGenerator(String uri, String version, String value) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Generator generator = fomfactory.newGenerator(this);
+        if (uri != null)
+            generator.setUri(uri);
+        if (version != null)
+            generator.setVersion(version);
+        if (value != null)
+            generator.setText(value);
+        return generator;
+    }
+
+    public IRIElement getIconElement() {
+        return (IRIElement)getFirstChildWithName(ICON);
+    }
+
+    public <T extends Source> T setIconElement(IRIElement iri) {
+        complete();
+        if (iri != null)
+            _setChild(ICON, (OMElement)iri);
+        else
+            _removeChildren(ICON, false);
+        return (T)this;
+    }
+
+    public IRIElement setIcon(String value) {
+        complete();
+        if (value == null) {
+            _removeChildren(ICON, false);
+            return null;
+        }
+        FOMFactory fomfactory = (FOMFactory)factory;
+        IRIElement iri = fomfactory.newIcon(this);
+        iri.setValue(value);
+        return iri;
+    }
+
+    public IRI getIcon() {
+        IRIElement iri = getIconElement();
+        IRI uri = (iri != null) ? iri.getResolvedValue() : null;
+        return uri;
+    }
+
+    public IRIElement getLogoElement() {
+        return (IRIElement)getFirstChildWithName(LOGO);
+    }
+
+    public <T extends Source> T setLogoElement(IRIElement iri) {
+        complete();
+        if (iri != null)
+            _setChild(LOGO, (OMElement)iri);
+        else
+            _removeChildren(LOGO, false);
+        return (T)this;
+    }
+
+    public IRIElement setLogo(String value) {
+        complete();
+        if (value == null) {
+            _removeChildren(LOGO, false);
+            return null;
+        }
+        FOMFactory fomfactory = (FOMFactory)factory;
+        IRIElement iri = fomfactory.newLogo(this);
+        iri.setValue(value);
+        return iri;
+    }
+
+    public IRI getLogo() {
+        IRIElement iri = getLogoElement();
+        IRI uri = (iri != null) ? iri.getResolvedValue() : null;
+        return uri;
+    }
+
+    public Link getLink(String rel) {
+        List<Link> self = getLinks(rel);
+        Link link = null;
+        if (self.size() > 0)
+            link = self.get(0);
+        return link;
+    }
+
+    public Link getSelfLink() {
+        return getLink(Link.REL_SELF);
+    }
+
+    public Link getAlternateLink() {
+        return getLink(Link.REL_ALTERNATE);
+    }
+
+    public IRI getLinkResolvedHref(String rel) {
+        Link link = getLink(rel);
+        return (link != null) ? link.getResolvedHref() : null;
+    }
+
+    public IRI getSelfLinkResolvedHref() {
+        Link link = getSelfLink();
+        return (link != null) ? link.getResolvedHref() : null;
+    }
+
+    public IRI getAlternateLinkResolvedHref() {
+        Link link = getAlternateLink();
+        return (link != null) ? link.getResolvedHref() : null;
+    }
+
+    public Text.Type getRightsType() {
+        Text text = getRightsElement();
+        return (text != null) ? text.getTextType() : null;
+    }
+
+    public Text.Type getSubtitleType() {
+        Text text = getSubtitleElement();
+        return (text != null) ? text.getTextType() : null;
+    }
+
+    public Text.Type getTitleType() {
+        Text text = getTitleElement();
+        return (text != null) ? text.getTextType() : null;
+    }
+
+    public Collection getCollection() {
+        Collection coll = getFirstChild(COLLECTION);
+        if (coll == null)
+            coll = getFirstChild(PRE_RFC_COLLECTION);
+        return coll;
+    }
+
+    public <T extends Source> T setCollection(Collection collection) {
+        complete();
+        if (collection != null) {
+            _removeChildren(PRE_RFC_COLLECTION, true);
+            _setChild(COLLECTION, (OMElement)collection);
+        } else {
+            _removeChildren(COLLECTION, false);
+        }
+        return (T)this;
+    }
+
+    public Link getAlternateLink(String type, String hreflang) {
+        return selectLink(getLinks(Link.REL_ALTERNATE), type, hreflang);
+    }
+
+    public IRI getAlternateLinkResolvedHref(String type, String hreflang) {
+        Link link = getAlternateLink(type, hreflang);
+        return (link != null) ? link.getResolvedHref() : null;
+    }
+
+    public Feed getAsFeed() {
+        FOMFeed feed = (FOMFeed)((FOMFactory)factory).newFeed();
+        for (Iterator<FOMElement> i = this.getChildElements(); i.hasNext();) {
+            FOMElement child = i.next();
+            if (!child.getQName().equals(ENTRY)) {
+                feed.addChild((OMNode)child.clone());
+            }
+        }
+        try {
+            if (this.getBaseUri() != null) {
+                feed.setBaseUri(this.getBaseUri());
+            }
+        } catch (Exception e) {
+        }
+        return feed;
+    }
+
+    public List<Person> getAuthors(Selector selector) {
+      return _getChildrenAsSet(AUTHOR,selector);
+    }
+
+    public List<Category> getCategories(Selector selector) {
+      return _getChildrenAsSet(AUTHOR,selector);
+    }
+
+    public List<Person> getContributors(Selector selector) {
+      return _getChildrenAsSet(AUTHOR,selector);
+    }
+
+    public List<Link> getLinks(Selector selector) {
+      return _getChildrenAsSet(AUTHOR,selector);
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMText.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMText.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMText.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMText.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,228 @@
+/*
+ * 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.Div;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Text;
+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;
+
+@SuppressWarnings("unchecked")
+public class FOMText extends FOMElement implements Text {
+
+    private static final long serialVersionUID = 5177795905116574120L;
+    protected Type type = Type.TEXT;
+
+    public FOMText(QName qname, Text.Type type) {
+        super(qname);
+        init(type);
+    }
+
+    public FOMText(Type type, String name, OMNamespace namespace, OMContainer parent, OMFactory factory)
+        throws OMException {
+        super(name, namespace, parent, factory);
+        init(type);
+    }
+
+    public FOMText(Type type, QName qname, OMContainer parent, OMFactory factory) throws OMException {
+        super(qname, parent, factory);
+        init(type);
+    }
+
+    public FOMText(Type type, QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder)
+        throws OMException {
+        super(qname, parent, factory, builder);
+        init(type);
+    }
+
+    private void init(Type type) {
+        this.type = type;
+        if (type == null)
+          removeAttribute(TYPE);
+        else 
+          setAttributeValue(TYPE,type.name().toLowerCase());
+    }
+
+    public final Type getTextType() {
+        return type;
+    }
+
+    public Text setTextType(Type type) {
+        complete();
+        init(type);
+        return this;
+    }
+
+    public Div getValueElement() {
+        return (Div)this.getFirstChildWithName(Constants.DIV);
+    }
+
+    public Text setValueElement(Div value) {
+        complete();
+        if (value != null) {
+            if (this.getFirstChildWithName(Constants.DIV) != null)
+                this.getFirstChildWithName(Constants.DIV).discard();
+            init(Text.Type.XHTML);
+            this.setFirstChild((OMElement)value);
+        } else
+            _removeAllChildren();
+        return this;
+    }
+
+    public String getValue() {
+        String val = null;
+        if (Type.TEXT.equals(type)) {
+            val = getText();
+        } else if (Type.HTML.equals(type)) {
+            val = getText();
+        } else if (Type.XHTML.equals(type)) {
+            FOMDiv div = (FOMDiv)this.getFirstChildWithName(Constants.DIV);
+            val = (div != null) ? div.getInternalValue() : null;
+        }
+        return val;
+    }
+
+    public void setText(String value) {
+        setText(Text.Type.TEXT, value);
+    }
+
+    public <T extends Element> T setText(Text.Type type, String value) {
+        complete();
+        init(type);
+        if (value != null) {
+            OMNode child = this.getFirstOMChild();
+            while (child != null) {
+                if (child.getType() == OMNode.TEXT_NODE) {
+                    child.detach();
+                }
+                child = child.getNextOMSibling();
+            }
+            getOMFactory().createOMText(this, value);
+        } else
+            _removeAllChildren();
+        return (T)this;
+    }
+
+    public Text setValue(String value) {
+        complete();
+        if (value != null) {
+            if (Type.TEXT.equals(type)) {
+                setText(type, value);
+            } else if (Type.HTML.equals(type)) {
+                setText(type, value);
+            } else if (Type.XHTML.equals(type)) {
+                IRI baseUri = null;
+                value = "<div xmlns=\"" + XHTML_NS + "\">" + value + "</div>";
+                Element element = null;
+                try {
+                    baseUri = getResolvedBaseUri();
+                    element = _parse(value, baseUri);
+                } catch (Exception e) {
+                }
+                if (element != null && element instanceof Div)
+                    setValueElement((Div)element);
+            }
+        } else
+            _removeAllChildren();
+        return this;
+    }
+
+    public String getWrappedValue() {
+        if (Type.XHTML.equals(type)) {
+            return this.getFirstChildWithName(Constants.DIV).toString();
+        } else {
+            return getValue();
+        }
+    }
+
+    public Text setWrappedValue(String wrappedValue) {
+        complete();
+        if (Type.XHTML.equals(type)) {
+            IRI baseUri = null;
+            Element element = null;
+            try {
+                baseUri = getResolvedBaseUri();
+                element = _parse(wrappedValue, baseUri);
+            } catch (Exception e) {
+            }
+
+            if (element != null && element instanceof Div)
+                setValueElement((Div)element);
+        } else {
+            setValue(wrappedValue);
+        }
+        return this;
+    }
+
+    @Override
+    public IRI getBaseUri() {
+        if (Type.XHTML.equals(type)) {
+            Element el = getValueElement();
+            if (el != null) {
+                if (el.getAttributeValue(BASE) != null) {
+                    if (getAttributeValue(BASE) != null)
+                        return super.getBaseUri().resolve(el.getAttributeValue(BASE));
+                    else
+                        return _getUriValue(el.getAttributeValue(BASE));
+                }
+            }
+        }
+        return super.getBaseUri();
+    }
+
+    @Override
+    public IRI getResolvedBaseUri() {
+        if (Type.XHTML.equals(type)) {
+            Element el = getValueElement();
+            if (el != null) {
+                if (el.getAttributeValue(BASE) != null) {
+                    return super.getResolvedBaseUri().resolve(el.getAttributeValue(BASE));
+                }
+            }
+        }
+        return super.getResolvedBaseUri();
+    }
+
+    @Override
+    public String getLanguage() {
+        if (Type.XHTML.equals(type)) {
+            Element el = getValueElement();
+            if (el != null && el.getAttributeValue(LANG) != null)
+                return el.getAttributeValue(LANG);
+        }
+        return super.getLanguage();
+    }
+
+    @Override
+    public Object clone() {
+        FOMText text = (FOMText)super.clone();
+        text.type = type;
+        return text;
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMTextValue.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMTextValue.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMTextValue.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMTextValue.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,108 @@
+/*
+ * 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.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.TextValue;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.llom.OMTextImpl;
+
+@SuppressWarnings("unchecked")
+public class FOMTextValue extends OMTextImpl implements TextValue {
+
+    public FOMTextValue(Object arg0, boolean arg1, OMFactory arg2) {
+        super(arg0, arg1, arg2);
+    }
+
+    public FOMTextValue(Object arg0, OMFactory arg1) {
+        super(arg0, arg1);
+    }
+
+    public FOMTextValue(OMContainer arg0, char[] arg1, int arg2, OMFactory arg3) {
+        super(arg0, arg1, arg2, arg3);
+    }
+
+    public FOMTextValue(OMContainer arg0, QName arg1, int arg2, OMFactory arg3) {
+        super(arg0, arg1, arg2, arg3);
+    }
+
+    public FOMTextValue(OMContainer arg0, QName arg1, OMFactory arg2) {
+        super(arg0, arg1, arg2);
+    }
+
+    public FOMTextValue(OMContainer arg0, String arg1, int arg2, OMFactory arg3) {
+        super(arg0, arg1, arg2, arg3);
+    }
+
+    public FOMTextValue(OMContainer arg0, String arg1, OMFactory arg2) {
+        super(arg0, arg1, arg2);
+    }
+
+    public FOMTextValue(OMContainer arg0, String arg1, String arg2, boolean arg3, OMFactory arg4) {
+        super(arg0, arg1, arg2, arg3, arg4);
+    }
+
+    public FOMTextValue(String arg0, int arg1, OMFactory arg2) {
+        super(arg0, arg1, arg2);
+    }
+
+    public FOMTextValue(String arg0, OMContainer arg1, OMXMLParserWrapper arg2, OMFactory arg3) {
+        super(arg0, arg1, arg2, arg3);
+    }
+
+    public FOMTextValue(String arg0, OMFactory arg1) {
+        super(arg0, arg1);
+    }
+
+    public FOMTextValue(String arg0, String arg1, boolean arg2, OMFactory arg3) {
+        super(arg0, arg1, arg2, arg3);
+    }
+
+    public DataHandler getDataHandler() {
+        return (DataHandler)super.getDataHandler();
+    }
+
+    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;
+    }
+
+    @Override
+    public String toString() {
+        return getText();
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedContentTypeException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedContentTypeException.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedContentTypeException.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedContentTypeException.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+public class FOMUnsupportedContentTypeException extends FOMException {
+
+    private static final long serialVersionUID = 4156893310308105899L;
+
+    public FOMUnsupportedContentTypeException(String message) {
+        super(Localizer.sprintf("UNSUPPORTED.CONTENT.TYPE", message));
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedTextTypeException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedTextTypeException.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedTextTypeException.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMUnsupportedTextTypeException.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+public class FOMUnsupportedTextTypeException extends FOMException {
+
+    private static final long serialVersionUID = 4156893310308105899L;
+
+    public FOMUnsupportedTextTypeException(String message) {
+        super(Localizer.sprintf("UNSUPPORTED.TEXT.TYPE", message));
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWorkspace.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWorkspace.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWorkspace.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWorkspace.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,180 @@
+/*
+ * 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.List;
+
+import javax.activation.MimeType;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.selector.Selector;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Text;
+import org.apache.abdera2.model.Workspace;
+import org.apache.abdera2.model.selector.CollectionAcceptSelector;
+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;
+
+@SuppressWarnings("deprecation")
+public class FOMWorkspace extends FOMExtensibleElement implements Workspace {
+
+    private static final long serialVersionUID = -421749865550509424L;
+
+    public FOMWorkspace() {
+        super(Constants.WORKSPACE);
+    }
+
+    public FOMWorkspace(String title) {
+        this();
+        setTitle(title);
+    }
+
+    public FOMWorkspace(String name, OMNamespace namespace, OMContainer parent, OMFactory factory)
+        throws OMException {
+        super(name, namespace, parent, factory);
+    }
+
+    public FOMWorkspace(QName qname, OMContainer parent, OMFactory factory) throws OMException {
+        super(qname, parent, factory);
+    }
+
+    public FOMWorkspace(QName qname, OMContainer parent, OMFactory factory, OMXMLParserWrapper builder)
+        throws OMException {
+        super(qname, parent, factory, builder);
+    }
+
+    public FOMWorkspace(OMContainer parent, OMFactory factory) throws OMException {
+        super(WORKSPACE, parent, factory);
+    }
+
+    public FOMWorkspace(OMContainer parent, OMFactory factory, OMXMLParserWrapper builder) throws OMException {
+        super(WORKSPACE, parent, factory, builder);
+    }
+
+    public String getTitle() {
+        Text title = this.getFirstChild(TITLE);
+        return (title != null) ? title.getValue() : null;
+    }
+
+    private Text setTitle(String title, Text.Type type) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Text text = fomfactory.newText(PREFIXED_TITLE, type);
+        text.setValue(title);
+        this._setChild(PREFIXED_TITLE, (OMElement)text);
+        return text;
+    }
+
+    public Text setTitle(String title) {
+        return setTitle(title, Text.Type.TEXT);
+    }
+
+    public Text setTitleAsHtml(String title) {
+        return setTitle(title, Text.Type.HTML);
+    }
+
+    public Text setTitleAsXHtml(String title) {
+        return setTitle(title, Text.Type.XHTML);
+    }
+
+    public Text getTitleElement() {
+        return getFirstChild(TITLE);
+    }
+
+    public List<Collection> getCollections() {
+        List<Collection> list = _getChildrenAsSet(COLLECTION);
+        if (list == null || list.size() == 0)
+            list = _getChildrenAsSet(PRE_RFC_COLLECTION);
+        return list;
+    }
+
+    public Collection getCollection(String title) {
+        List<Collection> cols = getCollections();
+        Collection col = null;
+        for (Collection c : cols) {
+            if (c.getTitle().equals(title)) {
+                col = c;
+                break;
+            }
+        }
+        return col;
+    }
+
+    public Workspace addCollection(Collection collection) {
+        complete();
+        addChild((OMElement)collection);
+        return this;
+    }
+
+    public Collection addCollection(String title, String href) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Collection collection = fomfactory.newCollection(this);
+        collection.setTitle(title);
+        collection.setHref(href);
+        return collection;
+    }
+
+    public Collection addMultipartCollection(String title, String href) {
+        complete();
+        FOMFactory fomfactory = (FOMFactory)factory;
+        Collection collection = fomfactory.newMultipartCollection(this);
+        collection.setTitle(title);
+        collection.setHref(href);
+        return collection;
+    }
+
+    public Collection getCollectionThatAccepts(MimeType... types) {
+      CollectionAcceptSelector sel =
+        new CollectionAcceptSelector(types);
+      List<Collection> list = getCollections(sel);
+      return list.size() > 0 ? list.get(0) : null;
+    }
+
+    public Collection getCollectionThatAccepts(String... types) {
+      CollectionAcceptSelector sel =
+        new CollectionAcceptSelector(types);
+      List<Collection> list = getCollections(sel);
+      return list.size() > 0 ? list.get(0) : null;
+    }
+
+    public List<Collection> getCollectionsThatAccept(MimeType... types) {
+      CollectionAcceptSelector sel =
+        new CollectionAcceptSelector(types);
+      return getCollections(sel);
+    }
+
+    public List<Collection> getCollectionsThatAccept(String... types) {
+      CollectionAcceptSelector sel =
+        new CollectionAcceptSelector(types);
+      return getCollections(sel);
+    }
+
+    public List<Collection> getCollections(Selector selector) {
+      List<Collection> list = _getChildrenAsSet(COLLECTION,selector);
+      if (list == null || list.size() == 0)
+          list = _getChildrenAsSet(PRE_RFC_COLLECTION,selector);
+      return list;
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriter.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,99 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.writer.AbstractWriter;
+import org.apache.abdera2.writer.WriterOptions;
+
+@Name("default")
+public class FOMWriter extends AbstractWriter {
+
+    public FOMWriter() {
+      super(
+        Constants.ATOM_MEDIA_TYPE, 
+        Constants.APP_MEDIA_TYPE, 
+        Constants.CAT_MEDIA_TYPE,
+        Constants.XML_MEDIA_TYPE);
+    }
+
+    public FOMWriter(Abdera abdera) {
+      super(
+          Constants.ATOM_MEDIA_TYPE, 
+          Constants.APP_MEDIA_TYPE, 
+          Constants.CAT_MEDIA_TYPE,
+          Constants.XML_MEDIA_TYPE);
+    }
+    
+    public void writeTo(Base base, OutputStream out, WriterOptions options) throws IOException {
+        out = getCompressedOutputStream(out, options);
+        String charset = options.getCharset();
+        if (charset == null) {
+            if (base instanceof Document)
+                charset = ((Document<?>)base).getCharset();
+            else if (base instanceof Element) {
+                Document<?> doc = ((Element)base).getDocument();
+                if (doc != null)
+                    charset = doc.getCharset();
+            }
+            if (charset == null)
+                charset = "UTF-8";
+        } else {
+            Document<?> doc = null;
+            if (base instanceof Document)
+                doc = (Document<?>)base;
+            else if (base instanceof Element)
+                doc = ((Element)base).getDocument();
+            if (doc != null)
+                doc.setCharset(charset);
+        }
+        base.writeTo(new OutputStreamWriter(out, charset));
+        finishCompressedOutputStream(out, options);
+        if (options.getAutoClose())
+            out.close();
+    }
+
+    public void writeTo(Base base, Writer out, WriterOptions options) throws IOException {
+        base.writeTo(out);
+        if (options.getAutoClose())
+            out.close();
+    }
+
+    public Object write(Base base, WriterOptions options) throws IOException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        writeTo(base, out, options);
+        return out.toString();
+    }
+
+    @Override
+    protected WriterOptions initDefaultWriterOptions() {
+        return new FOMWriterOptions();
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterFactory.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterFactory.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterFactory.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterFactory.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,95 @@
+/*
+ * 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.common.Localizer;
+import org.apache.abdera2.writer.StreamWriter;
+import org.apache.abdera2.writer.Writer;
+import org.apache.abdera2.writer.WriterFactory;
+
+@SuppressWarnings("unchecked")
+public class FOMWriterFactory implements WriterFactory {
+
+    private final Abdera abdera;
+    private final Map<String, Writer> writers;
+    private final Map<String, Class<? extends StreamWriter>> streamwriters;
+
+    public FOMWriterFactory() {
+        this(Abdera.getInstance());
+    }
+
+    public FOMWriterFactory(Abdera abdera) {
+        this.abdera = abdera;
+        Map<String, Writer> w = getAbdera().getConfiguration().getWriters();
+        writers = (w != null) ? w : new HashMap<String, Writer>();
+
+        Map<String, Class<? extends StreamWriter>> s = getAbdera().getConfiguration().getStreamWriters();
+        streamwriters = (s != null) ? s : new HashMap<String, Class<? extends StreamWriter>>();
+    }
+
+    protected Abdera getAbdera() {
+        return abdera;
+    }
+
+    public <T extends Writer> T getWriter() {
+        return (T)getAbdera().getWriter();
+    }
+
+    public <T extends Writer> T getWriter(String name) {
+        return (T)((name != null) ? getWriters().get(name.toLowerCase()) : getWriter());
+    }
+
+    public <T extends Writer> T getWriterByMediaType(String mediatype) {
+        Map<String, Writer> writers = getWriters();
+        for (Writer writer : writers.values()) {
+            if (writer.outputsFormat(mediatype))
+                return (T)writer;
+        }
+        return null;
+    }
+
+    private Map<String, Writer> getWriters() {
+        return writers;
+    }
+
+    private Map<String, Class<? extends StreamWriter>> getStreamWriters() {
+        return streamwriters;
+    }
+
+    public <T extends StreamWriter> T newStreamWriter() {
+        return (T)getAbdera().create(StreamWriter.class);
+    }
+
+    public <T extends StreamWriter> T newStreamWriter(String name) {
+        Class<? extends StreamWriter> _class = getStreamWriters().get(name);
+        StreamWriter sw = null;
+        if (_class != null) {
+            try {
+                sw = _class.newInstance();
+            } catch (Exception e) {
+                throw new RuntimeException(Localizer.sprintf("IMPLEMENTATION.NOT.AVAILABLE", "StreamWriter"), e);
+            }
+        }
+        return (T)sw;
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterOptions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterOptions.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterOptions.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMWriterOptions.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,24 @@
+/*
+ * 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.writer.AbstractWriterOptions;
+
+public class FOMWriterOptions extends AbstractWriterOptions {
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,275 @@
+/*
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.ElementWrapper;
+import org.apache.abdera2.xpath.AbstractXPath;
+import org.apache.abdera2.xpath.XPathException;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.xpath.DocumentNavigator;
+import org.jaxen.BaseXPath;
+import org.jaxen.Function;
+import org.jaxen.FunctionContext;
+import org.jaxen.JaxenException;
+import org.jaxen.SimpleFunctionContext;
+import org.jaxen.SimpleVariableContext;
+import org.jaxen.VariableContext;
+import org.jaxen.XPath;
+
+@SuppressWarnings("unchecked")
+public class FOMXPath extends AbstractXPath {
+
+    private final Map<QName, Function> functions;
+    private final Map<QName, Object> variables;
+
+    public FOMXPath(Abdera abdera) {
+        this(null, null, null);
+    }
+
+    protected FOMXPath(Map<String, String> defaultNamespaces) {
+        this(defaultNamespaces, null, null);
+    }
+
+    protected FOMXPath(Map<String, String> defaultNamespaces,
+                       Map<QName, Function> defaultFunctions,
+                       Map<QName, Object> defaultVariables) {
+        super(defaultNamespaces);
+        functions = (defaultFunctions != null) ? defaultFunctions : initDefaultFunctions();
+        variables = (defaultVariables != null) ? defaultVariables : initDefaultVariables();
+    }
+
+    protected Map<String, String> initDefaultNamespaces() {
+        Map<String, String> namespaces = super.initDefaultNamespaces();
+        namespaces.put("abdera", "http://abdera.apache.org");
+        return namespaces;
+    }
+
+    private Map<QName, Function> initDefaultFunctions() {
+        Map<QName, Function> functions = new HashMap<QName, Function>();
+        functions.put(ResolveFunction.QNAME, new ResolveFunction());
+        return functions;
+    }
+
+    private Map<QName, Object> initDefaultVariables() {
+        Map<QName, Object> variables = new HashMap<QName, Object>();
+        return variables;
+    }
+
+    public static XPath getXPath(String path) throws JaxenException {
+        return getXPath(path, null);
+    }
+
+    private static FunctionContext getFunctionContext(Map<QName, Function> functions, SimpleFunctionContext context) {
+        if (context == null)
+            context = new SimpleFunctionContext();
+        for (QName qname : functions.keySet()) {
+            Function function = functions.get(qname);
+            context.registerFunction(qname.getNamespaceURI(), qname.getLocalPart(), function);
+        }
+        return context;
+    }
+
+    private static VariableContext getVariableContext(Map<QName, Object> variables, SimpleVariableContext context) {
+        if (context == null)
+            context = new SimpleVariableContext();
+        for (QName qname : variables.keySet()) {
+            Object value = variables.get(qname);
+            context.setVariableValue(qname.getNamespaceURI(), qname.getLocalPart(), value);
+        }
+        return context;
+    }
+
+    public static XPath getXPath(String path,
+                                 Map<String, String> namespaces,
+                                 Map<QName, Function> functions,
+                                 Map<QName, Object> variables) throws JaxenException {
+        DocumentNavigator nav = new DocumentNavigator();
+        XPath contextpath = new BaseXPath(path, nav);
+        if (namespaces != null) {
+            for (Map.Entry<String, String> entry : namespaces.entrySet()) {
+                contextpath.addNamespace(entry.getKey(), entry.getValue());
+            }
+        }
+        if (functions != null) {
+            contextpath.setFunctionContext(getFunctionContext(functions, (SimpleFunctionContext)contextpath
+                .getFunctionContext()));
+        }
+        if (variables != null)
+            contextpath.setVariableContext(getVariableContext(variables, (SimpleVariableContext)contextpath
+                .getVariableContext()));
+        return contextpath;
+    }
+
+    public static XPath getXPath(String path, Map<String, String> namespaces) throws JaxenException {
+        return getXPath(path, namespaces, null, null);
+    }
+
+    public List<Object> selectNodes(String path,
+                            Base base,
+                            Map<String, String> namespaces,
+                            Map<QName, Function> functions,
+                            Map<QName, Object> variables) throws XPathException {
+        try {
+            base = getElementWrapped(base);
+            List<Object> nodes = new ArrayList<Object>();
+            XPath xpath = getXPath(path, namespaces, functions, variables);
+            List<Object> results = xpath.selectNodes(base);
+            for (Object obj : results) {
+                if (obj instanceof OMAttribute) {
+                    nodes.add(new FOMAttribute((OMAttribute)obj));
+                } else {
+                    nodes.add(obj);
+                }
+            }
+            return nodes;
+        } catch (JaxenException e) {
+            throw new XPathException(e);
+        }
+    }
+
+    public List<Object> selectNodes(String path, Base base, Map<String, String> namespaces) throws XPathException {
+        return selectNodes(path, base, namespaces, functions, variables);
+    }
+
+    public Object selectSingleNode(String path,
+                                   Base base,
+                                   Map<String, String> namespaces,
+                                   Map<QName, Function> functions,
+                                   Map<QName, Object> variables) throws XPathException {
+        try {
+            base = getElementWrapped(base);
+            XPath xpath = getXPath(path, namespaces, functions, variables);
+            Object obj = xpath.selectSingleNode(base);
+            if (obj instanceof OMAttribute)
+                obj = new FOMAttribute((OMAttribute)obj);
+            return obj;
+        } catch (JaxenException e) {
+            throw new XPathException(e);
+        }
+    }
+
+    public Object selectSingleNode(String path, Base base, Map<String, String> namespaces) throws XPathException {
+        return selectSingleNode(path, base, namespaces, functions, variables);
+    }
+
+    public Object evaluate(String path,
+                           Base base,
+                           Map<String, String> namespaces,
+                           Map<QName, Function> functions,
+                           Map<QName, Object> variables) throws XPathException {
+        try {
+            base = getElementWrapped(base);
+            XPath xpath = getXPath(path, namespaces, functions, variables);
+            return xpath.evaluate(base);
+        } catch (JaxenException e) {
+            throw new XPathException(e);
+        }
+    }
+
+    public Object evaluate(String path, Base base, Map<String, String> namespaces) throws XPathException {
+        return evaluate(path, base, namespaces, functions, variables);
+    }
+
+    public String valueOf(String path,
+                          Base base,
+                          Map<String, String> namespaces,
+                          Map<QName, Function> functions,
+                          Map<QName, Object> variables) throws XPathException {
+        try {
+            base = getElementWrapped(base);
+            XPath xpath = getXPath(path, namespaces, functions, variables);
+            return xpath.stringValueOf(base);
+        } catch (JaxenException e) {
+            throw new XPathException(e);
+        }
+    }
+
+    public String valueOf(String path, Base base, Map<String, String> namespaces) throws XPathException {
+        return valueOf(path, base, namespaces, functions, variables);
+    }
+
+    public boolean booleanValueOf(String path,
+                                  Base base,
+                                  Map<String, String> namespaces,
+                                  Map<QName, Function> functions,
+                                  Map<QName, Object> variables) throws XPathException {
+        try {
+            base = getElementWrapped(base);
+            XPath xpath = getXPath(path, namespaces, functions, variables);
+            return xpath.booleanValueOf(base);
+        } catch (JaxenException e) {
+            throw new XPathException(e);
+        }
+    }
+
+    public boolean booleanValueOf(String path, Base base, Map<String, String> namespaces) throws XPathException {
+        return booleanValueOf(path, base, namespaces, functions, variables);
+    }
+
+    public Number numericValueOf(String path,
+                                 Base base,
+                                 Map<String, String> namespaces,
+                                 Map<QName, Function> functions,
+                                 Map<QName, Object> variables) throws XPathException {
+        try {
+            base = getElementWrapped(base);
+            XPath xpath = getXPath(path, namespaces, functions, variables);
+            return xpath.numberValueOf(base);
+        } catch (JaxenException e) {
+            throw new XPathException(e);
+        }
+    }
+
+    public Number numericValueOf(String path, Base base, Map<String, String> namespaces) throws XPathException {
+        return numericValueOf(path, base, namespaces, functions, variables);
+    }
+
+    public Map<QName, Function> getDefaultFunctions() {
+        return new HashMap<QName, Function>(functions);
+    }
+
+    public synchronized void setDefaultFunctions(Map<QName, Function> functions) {
+        this.functions.clear();
+        this.functions.putAll(functions);
+    }
+
+    public Map<QName, Object> getDefaultVariables() {
+        return new HashMap<QName, Object>(variables);
+    }
+
+    public synchronized void setDefaultVariables(Map<QName, Object> variables) {
+        this.variables.clear();
+        this.variables.putAll(variables);
+    }
+
+    private Base getElementWrapped(Base base) {
+        if (base instanceof ElementWrapper) {
+            base = ((ElementWrapper)base).getInternal();
+        }
+        return base;
+    }
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/PrettyWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/PrettyWriter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/PrettyWriter.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/PrettyWriter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,292 @@
+package org.apache.abdera2.parser.axiom;
+
+/*
+ * 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.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.ElementWrapper;
+import org.apache.abdera2.writer.AbstractWriter;
+import org.apache.abdera2.writer.AbstractWriterOptions;
+import org.apache.abdera2.writer.WriterOptions;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
+
+@Name("PrettyXML")
+public class PrettyWriter extends AbstractWriter {
+
+    public PrettyWriter() {
+        super("application/atom+xml", "application/atomserv+xml", "application/xml");
+    }
+
+    public Object write(Base base, WriterOptions options) throws IOException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        writeTo(base, out, options);
+        return out.toString();
+    }
+
+    public void writeTo(Base base, OutputStream out, WriterOptions options) throws IOException {
+        out = getCompressedOutputStream(out, options);
+        String charset = options.getCharset() != null ? options.getCharset() : "UTF-8";
+        writeTo(base, new OutputStreamWriter(out, charset), options);
+        finishCompressedOutputStream(out, options);
+        if (options.getAutoClose())
+            out.close();
+    }
+
+    public void writeTo(Base base, Writer out, WriterOptions options) throws IOException {
+        try {
+            XMLStreamWriter w = StAXUtils.createXMLStreamWriter(out);
+            XMLStreamWriter pw = new PrettyStreamWriter(w);
+            OMElement om = (base instanceof Document) ? getOMElement(((Document<?>)base).getRoot()) : (OMElement)base;
+            String charset = options.getCharset();
+            String xmlver = null;
+            if (om.getParent() != null && om.getParent() instanceof OMDocument) {
+                OMDocument doc = (OMDocument)om.getParent();
+                charset = charset != null ? charset : doc.getCharsetEncoding();
+                xmlver = doc.getXMLVersion();
+                pw.writeStartDocument(charset, xmlver);   
+            }
+            om.serialize(pw);
+            pw.writeEndDocument();
+            if (options.getAutoClose())
+                out.close();
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private OMElement getOMElement(Element el) {
+        if (el instanceof ElementWrapper) {
+            return getOMElement(((ElementWrapper)el).getInternal());
+        } else
+            return (OMElement)el;
+    }
+
+    private static class PrettyStreamWriter implements XMLStreamWriter {
+
+        private static final int INDENT = 2;
+
+        private XMLStreamWriter internal = null;
+        private int depth = 0;
+        private boolean prev_was_end_element = false;
+
+        public PrettyStreamWriter(XMLStreamWriter writer) {
+            this.internal = writer;
+        }
+
+        public void close() throws XMLStreamException {
+            internal.close();
+        }
+
+        public void flush() throws XMLStreamException {
+            internal.flush();
+        }
+
+        public NamespaceContext getNamespaceContext() {
+            return internal.getNamespaceContext();
+        }
+
+        public String getPrefix(String arg0) throws XMLStreamException {
+            return internal.getPrefix(arg0);
+        }
+
+        public Object getProperty(String arg0) throws IllegalArgumentException {
+            return internal.getProperty(arg0);
+        }
+
+        public void setDefaultNamespace(String arg0) throws XMLStreamException {
+            internal.setDefaultNamespace(arg0);
+        }
+
+        public void setNamespaceContext(NamespaceContext arg0) throws XMLStreamException {
+            internal.setNamespaceContext(arg0);
+        }
+
+        public void setPrefix(String arg0, String arg1) throws XMLStreamException {
+            internal.setPrefix(arg0, arg1);
+        }
+
+        public void writeAttribute(String arg0, String arg1) throws XMLStreamException {
+            internal.writeAttribute(arg0, arg1);
+            prev_was_end_element = false;
+        }
+
+        public void writeAttribute(String arg0, String arg1, String arg2) throws XMLStreamException {
+            internal.writeAttribute(arg0, arg1, arg2);
+            prev_was_end_element = false;
+        }
+
+        public void writeAttribute(String arg0, String arg1, String arg2, String arg3) throws XMLStreamException {
+            internal.writeAttribute(arg0, arg1, arg2, arg3);
+            prev_was_end_element = false;
+        }
+
+        public void writeCData(String arg0) throws XMLStreamException {
+            internal.writeCData(arg0);
+            prev_was_end_element = false;
+        }
+
+        public void writeCharacters(String arg0) throws XMLStreamException {
+            internal.writeCharacters(arg0);
+            prev_was_end_element = false;
+        }
+
+        public void writeCharacters(char[] arg0, int arg1, int arg2) throws XMLStreamException {
+            internal.writeCharacters(arg0, arg1, arg2);
+            prev_was_end_element = false;
+        }
+
+        public void writeComment(String arg0) throws XMLStreamException {
+            writeIndent();
+            internal.writeComment(arg0);
+            prev_was_end_element = true;
+        }
+
+        public void writeDTD(String arg0) throws XMLStreamException {
+            internal.writeDTD(arg0);
+            prev_was_end_element = true;
+        }
+
+        public void writeDefaultNamespace(String arg0) throws XMLStreamException {
+            internal.writeDefaultNamespace(arg0);
+            prev_was_end_element = false;
+        }
+
+        public void writeEmptyElement(String arg0) throws XMLStreamException {
+            writeIndent();
+            internal.writeEmptyElement(arg0);
+            prev_was_end_element = true;
+        }
+
+        public void writeEmptyElement(String arg0, String arg1) throws XMLStreamException {
+            writeIndent();
+            internal.writeEmptyElement(arg0, arg1);
+            prev_was_end_element = true;
+        }
+
+        public void writeEmptyElement(String arg0, String arg1, String arg2) throws XMLStreamException {
+            writeIndent();
+            internal.writeEmptyElement(arg0, arg1, arg2);
+            prev_was_end_element = true;
+        }
+
+        public void writeEndDocument() throws XMLStreamException {
+            internal.writeEndDocument();
+            prev_was_end_element = false;
+        }
+
+        public void writeEndElement() throws XMLStreamException {
+            depth--;
+            if (prev_was_end_element)
+                writeIndent();
+            internal.writeEndElement();
+            prev_was_end_element = true;
+        }
+
+        public void writeEntityRef(String arg0) throws XMLStreamException {
+            internal.writeEntityRef(arg0);
+            prev_was_end_element = false;
+        }
+
+        public void writeNamespace(String arg0, String arg1) throws XMLStreamException {
+            internal.writeNamespace(arg0, arg1);
+            prev_was_end_element = false;
+        }
+
+        public void writeProcessingInstruction(String arg0) throws XMLStreamException {
+            writeIndent();
+            internal.writeProcessingInstruction(arg0);
+            prev_was_end_element = true;
+        }
+
+        public void writeProcessingInstruction(String arg0, String arg1) throws XMLStreamException {
+            writeIndent();
+            internal.writeProcessingInstruction(arg0, arg1);
+            prev_was_end_element = true;
+        }
+
+        public void writeStartDocument() throws XMLStreamException {
+            internal.writeStartDocument();
+            prev_was_end_element = false;
+        }
+
+        public void writeStartDocument(String arg0) throws XMLStreamException {
+            internal.writeStartDocument(arg0);
+            prev_was_end_element = false;
+        }
+
+        public void writeStartDocument(String arg0, String arg1) throws XMLStreamException {
+            internal.writeStartDocument(arg0, arg1);
+            prev_was_end_element = false;
+        }
+
+        public void writeStartElement(String arg0) throws XMLStreamException {
+            writeIndent();
+            depth++;
+            internal.writeStartElement(arg0);
+            prev_was_end_element = false;
+        }
+
+        public void writeStartElement(String arg0, String arg1) throws XMLStreamException {
+            writeIndent();
+            depth++;
+            internal.writeStartElement(arg0, arg1);
+            prev_was_end_element = false;
+        }
+
+        public void writeStartElement(String arg0, String arg1, String arg2) throws XMLStreamException {
+            writeIndent();
+            depth++;
+            internal.writeStartElement(arg0, arg1, arg2);
+            prev_was_end_element = false;
+        }
+
+        private void writeIndent() throws XMLStreamException {
+            internal.writeCharacters("\n");
+            char[] spaces = getSpaces();
+            internal.writeCharacters(spaces, 0, spaces.length);
+        }
+
+        private char[] getSpaces() {
+            char[] spaces = new char[INDENT * depth];
+            java.util.Arrays.fill(spaces, ' ');
+            return spaces;
+        }
+    }
+
+    @Override
+    protected WriterOptions initDefaultWriterOptions() {
+        return new AbstractWriterOptions() {
+        };
+    }
+
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/ResolveFunction.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/ResolveFunction.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/ResolveFunction.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/ResolveFunction.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,87 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMNode;
+import org.jaxen.Context;
+import org.jaxen.Function;
+import org.jaxen.FunctionCallException;
+import org.jaxen.Navigator;
+import org.jaxen.function.StringFunction;
+
+public class ResolveFunction implements Function {
+
+    public static final QName QNAME = new QName("http://abdera.apache.org", "resolve");
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public Object call(Context context, List args) throws FunctionCallException {
+        List<String> results = new ArrayList<String>();
+        if (args.isEmpty())
+            return null;
+        Navigator navigator = context.getNavigator();
+        for (Object obj : args) {
+            if (obj instanceof List) {
+                for (Object o : (List<?>)obj) {
+                    try {
+                        String value = StringFunction.evaluate(o, navigator);
+                        IRI resolved = null;
+                        IRI baseUri = null;
+                        if (o instanceof OMNode) {
+                            OMNode node = (OMNode)o;
+                            OMContainer el = node.getParent();
+                            if (el instanceof Document) {
+                                Document<Element> doc = (Document<Element>)el;
+                                baseUri = doc.getBaseUri();
+                            } else if (el instanceof Element) {
+                                Element element = (Element)el;
+                                baseUri = element.getBaseUri();
+                            }
+                        } else if (o instanceof OMAttribute) {
+                            OMAttribute attr = (OMAttribute)o;
+                            Element element = (Element)context.getNavigator().getParentNode(attr);
+                            baseUri = element.getBaseUri();
+                        }
+                        if (baseUri != null) {
+                            resolved = baseUri.resolve(value);
+                            results.add(resolved.toString());
+                        }
+                    } catch (Exception e) {
+                    }
+                }
+            } else {
+                // nothing to do
+            }
+        }
+        if (results.size() == 1) {
+            return results.get(0);
+        } else if (results.size() > 1) {
+            return results;
+        } else
+            return null;
+    }
+}

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



Mime
View raw message