abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [27/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/writer/AbstractStreamWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,777 @@
+/*
+ * 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.writer;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
+import java.util.Date;
+import java.util.Formatter;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.xml.XMLVersion;
+import org.apache.abdera2.common.date.DateTime;
+import org.apache.abdera2.model.Content;
+import org.apache.abdera2.model.Text;
+import org.apache.abdera2.model.Text.Type;
+import org.apache.commons.codec.binary.Base64;
+
+public abstract class AbstractStreamWriter implements StreamWriter {
+
+    protected final Abdera abdera;
+    protected final String name;
+    protected boolean autoflush = false;
+    protected boolean autoclose = false;
+    protected boolean autoindent = false;
+
+    protected final Set<String> formats = 
+      new HashSet<String>();
+    
+    protected AbstractStreamWriter(Abdera abdera, String name) {
+        this.abdera = abdera;
+        this.name = name;
+    }
+
+    protected AbstractStreamWriter(Abdera abdera, String name, String... formats) {
+      this.abdera = abdera;
+      this.name = name;
+      for (String format : formats)
+        this.formats.add(format);
+    }
+    
+    public StreamWriter setAutoflush(boolean auto) {
+        this.autoflush = auto;
+        return this;
+    }
+
+    public StreamWriter setAutoclose(boolean auto) {
+        this.autoclose = auto;
+        return this;
+    }
+
+    public StreamWriter setChannel(WritableByteChannel channel) {
+        return setOutputStream(Channels.newOutputStream(channel));
+    }
+
+    public StreamWriter setChannel(WritableByteChannel channel, String charset) {
+        return setWriter(Channels.newWriter(channel, charset));
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public StreamWriter startDocument() {
+        return startDocument("1.0");
+    }
+    
+    public StreamWriter startDocument(XMLVersion xmlversion) {
+        return startDocument(xmlversion.label());
+    }
+    
+    public StreamWriter startDocument(XMLVersion xmlversion, String charset) {
+      return startDocument(xmlversion.label(),charset);
+    }
+
+    public StreamWriter endDocument() {
+        return this;
+    }
+
+    public StreamWriter startFeed() {
+        return startElement(Constants.FEED);
+    }
+
+    public StreamWriter endFeed() {
+        return endElement();
+    }
+
+    public StreamWriter startEntry() {
+        return startElement(Constants.ENTRY);
+    }
+
+    public StreamWriter endEntry() {
+        return endElement();
+    }
+
+    public StreamWriter endCategory() {
+        return endElement();
+    }
+
+    public StreamWriter endContent() {
+        return endElement();
+    }
+
+    public StreamWriter endLink() {
+        return endElement();
+    }
+
+    public StreamWriter endPerson() {
+        return endElement();
+    }
+
+    public StreamWriter endSource() {
+        return endElement();
+    }
+
+    public StreamWriter endText() {
+        return endElement();
+    }
+
+    public StreamWriter startLink(String iri, String rel, String type, String title, String hreflang, long length) {
+        return startElement(Constants.LINK).writeAttribute("href", iri).writeAttribute("rel", rel)
+            .writeAttribute("type", type).writeAttribute("title", title).writeAttribute("hreflang", hreflang)
+            .writeAttribute("length", length > -1 ? String.valueOf(length) : null);
+    }
+
+    public StreamWriter startPerson(QName qname) {
+        return startElement(qname);
+    }
+
+    public StreamWriter startSource() {
+        return startElement(Constants.SOURCE);
+    }
+
+    public StreamWriter startText(QName qname, Text.Type type) {
+        return startElement(qname).writeAttribute("type", type != null ? type.name().toLowerCase() : "text");
+    }
+
+    public StreamWriter writeDate(QName qname, String date) {
+        return startElement(qname).writeElementText(date).endElement();
+    }
+
+    public StreamWriter writeIRIElement(QName qname, String iri) {
+        return startElement(qname).writeElementText(iri).endElement();
+    }
+
+    public StreamWriter writePersonEmail(String email) {
+        if (email == null)
+            return this;
+        return startElement(Constants.EMAIL).writeElementText(email).endElement();
+    }
+
+    public StreamWriter writePersonName(String name) {
+        if (name == null)
+            return this;
+        return startElement(Constants.NAME).writeElementText(name).endElement();
+    }
+
+    public StreamWriter writePersonUri(String uri) {
+        if (uri == null)
+            return this;
+        return startElement(Constants.URI).writeElementText(uri).endElement();
+    }
+
+    public StreamWriter startContent(Content.Type type, String src) {
+        return startContent(type.name().toLowerCase(), src);
+    }
+
+    public StreamWriter startContent(String type, String src) {
+        return startElement(Constants.CONTENT).writeAttribute("type", type).writeAttribute("src", src);
+    }
+
+    public StreamWriter startContent(Content.Type type) {
+        return startContent(type, null);
+    }
+
+    public StreamWriter startContent(String type) {
+        return startContent(type, null);
+    }
+
+    public StreamWriter startLink(String iri) {
+        return startLink(iri, null, null, null, null, -1);
+    }
+
+    public StreamWriter startLink(String iri, String rel) {
+        return startLink(iri, rel, null, null, null, -1);
+    }
+
+    public StreamWriter startLink(String iri, String rel, String type) {
+        return startLink(iri, rel, type, null, null, -1);
+    }
+
+    public StreamWriter writeCategory(String term) {
+        return writeCategory(term, null, null);
+    }
+
+    public StreamWriter writeCategory(String term, String scheme) {
+        return writeCategory(term, scheme, null);
+    }
+
+    public StreamWriter writeCategory(String term, String scheme, String label) {
+        return startElement(Constants.CATEGORY).writeAttribute("term", term).writeAttribute("scheme", scheme)
+            .writeAttribute("label", label).endElement();
+    }
+
+    public StreamWriter writeContent(Content.Type type, String value) {
+        return startContent(type).writeElementText(value).endContent();
+    }
+
+    public StreamWriter writeContent(Content.Type type, InputStream value) throws IOException {
+        return startContent(type).writeElementText(value).endContent();
+    }
+
+    public StreamWriter writeContent(Content.Type type, DataHandler value) throws IOException {
+        return startContent(type).writeElementText(value).endContent();
+    }
+
+    public StreamWriter writeContent(String type, String value) {
+        return startContent(type).writeElementText(value).endContent();
+    }
+
+    public StreamWriter writeEdited(Date date) {
+        writeDate(Constants.EDITED, date);
+        return this;
+    }
+
+    public StreamWriter writeId(String iri) {
+        return writeIRIElement(Constants.ID, iri);
+    }
+
+    public StreamWriter writeIcon(String iri) {
+        return writeIRIElement(Constants.ICON, iri);
+    }
+
+    public StreamWriter writeLogo(String iri) {
+        return writeIRIElement(Constants.LOGO, iri);
+    }
+
+    public StreamWriter writeLink(String iri) {
+        return writeLink(iri, null, null, null, null, -1);
+    }
+
+    public StreamWriter writeLink(String iri, String rel) {
+        return writeLink(iri, rel, null, null, null, -1);
+    }
+
+    public StreamWriter writeLink(String iri, String rel, String type) {
+        return writeLink(iri, rel, type, null, null, -1);
+    }
+
+    public StreamWriter writeLink(String iri, String rel, String type, String title, String hreflang, long length) {
+        return startLink(iri, rel, type, title, hreflang, length).endLink();
+    }
+
+    public StreamWriter writePerson(QName qname, String name, String email, String uri) {
+        return startPerson(qname).writePersonName(name).writePersonEmail(email).writePersonUri(uri).endPerson();
+    }
+
+    public StreamWriter writePublished(Date date) {
+        return writeDate(Constants.PUBLISHED, date);
+    }
+
+    public StreamWriter writeText(QName qname, Text.Type type, String value) {
+        return startText(qname, type).writeElementText(value).endElement();
+    }
+
+    public StreamWriter writeUpdated(Date date) {
+        return writeDate(Constants.UPDATED, date);
+    }
+
+    public StreamWriter writeUpdated(String date) {
+        return writeDate(Constants.UPDATED, date);
+    }
+
+    public StreamWriter writePublished(String date) {
+        return writeDate(Constants.PUBLISHED, date);
+    }
+
+    public StreamWriter writeEdited(String date) {
+        return writeDate(Constants.EDITED, date);
+    }
+
+    public StreamWriter writeDate(QName qname, Date date) {
+        return writeDate(qname, DateTime.format(date));
+    }
+
+    public StreamWriter writeId(IRI iri) {
+        return writeIRIElement(Constants.ID, iri);
+    }
+
+    public StreamWriter writeIcon(IRI iri) {
+        return writeIRIElement(Constants.ICON, iri);
+    }
+
+    public StreamWriter writeLogo(IRI iri) {
+        return writeIRIElement(Constants.LOGO, iri);
+    }
+
+    public StreamWriter writeIRIElement(QName qname, IRI iri) {
+        return writeIRIElement(qname, iri.toString());
+    }
+
+    public StreamWriter writeElementText(InputStream value) throws IOException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        byte[] buf = new byte[1024];
+        int r = -1;
+        while ((r = value.read(buf)) != -1)
+            out.write(buf, 0, r);
+        byte[] data = out.toByteArray();
+        writeElementText(new String(Base64.encodeBase64(data), "UTF-8"));
+        return this;
+    }
+
+    public StreamWriter writeElementText(DataHandler value) throws IOException {
+        writeElementText(value.getInputStream());
+        return this;
+    }
+
+    public StreamWriter writeTitle(String value) {
+        return writeText(Constants.TITLE, Text.Type.TEXT, value);
+    }
+
+    public StreamWriter writeTitle(Text.Type type, String value) {
+        return writeText(Constants.TITLE, type, value);
+    }
+
+    public StreamWriter writeSubtitle(String value) {
+        return writeText(Constants.SUBTITLE, Text.Type.TEXT, value);
+    }
+
+    public StreamWriter writeSubtitle(Text.Type type, String value) {
+        return writeText(Constants.SUBTITLE, type, value);
+    }
+
+    public StreamWriter writeSummary(String value) {
+        return writeText(Constants.SUMMARY, Text.Type.TEXT, value);
+    }
+
+    public StreamWriter writeSummary(Text.Type type, String value) {
+        return writeText(Constants.SUMMARY, type, value);
+    }
+
+    public StreamWriter writeRights(String value) {
+        return writeText(Constants.RIGHTS, Text.Type.TEXT, value);
+    }
+
+    public StreamWriter writeRights(Text.Type type, String value) {
+        return writeText(Constants.RIGHTS, type, value);
+    }
+
+    public StreamWriter writeAuthor(String name, String email, String uri) {
+        return writePerson(Constants.AUTHOR, name, email, uri);
+    }
+
+    public StreamWriter writeAuthor(String name) {
+        return writeAuthor(name, null, null);
+    }
+
+    public StreamWriter startAuthor() {
+        return startElement(Constants.AUTHOR);
+    }
+
+    public StreamWriter endAuthor() {
+        return endElement();
+    }
+
+    public StreamWriter writeContributor(String name, String email, String uri) {
+        return writePerson(Constants.CONTRIBUTOR, name, email, uri);
+    }
+
+    public StreamWriter writeContributor(String name) {
+        return writeContributor(name, null, null);
+    }
+
+    public StreamWriter startContributor() {
+        return startElement(Constants.CONTRIBUTOR);
+    }
+
+    public StreamWriter endContributor() {
+        return endElement();
+    }
+
+    public StreamWriter writeGenerator(String version, String uri, String value) {
+        return startElement(Constants.GENERATOR).writeAttribute("version", version).writeAttribute("uri", uri)
+            .writeElementText(value).endElement();
+    }
+
+    public StreamWriter startGenerator(String version, String uri) {
+        return startElement(Constants.GENERATOR).writeAttribute("version", version).writeAttribute("uri", uri);
+    }
+
+    public StreamWriter endGenerator() {
+        return endElement();
+    }
+
+    public StreamWriter startCategory(String term) {
+        return startCategory(term, null, null);
+    }
+
+    public StreamWriter startCategory(String term, String scheme) {
+        return startCategory(term, scheme, null);
+    }
+
+    public StreamWriter startCategory(String term, String scheme, String label) {
+        return startElement(Constants.CATEGORY).writeAttribute("term", term).writeAttribute("scheme", scheme)
+            .writeAttribute("label", label);
+    }
+
+    public StreamWriter startService() {
+        return startElement(Constants.SERVICE);
+    }
+
+    public StreamWriter endService() {
+        return endElement();
+    }
+
+    public StreamWriter startWorkspace() {
+        return startElement(Constants.WORKSPACE);
+    }
+
+    public StreamWriter endWorkspace() {
+        return endElement();
+    }
+
+    public StreamWriter startCollection(String href) {
+        return startElement(Constants.COLLECTION).writeAttribute("href", href);
+    }
+
+    public StreamWriter endCollection() {
+        endElement();
+        return this;
+    }
+
+    public StreamWriter writeAccepts(String... accepts) {
+        for (String accept : accepts) {
+            startElement(Constants.ACCEPT).writeElementText(accept).endElement();
+        }
+        return this;
+    }
+
+    public StreamWriter writeAcceptsEntry() {
+        return writeAccepts("application/atom+xml;type=entry");
+    }
+
+    public StreamWriter writeAcceptsNothing() {
+        return writeAccepts("");
+    }
+
+    public StreamWriter startCategories() {
+        return startCategories(false, null);
+    }
+
+    public StreamWriter startCategories(boolean fixed) {
+        return startCategories(fixed, null);
+    }
+
+    public StreamWriter startCategories(boolean fixed, String scheme) {
+        startElement(Constants.CATEGORIES);
+        if (fixed) {
+            writeAttribute("fixed", "yes");
+        }
+        if (scheme != null && scheme.length() > 0) {
+            writeAttribute("scheme", scheme);
+        }
+        return this;
+    }
+
+    public StreamWriter endCategories() {
+        return endElement();
+    }
+
+    public StreamWriter startControl() {
+        return startElement(Constants.CONTROL);
+    }
+
+    public StreamWriter endControl() {
+        return endElement();
+    }
+
+    public StreamWriter writeDraft(boolean draft) {
+        return startElement(Constants.DRAFT).writeElementText(draft ? "yes" : "no").endElement();
+    }
+
+    public StreamWriter writeAttribute(String name, String value) {
+        if (value == null)
+            return this;
+        return writeAttribute(name, null, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, String value) {
+        if (value == null)
+            return this;
+        return writeAttribute(name, namespace, null, value);
+    }
+
+    public StreamWriter writeAttribute(QName qname, String value) {
+        if (value == null)
+            return this;
+        return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value);
+    }
+
+    public StreamWriter startElement(QName qname) {
+        return startElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix());
+    }
+
+    public StreamWriter startElement(String name) {
+        return startElement(name, null, null);
+    }
+
+    public StreamWriter startElement(String name, String namespace) {
+        return startElement(name, namespace, null);
+    }
+
+    public StreamWriter setAutoIndent(boolean indent) {
+        this.autoindent = indent;
+        return this;
+    }
+
+    public StreamWriter writeAttribute(QName qname, Date value) {
+        return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value);
+    }
+
+    public StreamWriter writeAttribute(String name, Date value) {
+        return writeAttribute(name, null, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, Date value) {
+        return writeAttribute(name, namespace, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, String prefix, Date value) {
+        return writeAttribute(name, namespace, prefix, DateTime.format(value));
+    }
+
+    public StreamWriter writeAttribute(QName qname, int value) {
+        return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value);
+    }
+
+    public StreamWriter writeAttribute(String name, int value) {
+        return writeAttribute(name, null, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, int value) {
+        return writeAttribute(name, namespace, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, String prefix, int value) {
+        return writeAttribute(name, namespace, prefix, Integer.toString(value));
+    }
+
+    public StreamWriter writeAttribute(QName qname, long value) {
+        return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value);
+    }
+
+    public StreamWriter writeAttribute(String name, long value) {
+        return writeAttribute(name, null, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, long value) {
+        return writeAttribute(name, namespace, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, String prefix, long value) {
+        return writeAttribute(name, namespace, prefix, Long.toString(value));
+    }
+
+    public StreamWriter writeAttribute(QName qname, double value) {
+        return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value);
+    }
+
+    public StreamWriter writeAttribute(String name, double value) {
+        return writeAttribute(name, null, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, double value) {
+        return writeAttribute(name, namespace, null, value);
+    }
+
+    public StreamWriter writeAttribute(String name, String namespace, String prefix, double value) {
+        return writeAttribute(name, namespace, prefix, Double.toString(value));
+    }
+
+    public StreamWriter writeElementText(Date value) {
+        return writeElementText(DateTime.format(value));
+    }
+
+    public StreamWriter writeElementText(int value) {
+        return writeElementText(Integer.toString(value));
+    }
+
+    public StreamWriter writeElementText(long value) {
+        return writeElementText(Long.toString(value));
+    }
+
+    public StreamWriter writeElementText(double value) {
+        return writeElementText(Double.toString(value));
+    }
+
+    public StreamWriter writeBase(String iri) {
+        return writeAttribute(Constants.BASE, iri);
+    }
+
+    public StreamWriter writeBase(IRI iri) {
+        return writeBase(iri.toString());
+    }
+
+    public StreamWriter writeLanguage(String lang) {
+        return writeAttribute(Constants.LANG, lang);
+    }
+
+    public StreamWriter writeLanguage(Lang lang) {
+        return writeLanguage(lang.toString());
+    }
+
+    public StreamWriter writeLanguage(Locale locale) {
+        return writeLanguage(new Lang(locale));
+    }
+
+    public StreamWriter writeIRIElement(String name, IRI iri) {
+        return startElement(name).writeElementText(iri.toString()).endElement();
+    }
+
+    public StreamWriter writeIRIElement(String name, String namespace, IRI iri) {
+        return startElement(name, namespace).writeElementText(iri.toString()).endElement();
+    }
+
+    public StreamWriter writeIRIElement(String name, String namespace, String prefix, IRI iri) {
+        return startElement(name, namespace, prefix).writeElementText(iri.toString()).endElement();
+    }
+
+    public StreamWriter writeIRIElement(String name, String namespace, String prefix, String iri) {
+        return startElement(name, namespace, prefix).writeElementText(iri).endElement();
+    }
+
+    public StreamWriter writeIRIElement(String name, String namespace, String iri) {
+        return startElement(name, namespace).writeElementText(iri).endElement();
+    }
+
+    public StreamWriter writeIRIElement(String name, String iri) {
+        return startElement(name).writeElementText(iri).endElement();
+    }
+
+    public StreamWriter writeDate(String name, Date date) {
+        return startElement(name).writeElementText(date).endElement();
+    }
+
+    public StreamWriter writeDate(String name, String namespace, Date date) {
+        return startElement(name, namespace).writeElementText(date).endElement();
+    }
+
+    public StreamWriter writeDate(String name, String namespace, String prefix, Date date) {
+        return startElement(name, namespace, prefix).writeElementText(date).endElement();
+    }
+
+    public StreamWriter writeDate(String name, String date) {
+        return startElement(name).writeElementText(date).endElement();
+    }
+
+    public StreamWriter writeDate(String name, String namespace, String date) {
+        return startElement(name, namespace).writeElementText(date).endElement();
+    }
+
+    public StreamWriter writeDate(String name, String namespace, String prefix, String date) {
+        return startElement(name, namespace, prefix).writeElementText(date).endElement();
+    }
+
+    public StreamWriter startText(String name, String namespace, String prefix, Type type) {
+        return startElement(name, namespace, prefix).writeAttribute("type",
+                                                                    type != null ? type.name().toLowerCase() : "text");
+    }
+
+    public StreamWriter startText(String name, String namespace, Type type) {
+        return startElement(name, namespace).writeAttribute("type", type != null ? type.name().toLowerCase() : "text");
+    }
+
+    public StreamWriter startText(String name, Type type) {
+        return startElement(name).writeAttribute("type", type != null ? type.name().toLowerCase() : "text");
+    }
+
+    public StreamWriter writeText(String name, String namespace, String prefix, Type type, String value) {
+        return startText(name, namespace, prefix, type).writeElementText(value).endElement();
+    }
+
+    public StreamWriter writeText(String name, String namespace, Type type, String value) {
+        return startText(name, namespace, type).writeElementText(value).endElement();
+    }
+
+    public StreamWriter writeText(String name, Type type, String value) {
+        return startText(name, type).writeElementText(value).endElement();
+    }
+
+    public StreamWriter startPerson(String name, String namespace, String prefix) {
+        return startElement(name, namespace, prefix);
+    }
+
+    public StreamWriter startPerson(String name, String namespace) {
+        return startElement(name, namespace);
+    }
+
+    public StreamWriter startPerson(String name) {
+        return startElement(name);
+    }
+
+    public StreamWriter writePerson(String localname,
+                                    String namespace,
+                                    String prefix,
+                                    String name,
+                                    String email,
+                                    String uri) {
+        return startPerson(localname, namespace, prefix).writePersonName(name).writePersonEmail(email)
+            .writePersonUri(uri).endPerson();
+    }
+
+    public StreamWriter writePerson(String localname, String namespace, String name, String email, String uri) {
+        return startPerson(localname, namespace).writePersonName(name).writePersonEmail(email).writePersonUri(uri)
+            .endPerson();
+    }
+
+    public StreamWriter writePerson(String localname, String name, String email, String uri) {
+        return startPerson(localname).writePersonName(name).writePersonEmail(email).writePersonUri(uri).endPerson();
+    }
+
+    public Appendable append(char c) throws IOException {
+        return writeElementText(String.valueOf(c));
+    }
+
+    public Appendable append(CharSequence csq, int start, int end) throws IOException {
+        return append(csq.subSequence(start, end));
+    }
+
+    public Appendable append(CharSequence csq) throws IOException {
+        return writeElementText(csq.toString());
+    }
+
+    public StreamWriter writeElementText(String format, Object... args) {
+        new Formatter(this).format(format, args);
+        return this;
+    }
+    
+    public Iterable<String> getOutputFormats() {
+      return formats;
+  }
+
+  public boolean outputsFormat(String mediatype) {
+      for (String format : formats) {
+          if (MimeTypeHelper.isMatch(format, mediatype))
+              return true;
+      }
+      return false;
+  }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,135 @@
+/*
+ * 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.writer;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.zip.DeflaterOutputStream;
+
+import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+
+public abstract class AbstractWriter implements Writer {
+
+    protected WriterOptions options;
+    
+    protected final Set<String> formats = 
+      new HashSet<String>();
+    
+    protected AbstractWriter() {}
+    
+    protected AbstractWriter(String... formats) {
+      for (String format : formats)
+        this.formats.add(format);
+    }
+
+    public WriterOptions getDefaultWriterOptions() {
+        if (options == null)
+            options = initDefaultWriterOptions();
+
+        // Make a copy of the options, so that changes to it don't result in
+        // changes to the Parser's defaults. Also, this allows us to remain
+        // thread safe without having to make ParseOptions implementations
+        // synchronized.
+
+        try {
+            return (WriterOptions)options.clone();
+        } catch (CloneNotSupportedException cnse) {
+            // This shouldn't actually happen
+            throw new RuntimeException(cnse);
+        }
+    }
+
+    protected abstract WriterOptions initDefaultWriterOptions();
+
+    public synchronized Writer setDefaultWriterOptions(WriterOptions options) {
+        // Ok, we need to make a defensive copy of the options, since otherwise
+        // the caller still has access to the object, which means our access to
+        // it isn't certain to be thread safe.
+
+        try {
+            this.options = (options != null) ? (WriterOptions)options.clone() : initDefaultWriterOptions();
+        } catch (CloneNotSupportedException cnse) {
+            // This shouldn't actually happen
+            throw new RuntimeException(cnse);
+        }
+        return this;
+    }
+
+    public Object write(Base base) throws IOException {
+        return write(base, getDefaultWriterOptions());
+    }
+
+    public void writeTo(Base base, OutputStream out) throws IOException {
+        writeTo(base, out, getDefaultWriterOptions());
+    }
+
+    public void writeTo(Base base, java.io.Writer out) throws IOException {
+        writeTo(base, out, getDefaultWriterOptions());
+    }
+
+    protected OutputStream getCompressedOutputStream(OutputStream out, WriterOptions options) throws IOException {
+        if (options.getCompressionCodecs() != null) {
+            out = Compression.wrap(out, options.getCompressionCodecs());
+        }
+        return out;
+    }
+
+    protected void finishCompressedOutputStream(OutputStream out, WriterOptions options) throws IOException {
+        if (options.getCompressionCodecs() != null) {
+            ((DeflaterOutputStream)out).finish();
+        }
+    }
+
+    public void writeTo(Base base, WritableByteChannel out, WriterOptions options) throws IOException {
+        String charset = options.getCharset();
+        if (charset == null) {
+            Document<?> doc = null;
+            if (base instanceof Document)
+                doc = (Document<?>)base;
+            else if (base instanceof Element) {
+                doc = ((Element)base).getDocument();
+            }
+            charset = doc != null ? doc.getCharset() : null;
+        }
+        writeTo(base, Channels.newWriter(out, charset != null ? charset : "utf-8"), options);
+    }
+
+    public void writeTo(Base base, WritableByteChannel out) throws IOException {
+        writeTo(base, out, getDefaultWriterOptions());
+    }
+
+    public Iterable<String> getOutputFormats() {
+      return formats;
+  }
+
+  public boolean outputsFormat(String mediatype) {
+      for (String format : formats) {
+          if (MimeTypeHelper.isMatch(format, mediatype))
+              return true;
+      }
+      return false;
+  }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriterOptions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriterOptions.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriterOptions.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriterOptions.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,60 @@
+/*
+ * 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.writer;
+
+import org.apache.abdera2.common.io.Compression.CompressionCodec;
+
+public abstract class AbstractWriterOptions implements WriterOptions {
+
+    protected String charset = "UTF-8";
+    protected CompressionCodec[] codecs = null;
+    protected boolean autoclose = false;
+
+    public Object clone() throws CloneNotSupportedException {
+        AbstractWriterOptions copy = (AbstractWriterOptions)super.clone();
+        return copy;
+    }
+
+    public CompressionCodec[] getCompressionCodecs() {
+        return codecs;
+    }
+
+    public WriterOptions setCompressionCodecs(CompressionCodec... codecs) {
+        this.codecs = codecs;
+        return this;
+    }
+
+    public String getCharset() {
+        return charset;
+    }
+
+    public WriterOptions setCharset(String charset) {
+        this.charset = charset;
+        return this;
+    }
+
+    public boolean getAutoClose() {
+        return autoclose;
+    }
+
+    public WriterOptions setAutoClose(boolean autoclose) {
+        this.autoclose = autoclose;
+        return this;
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriterOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,1217 @@
+/*
+ * 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.writer;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.channels.WritableByteChannel;
+import java.util.Date;
+import java.util.Locale;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.anno.DefaultImplementation;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.xml.XMLVersion;
+import org.apache.abdera2.model.Content;
+import org.apache.abdera2.model.Text;
+
+/**
+ * The StreamWriter interface provides a for producing Atom documents based on a streaming api. This approach provides a
+ * lightweight alternative to building up an object model. The StreamWriter is NOT synchronized and is NOT threadsafe
+ */
+@DefaultImplementation("org.apache.abdera2.parser.axiom.StaxStreamWriter")
+public interface StreamWriter extends Appendable, Closeable {
+
+    StreamWriter flush();
+
+    /**
+     * True if the StreamWriter should autoclose the buffer after calling endDocument
+     */
+    StreamWriter setAutoclose(boolean auto);
+
+    /**
+     * True if the StreamWriter should autoflush the buffer
+     */
+    StreamWriter setAutoflush(boolean auto);
+
+    /**
+     * Set the target java.io.Writer
+     */
+    StreamWriter setWriter(java.io.Writer writer);
+
+    /**
+     * Set the target java.io.OutputStream
+     */
+    StreamWriter setOutputStream(OutputStream out);
+
+    /**
+     * Set the target java.io.OutputStream
+     */
+    StreamWriter setOutputStream(OutputStream out, String charset);
+
+    /**
+     * Set the target WritableByteChannel
+     */
+    StreamWriter setChannel(WritableByteChannel channel);
+
+    /**
+     * Set the target WritableByteChannel
+     */
+    StreamWriter setChannel(WritableByteChannel channel, String charset);
+
+    /**
+     * Start the document
+     * 
+     * @param xmlversion The XML version
+     * @param charset the Character Encoding
+     */
+    StreamWriter startDocument(String xmlversion, String charset);
+
+    /**
+     * Start the document
+     * 
+     * @param xmlversion The XML version
+     */
+    StreamWriter startDocument(String xmlversion);
+
+    /**
+     * Start the document
+     * 
+     * @param xmlversion The XML version
+     */
+    StreamWriter startDocument(XMLVersion xmlversion);
+    
+    StreamWriter startDocument(XMLVersion xmlversion, String charset);
+    
+    /**
+     * Start the document
+     */
+    StreamWriter startDocument();
+
+    /**
+     * End the document
+     */
+    StreamWriter endDocument();
+
+    /**
+     * Start an atom:feed element
+     */
+    StreamWriter startFeed();
+
+    /**
+     * End the atom:feed element
+     */
+    StreamWriter endFeed();
+
+    /**
+     * Start an atom:entry element
+     */
+    StreamWriter startEntry();
+
+    /**
+     * End the atom:entry element
+     */
+    StreamWriter endEntry();
+
+    /**
+     * Write an atom:id element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeId(String iri);
+
+    /**
+     * Write an atom:icon element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeIcon(String iri);
+
+    /**
+     * Write an atom:logo element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeLogo(String iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeIRIElement(QName qname, String iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param prefix the element prefix
+     * @param iri the IRI to write
+     */
+    StreamWriter writeIRIElement(String name, String namespace, String prefix, String iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param iri the IRI to write
+     */
+    StreamWriter writeIRIElement(String name, String namespace, String iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param name The element localname
+     * @param iri the IRI to write
+     */
+    StreamWriter writeIRIElement(String name, String iri);
+
+    /**
+     * Write an atom:id element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeId(IRI iri);
+
+    /**
+     * Write an atom:icon element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeIcon(IRI iri);
+
+    /**
+     * Write an atom:logo element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeLogo(IRI iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeIRIElement(QName qname, IRI iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param prefix the element prefix
+     * @param iri the IRI to write
+     */
+    StreamWriter writeIRIElement(String name, String namespace, String prefix, IRI iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param iri the IRI to write
+     */
+    StreamWriter writeIRIElement(String name, String namespace, IRI iri);
+
+    /**
+     * Write an IRI element
+     * 
+     * @param name The element localname
+     * @param iri the IRI to write
+     */
+    StreamWriter writeIRIElement(String name, IRI iri);
+
+    /**
+     * Write an atom:id element with a new IRI value
+     * 
+     * @param iri The value
+     */
+    StreamWriter writeId();
+
+    /**
+     * Write an atom:updated element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writeUpdated(Date date);
+
+    /**
+     * Write an atom:published element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writePublished(Date date);
+
+    /**
+     * Write an atom:edited element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writeEdited(Date date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param qname The element qname
+     * @param date The date value
+     */
+    StreamWriter writeDate(QName qname, Date date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param prefix The element prefix
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, String namespace, String prefix, Date date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, String namespace, Date date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, Date date);
+
+    /**
+     * Write an atom:updated element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writeUpdated(String date);
+
+    /**
+     * Write an atom:published element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writePublished(String date);
+
+    /**
+     * Write an atom:edited element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writeEdited(String date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param qname The element qname
+     * @param date The date value
+     */
+    StreamWriter writeDate(QName qname, String date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param prefix The element prefix
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, String namespace, String prefix, String date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, String namespace, String date);
+
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, String date);
+
+    /**
+     * End the person element
+     */
+    StreamWriter endPerson();
+
+    /**
+     * End the atom:link
+     */
+    StreamWriter endLink();
+
+    /**
+     * Write an atom:link element
+     * 
+     * @param iri The href value
+     */
+    StreamWriter writeLink(String iri);
+
+    /**
+     * Write an atom:link element
+     * 
+     * @param iri The href value
+     * @param rel The rel value
+     */
+    StreamWriter writeLink(String iri, String rel);
+
+    /**
+     * Write an atom:link element
+     * 
+     * @param iri The href value
+     * @param rel The rel value
+     * @param type The type value
+     */
+    StreamWriter writeLink(String iri, String rel, String type);
+
+    /**
+     * Write an atom:link element
+     * 
+     * @param iri The href value
+     * @param rel The rel value
+     * @param type The type value
+     * @param title The title value
+     * @param hreflang The hreflang value
+     * @param length The link length
+     */
+    StreamWriter writeLink(String iri, String rel, String type, String title, String hreflang, long length);
+
+    /**
+     * Start an atom:link element
+     * 
+     * @param iri The href value
+     */
+    StreamWriter startLink(String iri);
+
+    /**
+     * Start an atom:link element
+     * 
+     * @param iri The href value
+     * @param rel The rel value
+     */
+    StreamWriter startLink(String iri, String rel);
+
+    /**
+     * Start an atom:link element
+     * 
+     * @param iri The href value
+     * @param rel The rel value
+     * @param type The type value
+     */
+    StreamWriter startLink(String iri, String rel, String type);
+
+    /**
+     * Start an atom:link element
+     * 
+     * @param iri The href value
+     * @param rel The rel value
+     * @param type The type value
+     * @param title The title value
+     * @param hreflang The hreflang value
+     * @param length The link length
+     */
+    StreamWriter startLink(String iri, String rel, String type, String title, String hreflang, long length);
+
+    /**
+     * End the atom:category
+     */
+    StreamWriter endCategory();
+
+    /**
+     * Write an atom:category element
+     * 
+     * @param term The term value
+     */
+    StreamWriter writeCategory(String term);
+
+    /**
+     * Write an atom:category element
+     * 
+     * @param term The term value
+     * @param scheme The term value
+     */
+    StreamWriter writeCategory(String term, String scheme);
+
+    /**
+     * Write an atom:category element
+     * 
+     * @param term The term value
+     * @param scheme The term value
+     * @param label The term value
+     */
+    StreamWriter writeCategory(String term, String scheme, String label);
+
+    /**
+     * Start an atom:category element
+     * 
+     * @param term The term value
+     */
+    StreamWriter startCategory(String term);
+
+    /**
+     * Start an atom:category element
+     * 
+     * @param term The term value
+     * @param scheme The term value
+     */
+    StreamWriter startCategory(String term, String scheme);
+
+    /**
+     * Start an atom:category element
+     * 
+     * @param term The term value
+     * @param scheme The term value
+     * @param label The term value
+     */
+    StreamWriter startCategory(String term, String scheme, String label);
+
+    /**
+     * Start an atom:source element
+     */
+    StreamWriter startSource();
+
+    /**
+     * End the atom:source
+     */
+    StreamWriter endSource();
+
+    /**
+     * Write a Text element
+     * 
+     * @param qname The element qname
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeText(QName qname, Text.Type type, String value);
+
+    /**
+     * Write a Text element
+     * 
+     * @param name The element name
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeText(String name, Text.Type type, String value);
+
+    /**
+     * Write a Text element
+     * 
+     * @param name The element name
+     * @param namespace The element namespace
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeText(String name, String namespace, Text.Type type, String value);
+
+    /**
+     * Write a Text element
+     * 
+     * @param name The element name
+     * @param namespace The element namespace
+     * @param prefix The element prefix
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeText(String name, String namespace, String prefix, Text.Type type, String value);
+
+    /**
+     * Start a Text element
+     * 
+     * @param qname The element qname
+     * @param type The text type
+     */
+    StreamWriter startText(QName qname, Text.Type type);
+
+    /**
+     * Start a Text element
+     * 
+     * @param name The element name
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter startText(String name, Text.Type type);
+
+    /**
+     * Start a Text element
+     * 
+     * @param name The element name
+     * @param namespace The element namespace
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter startText(String name, String namespace, Text.Type type);
+
+    /**
+     * Start a Text element
+     * 
+     * @param name The element name
+     * @param namespace The element namespace
+     * @param prefix The element prefix
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter startText(String name, String namespace, String prefix, Text.Type type);
+
+    /**
+     * End the atom:content element
+     */
+    StreamWriter endContent();
+
+    /**
+     * Write an atom:content element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeContent(Content.Type type, String value);
+
+    /**
+     * Write an atom:content element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeContent(Content.Type type, InputStream value) throws IOException;
+
+    /**
+     * Write an atom:content element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeContent(Content.Type type, DataHandler value) throws IOException;
+
+    /**
+     * Write an atom:content element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeContent(String type, String value);
+
+    /**
+     * Start an atom:content element
+     * 
+     * @param type The text type
+     */
+    StreamWriter startContent(Content.Type type);
+
+    /**
+     * Start an atom:content element
+     * 
+     * @param type The text type
+     */
+    StreamWriter startContent(String type);
+
+    /**
+     * Start an atom:content element
+     * 
+     * @param type The text type
+     * @param src The src value
+     */
+    StreamWriter startContent(Content.Type type, String src);
+
+    /**
+     * Start an atom:content element
+     * 
+     * @param type The text type
+     * @param src The src value
+     */
+    StreamWriter startContent(String type, String src);
+
+    /**
+     * Start an element
+     * 
+     * @param qname Element qname
+     */
+    StreamWriter startElement(QName qname);
+
+    /**
+     * Start an element
+     */
+    StreamWriter startElement(String name);
+
+    /**
+     * Start an element
+     */
+    StreamWriter startElement(String name, String namespace);
+
+    /**
+     * Start an element
+     */
+    StreamWriter startElement(String name, String namespace, String prefix);
+
+    /**
+     * Write element text using Formatter
+     * 
+     * @param format
+     * @param params
+     */
+    StreamWriter writeElementText(String format, Object... params);
+
+    /**
+     * Write element text
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeElementText(String value);
+
+    /**
+     * Write element text
+     * 
+     * @param datahandler The text value
+     */
+    StreamWriter writeElementText(DataHandler datahandler) throws IOException;
+
+    /**
+     * Write element text
+     * 
+     * @param in The text value
+     */
+    StreamWriter writeElementText(InputStream in) throws IOException;
+
+    /**
+     * Write element text
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeElementText(Date value);
+
+    /**
+     * Write element text
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeElementText(int value);
+
+    /**
+     * Write element text
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeElementText(long value);
+
+    /**
+     * Write element text
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeElementText(double value);
+
+    /**
+     * End the element
+     */
+    StreamWriter endElement();
+
+    /**
+     * Write an atom:title element
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeTitle(String value);
+
+    /**
+     * Write an atom:title element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeTitle(Text.Type type, String value);
+
+    /**
+     * Write an atom:subtitle element
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeSubtitle(String value);
+
+    /**
+     * Write an atom:subtitle element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeSubtitle(Text.Type type, String value);
+
+    /**
+     * Write an atom:summary element
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeSummary(String value);
+
+    /**
+     * Write an atom:summary element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeSummary(Text.Type type, String value);
+
+    /**
+     * Write an atom:rights element
+     * 
+     * @param value The text value
+     */
+    StreamWriter writeRights(String value);
+
+    /**
+     * Write an atom:rights element
+     * 
+     * @param type The text type
+     * @param value The text value
+     */
+    StreamWriter writeRights(Text.Type type, String value);
+
+    /**
+     * Write a person element
+     * 
+     * @param qname the element qname
+     * @param name The person name
+     * @param email The person email
+     * @param uri The person uri
+     */
+    StreamWriter writePerson(QName qname, String name, String email, String uri);
+
+    /**
+     * Write a person element
+     * 
+     * @param localhost the element name
+     * @param name The person name
+     * @param email The person email
+     * @param uri The person uri
+     */
+    StreamWriter writePerson(String localname, String name, String email, String uri);
+
+    /**
+     * Write a person element
+     * 
+     * @param localhost the element name
+     * @param namespace the element namespace
+     * @param name The person name
+     * @param email The person email
+     * @param uri The person uri
+     */
+    StreamWriter writePerson(String localname, String namespace, String name, String email, String uri);
+
+    /**
+     * Write a person element
+     * 
+     * @param localhost the element name
+     * @param namespace the element namespace
+     * @param prefix the element prefix
+     * @param name The person name
+     * @param email The person email
+     * @param uri The person uri
+     */
+    StreamWriter writePerson(String localname, String namespace, String prefix, String name, String email, String uri);
+
+    /**
+     * Start a person element
+     * 
+     * @param qname The element qname
+     */
+    StreamWriter startPerson(QName qname);
+
+    /**
+     * Start a person element
+     * 
+     * @param name The element name
+     */
+    StreamWriter startPerson(String name);
+
+    /**
+     * Start a person element
+     * 
+     * @param name The element name
+     * @param namespace The element namespace
+     */
+    StreamWriter startPerson(String name, String namespace);
+
+    /**
+     * Start a person element
+     * 
+     * @param name The element name
+     * @param namespace The element namespace
+     * @param prefix The element prefix
+     */
+    StreamWriter startPerson(String name, String namespace, String prefix);
+
+    /**
+     * Write a person name
+     * 
+     * @param name The person name
+     */
+    StreamWriter writePersonName(String name);
+
+    /**
+     * Write a person email
+     * 
+     * @param email The person email
+     */
+    StreamWriter writePersonEmail(String email);
+
+    /**
+     * Write a person uri
+     * 
+     * @param uri The person uri
+     */
+    StreamWriter writePersonUri(String uri);
+
+    /**
+     * Write an atom:author element
+     * 
+     * @param name The person name
+     * @param email The person email
+     * @param uri The person uri
+     */
+    StreamWriter writeAuthor(String name, String email, String uri);
+
+    /**
+     * Write an atom:author element
+     * 
+     * @param name The person name
+     */
+    StreamWriter writeAuthor(String name);
+
+    /**
+     * Start an atom:author element
+     */
+    StreamWriter startAuthor();
+
+    /**
+     * End the atom:author element
+     */
+    StreamWriter endAuthor();
+
+    /**
+     * Write an atom:contributor element
+     * 
+     * @param name The person name
+     * @param email The person email
+     * @param uri The person uri
+     */
+    StreamWriter writeContributor(String name, String email, String uri);
+
+    /**
+     * Write an atom:contributor element
+     * 
+     * @param name The person name
+     */
+    StreamWriter writeContributor(String name);
+
+    /**
+     * Start an atom:contributor element
+     */
+    StreamWriter startContributor();
+
+    /**
+     * End an atom:contributor element
+     */
+    StreamWriter endContributor();
+
+    /**
+     * Write an atom:generator element
+     * 
+     * @param version The version value
+     * @param uri The uri value
+     * @param value The text value
+     */
+    StreamWriter writeGenerator(String version, String uri, String value);
+
+    /**
+     * Start an atom:generator element
+     * 
+     * @param version The version value
+     * @param uri The uri value
+     */
+    StreamWriter startGenerator(String version, String uri);
+
+    /**
+     * End the atom:generator element
+     */
+    StreamWriter endGenerator();
+
+    /**
+     * Write an XML comment
+     */
+    StreamWriter writeComment(String value);
+
+    /**
+     * Write an XML Processing Instruction
+     */
+    StreamWriter writePI(String value);
+
+    /**
+     * Write an XML Processing Instruction
+     */
+    StreamWriter writePI(String value, String target);
+
+    /**
+     * Start an app:service element
+     */
+    StreamWriter startService();
+
+    /**
+     * End an app:service element
+     */
+    StreamWriter endService();
+
+    /**
+     * Start an app:workspace element
+     */
+    StreamWriter startWorkspace();
+
+    /**
+     * End an app:workspace element
+     */
+    StreamWriter endWorkspace();
+
+    /**
+     * Start an app:collection element
+     * 
+     * @param href The href value
+     */
+    StreamWriter startCollection(String href);
+
+    /**
+     * End an app:collection element
+     */
+    StreamWriter endCollection();
+
+    /**
+     * Writes app:accept elements
+     * 
+     * @param accepts accept element values
+     */
+    StreamWriter writeAccepts(String... accepts);
+
+    /**
+     * Writes an app:accept element indicating that entries are accepted
+     */
+    StreamWriter writeAcceptsEntry();
+
+    /**
+     * Writes an app:accept element indicating that nothing is accepted
+     */
+    StreamWriter writeAcceptsNothing();
+
+    /**
+     * Start an app:categories element
+     */
+    StreamWriter startCategories();
+
+    /**
+     * Start an app:categories element
+     * 
+     * @param fixed True if the app:categories element is fixed
+     */
+    StreamWriter startCategories(boolean fixed);
+
+    /**
+     * Start an app:categories element
+     * 
+     * @param fixed True if the app:categories element is fixed
+     * @param scheme The scheme value
+     */
+    StreamWriter startCategories(boolean fixed, String scheme);
+
+    /**
+     * End the app:categories element
+     */
+    StreamWriter endCategories();
+
+    /**
+     * Start the app:control element
+     */
+    StreamWriter startControl();
+
+    /**
+     * End the app:control element
+     */
+    StreamWriter endControl();
+
+    /**
+     * Write an app:draft element
+     * 
+     * @param draft true if app:draft=yes
+     */
+    StreamWriter writeDraft(boolean draft);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(QName qname, String value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String prefix, String value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(QName qname, Date value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, Date value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, Date value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String prefix, Date value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(QName qname, int value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, int value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, int value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String prefix, int value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(QName qname, long value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, long value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, long value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String prefix, long value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(QName qname, double value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, double value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, double value);
+
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String prefix, double value);
+
+    /**
+     * Write a new line and indent
+     */
+    StreamWriter indent();
+
+    /**
+     * True to enable automatic indenting
+     */
+    StreamWriter setAutoIndent(boolean indent);
+
+    /**
+     * Write the xml:base attribute
+     */
+    StreamWriter writeBase(String iri);
+
+    /**
+     * Write the xml:base attribute
+     */
+    StreamWriter writeBase(IRI iri);
+
+    /**
+     * Write the xml:lang attribute
+     */
+    StreamWriter writeLanguage(String lang);
+
+    /**
+     * Write the xml:lang attribute
+     */
+    StreamWriter writeLanguage(Lang lang);
+
+    /**
+     * Write the xml:lang attribute
+     */
+    StreamWriter writeLanguage(Locale locale);
+
+    /**
+     * Specify the namespace prefix
+     */
+    StreamWriter setPrefix(String prefix, String uri);
+
+    /**
+     * Write a namespace declaration
+     */
+    StreamWriter writeNamespace(String prefix, String uri);
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writer.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writer.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writer.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writer.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.writer;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.channels.WritableByteChannel;
+
+import org.apache.abdera2.common.anno.DefaultImplementation;
+import org.apache.abdera2.model.Base;
+
+/**
+ * Writers are used to serialize Abdera objects
+ */
+@DefaultImplementation("org.apache.abdera2.parser.axiom.FOMWriter")
+public interface Writer {
+
+    /**
+     * Serialized the given Abdera Base to the given outputstream
+     */
+    void writeTo(Base base, OutputStream out) throws IOException;
+
+    /**
+     * Serialized the given Abdera Base to the given writer
+     */
+    void writeTo(Base base, java.io.Writer out) throws IOException;
+
+    /**
+     * Return the serialized form of the Abdera Base
+     */
+    Object write(Base base) throws IOException;
+
+    /**
+     * Serialized the given Abdera Base to the given outputstream
+     */
+    void writeTo(Base base, OutputStream out, WriterOptions options) throws IOException;
+
+    /**
+     * Serialized the given Abdera Base to the given writer
+     */
+    void writeTo(Base base, java.io.Writer out, WriterOptions options) throws IOException;
+
+    /**
+     * Return the serialized form of the Abdera Base
+     */
+    Object write(Base base, WriterOptions options) throws IOException;
+
+    void writeTo(Base base, WritableByteChannel out) throws IOException;
+
+    void writeTo(Base base, WritableByteChannel out, WriterOptions options) throws IOException;
+
+    WriterOptions getDefaultWriterOptions();
+
+    Writer setDefaultWriterOptions(WriterOptions options);
+   
+    /**
+     * Return a listing of MIME Media formats this Writer is capable of outputting.
+     */
+    Iterable<String> getOutputFormats();
+
+    /**
+     * Returns true if the format produced by this writer matches the specified media type
+     */
+    boolean outputsFormat(String mediatype);
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterFactory.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterFactory.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterFactory.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterFactory.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,67 @@
+/*
+ * 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.writer;
+
+import org.apache.abdera2.common.anno.DefaultImplementation;
+
+/**
+ * The WriterFactory is used a acquire instances of alternative writers registered with Abdera.
+ * 
+ * @see org.apache.abdera.writer.Writer
+ */
+@DefaultImplementation("org.apache.abdera2.parser.axiom.FOMWriterFactory")
+public interface WriterFactory {
+
+    /**
+     * Get the default writer. This is equivalent to calling abdera.getWriter();
+     * 
+     * @return The default writer
+     */
+    <T extends Writer> T getWriter();
+
+    /**
+     * Get the named writer.
+     * 
+     * @param name The name of the writer
+     * @return The specified writer
+     */
+    <T extends Writer> T getWriter(String name);
+
+    /**
+     * Return a writer capable of outputting the given MIME media type
+     * 
+     * @param mediatype A MIME media type
+     * @return A matching writer
+     */
+    <T extends Writer> T getWriterByMediaType(String mediatype);
+
+    /**
+     * Get the default StreamWriter. This is equivalent to calling abdera.getStreamWriter();
+     * 
+     * @return The default stream writer
+     */
+    <T extends StreamWriter> T newStreamWriter();
+
+    /**
+     * Get the named StreamWriter.
+     * 
+     * @param name The name of the StreamWriter
+     * @return The specified StreamWriter
+     */
+    <T extends StreamWriter> T newStreamWriter(String name);
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterOptions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterOptions.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterOptions.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterOptions.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.writer;
+
+import org.apache.abdera2.common.io.Compression.CompressionCodec;
+
+public interface WriterOptions extends Cloneable {
+
+    /**
+     * When writing, use the specified compression codecs
+     */
+    CompressionCodec[] getCompressionCodecs();
+
+    /**
+     * When writing, use the specified compression codecs
+     */
+    WriterOptions setCompressionCodecs(CompressionCodec... codecs);
+
+    Object clone() throws CloneNotSupportedException;
+
+    /**
+     * The character encoding to use for the output
+     */
+    String getCharset();
+
+    /**
+     * The character encoding to use for the output
+     */
+    WriterOptions setCharset(String charset);
+
+    /**
+     * True if the writer should close the output stream or writer when finished
+     */
+    boolean getAutoClose();
+
+    /**
+     * True if the writer should close the output stream or writer when finished
+     */
+    WriterOptions setAutoClose(boolean autoclose);
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/WriterOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/AbstractXPath.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/AbstractXPath.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/AbstractXPath.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/AbstractXPath.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.xpath;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.model.Base;
+
+/**
+ * Abstract base implementation of XPath
+ */
+public abstract class AbstractXPath implements XPath {
+
+    private final Map<String, String> namespaces;
+
+    protected AbstractXPath() {
+        this(null);
+    }
+
+    protected AbstractXPath(Map<String, String> defaultNamespaces) {
+        namespaces = (defaultNamespaces != null) ? defaultNamespaces : initDefaultNamespaces();
+    }
+
+    protected Map<String, String> initDefaultNamespaces() {
+        Map<String, String> namespaces = new HashMap<String, String>();
+        namespaces.put("a", Constants.ATOM_NS);
+        namespaces.put("app", Constants.APP_NS);
+        namespaces.put("xhtml", Constants.XHTML_NS);
+        return namespaces;
+    }
+
+    public Map<String, String> getDefaultNamespaces() {
+        return new HashMap<String, String>(namespaces);
+    }
+
+    public List<?> selectNodes(String path, Base base) throws XPathException {
+        return selectNodes(path, base, getDefaultNamespaces());
+    }
+
+    public Object selectSingleNode(String path, Base base) throws XPathException {
+        return selectSingleNode(path, base, getDefaultNamespaces());
+    }
+
+    public Object evaluate(String path, Base base) throws XPathException {
+        return evaluate(path, base, getDefaultNamespaces());
+    }
+
+    public String valueOf(String path, Base base) throws XPathException {
+        return valueOf(path, base, getDefaultNamespaces());
+    }
+
+    public boolean booleanValueOf(String path, Base base) throws XPathException {
+        return booleanValueOf(path, base, getDefaultNamespaces());
+    }
+
+    public Number numericValueOf(String path, Base base) throws XPathException {
+        return numericValueOf(path, base, getDefaultNamespaces());
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/AbstractXPath.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPath.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPath.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPath.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPath.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,97 @@
+/*
+ * 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.xpath;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.abdera2.common.anno.DefaultImplementation;
+import org.apache.abdera2.model.Base;
+
+/**
+ * Used to execute XPath queries over Feed Object Model instances.
+ */
+@DefaultImplementation("org.apache.abdera2.parser.axiom.FOMXPath")
+public interface XPath {
+
+    /**
+     * Return the default mapping of Prefixes to XML Namespaces
+     */
+    Map<String, String> getDefaultNamespaces();
+
+    /**
+     * Return a listing of nodes matching the specified Path
+     */
+    List<?> selectNodes(String path, Base base) throws XPathException;
+
+    /**
+     * Return the first node matching the specified Path
+     */
+    Object selectSingleNode(String path, Base base) throws XPathException;
+
+    /**
+     * Evaluate the specified XPath and return it's value
+     */
+    Object evaluate(String path, Base base) throws XPathException;
+
+    /**
+     * Return the text value of the specified Path
+     */
+    String valueOf(String path, Base base) throws XPathException;
+
+    /**
+     * Return a boolean representation of the specified Path
+     */
+    boolean booleanValueOf(String path, Base base) throws XPathException;
+
+    /**
+     * Return a numeric representation of the specified Path
+     */
+    Number numericValueOf(String path, Base base) throws XPathException;
+
+    /**
+     * Return a listing of nodes matching the specified Path using the specified Namespaces mapping
+     */
+    List<?> selectNodes(String path, Base base, Map<String, String> namespaces) throws XPathException;
+
+    /**
+     * Return a the first node matching the specified Path using the specified Namespaces mapping
+     */
+    Object selectSingleNode(String path, Base base, Map<String, String> namespaces) throws XPathException;
+
+    /**
+     * Evaluate the specified XPath and return it's value using the specified Namespaces mapping
+     */
+    Object evaluate(String path, Base base, Map<String, String> namespaces) throws XPathException;
+
+    /**
+     * Return the text value of the specified Path using the specified Namespaces mapping
+     */
+    String valueOf(String path, Base base, Map<String, String> namespaces) throws XPathException;
+
+    /**
+     * Return a boolean representation of the specified Path using the specified Namespaces mapping
+     */
+    boolean booleanValueOf(String path, Base base, Map<String, String> namespaces) throws XPathException;
+
+    /**
+     * Return a numeric representation of the specified Path using the specified Namespaces mapping
+     */
+    Number numericValueOf(String path, Base base, Map<String, String> namespaces) throws XPathException;
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPath.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPathException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPathException.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPathException.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPathException.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.xpath;
+
+public class XPathException extends RuntimeException {
+
+    private static final long serialVersionUID = 7373747391262088925L;
+
+    public XPathException() {
+        super();
+    }
+
+    public XPathException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public XPathException(String message) {
+        super(message);
+    }
+
+    public XPathException(Throwable cause) {
+        super(cause);
+    }
+
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPathException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/resources/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/resources/META-INF/MANIFEST.MF?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/resources/META-INF/MANIFEST.MF (added)
+++ abdera/abdera2/core/src/main/resources/META-INF/MANIFEST.MF Tue Sep 20 15:56:46 2011
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

Propchange: abdera/abdera2/core/src/main/resources/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.parser.Parser
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.parser.Parser?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.parser.Parser (added)
+++ abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.parser.Parser Tue Sep 20 15:56:46 2011
@@ -0,0 +1 @@
+org.apache.abdera2.parser.axiom.FOMParser
\ No newline at end of file

Added: abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.writer.Writer
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.writer.Writer?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.writer.Writer (added)
+++ abdera/abdera2/core/src/main/resources/META-INF/services/org.apache.abdera2.writer.Writer Tue Sep 20 15:56:46 2011
@@ -0,0 +1,2 @@
+org.apache.abdera2.parser.axiom.FOMWriter
+org.apache.abdera2.parser.axiom.util.PrettyWriter
\ No newline at end of file



Mime
View raw message