abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r591523 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/ core/src/main/java/org/apache/abdera/parser/ core/src/main/java/org/apache/abdera/util/ core/src/main/java/org/apache/abdera/writer/ examples/src/main/java/org...
Date Sat, 03 Nov 2007 00:32:48 GMT
Author: jmsnell
Date: Fri Nov  2 17:32:39 2007
New Revision: 591523

URL: http://svn.apache.org/viewvc?rev=591523&view=rev
Log:
When writing out large Atom documents, going through an creating a bunch of objects is less than 
optimum.  The new StreamWriter interface allows us to write out Atom documents using a streaming 
interface.  This is a work in progress.  There are some features, such as xml:lang and xml:base that need better support.  

Example:

  Abdera abdera = Abdera.getInstance();
  StreamWriter out = abdera.newStreamWriter();
  out.setOutputStream(System.out,"UTF-8");
  
  out.startDocument();
  out.startFeed();
  out.writeId("http://example.org");
  out.writeTitle("Foo");
  ...
  out.endFeed();
  out.endDocument();



Added:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/NamedItem.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/StreamWriterExample.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java
Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/NamedWriter.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/WriterFactory.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWriterFactory.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java Fri Nov  2 17:32:39 2007
@@ -27,6 +27,7 @@
 import org.apache.abdera.util.AbderaConfiguration;
 import org.apache.abdera.util.Messages;
 import org.apache.abdera.util.ServiceUtil;
+import org.apache.abdera.writer.StreamWriter;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
 import org.apache.abdera.xpath.XPath;
@@ -268,6 +269,19 @@
     }
   }
   
+  /**
+   * Return a new instance of the default org.apache.abdera.writer.Writer
+   * 
+   * @return A new default writer implementation instance
+   */
+  public StreamWriter newStreamWriter() {
+    try {
+      return ServiceUtil.newStreamWriterInstance(this);
+    } catch (NoClassDefFoundError n) {
+      throw new RuntimeException(Messages.format("IMPLEMENTATION.NOT.AVAILABLE","StreamWriter"),n);
+    }
+  }  
+  
   // Static convenience methods //
   
   /**
@@ -322,5 +336,14 @@
    */
   public static Writer getNewWriter() {
     return (new Abdera()).newWriter();
+  }
+  
+  /**
+   * Return a new instance of the default StreamWriter using a non-shared Abdera object
+   * 
+   *  @return A new default stream writer implementation instance
+   */
+  public static StreamWriter getNewStreamWriter() {
+    return (new Abdera()).newStreamWriter();
   }
 }

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/NamedItem.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/NamedItem.java?rev=591523&view=auto
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/NamedItem.java (added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/NamedItem.java Fri Nov  2 17:32:39 2007
@@ -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.abdera;
+
+public interface NamedItem {
+
+  String getName();
+  
+}

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java Fri Nov  2 17:32:39 2007
@@ -17,6 +17,8 @@
 */
 package org.apache.abdera.parser;
 
+import org.apache.abdera.NamedItem;
+
 /**
  * Abdera's abstract parsing model allows developers to implement parsers 
  * capable of translating non-Atom formats into Abdera objects.  For instance,
@@ -32,14 +34,8 @@
  *   Document<Feed> doc = parser.parse(...);
  * </pre>
  */
-public interface NamedParser extends Parser {
+public interface NamedParser extends Parser, NamedItem {
 
-  /**
-   * Returns the name used to retrieve this parser (case insensitive)
-   * @return The name of this parser
-   */
-  String getName();
-  
   /**
    * Returns a listing of media type of the format consumed by this parser
    * @return An array of MIME Media Types

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java Fri Nov  2 17:32:39 2007
@@ -18,6 +18,8 @@
 package org.apache.abdera.util;
 
 import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -29,6 +31,7 @@
 import org.apache.abdera.factory.ExtensionFactory;
 import org.apache.abdera.parser.NamedParser;
 import org.apache.abdera.writer.NamedWriter;
+import org.apache.abdera.writer.StreamWriter;
 
 /**
  * Provides the basic configuration for the Abdera default implementation.  This
@@ -77,9 +80,11 @@
   private final String parserFactory;
   private final String writerFactory;
   private final String writer;
+  private final String streamwriter;
   private final List<ExtensionFactory> factories;
   private final List<ConverterProvider> providers;
   private final Map<String,NamedWriter> writers;
+  private final Map<String,Class<? extends StreamWriter>> streamwriters;
   private final Map<String,NamedParser> parsers;
   
   public AbderaConfiguration() {
@@ -97,10 +102,12 @@
     parserFactory = getConfigurationOption(CONFIG_PARSERFACTORY, DEFAULT_PARSERFACTORY);
     writerFactory = getConfigurationOption(CONFIG_WRITERFACTORY, DEFAULT_WRITERFACTORY);
     writer = getConfigurationOption(CONFIG_WRITER, DEFAULT_WRITER);
+    streamwriter = getConfigurationOption(CONFIG_STREAMWRITER, DEFAULT_STREAMWRITER);
     factories = ServiceUtil.loadExtensionFactories();
     providers = ServiceUtil.loadConverterProviders();
     writers = initNamedWriters();
     parsers = initNamedParsers();
+    streamwriters = initStreamWriters();
   }  
   
   private ResourceBundle getBundle() {
@@ -175,6 +182,13 @@
   public String getDefaultWriter() {
     return writer;
   }
+
+  /**
+   * Returns the Java classname of the default StreamWriter implementation
+   */
+  public String getDefaultStreamWriter() {
+    return streamwriter;
+  }
   
   /**
    * Registers an ExtensionFactory implementation.
@@ -221,12 +235,41 @@
     }
     return writers;
   }
+
+  /**
+   * Registers StreamWriter implementations using 
+   * the /META-INF/services/org.apache.abdera.writer.StreamWriter file
+   */
+  private Map<String,Class<? extends StreamWriter>> initStreamWriters() {
+    Map<String,Class<? extends StreamWriter>> writers = null;
+    List<Class<? extends StreamWriter>> _writers = 
+      ServiceUtil._loadimpls(STREAM_WRITER,true);
+    writers = Collections.synchronizedMap(new HashMap<String,Class<? extends StreamWriter>>());
+    for (Class<? extends StreamWriter> writer : _writers) {
+      try {
+        Field field = writer.getField("NAME");
+        if (Modifier.isStatic(field.getModifiers())) {
+          String name = (String)field.get(null);
+          if (name != null)
+            writers.put(name.toLowerCase(), writer);
+        }
+      } catch (Exception e) {}
+    }
+    return writers;
+  }
   
   /**
    * Returns the collection of NamedWriters
    */
   public Map<String,NamedWriter> getNamedWriters() {
     return writers;
+  }
+
+  /**
+   * Returns the collection of NamedWriters
+   */
+  public Map<String,Class<? extends StreamWriter>> getStreamWriters() {
+    return streamwriters;
   }
   
   /**

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java?rev=591523&view=auto
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java (added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java Fri Nov  2 17:32:39 2007
@@ -0,0 +1,895 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.AtomDate;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Text;
+import org.apache.abdera.writer.StreamWriter;
+import org.apache.commons.codec.binary.Base64;
+
+public abstract class AbstractStreamWriter 
+  implements StreamWriter {
+  
+  protected final String name;
+  
+  protected AbstractStreamWriter(String name) {
+    this.name = name;
+  }
+  
+  public String getName() {
+    return name;
+  }
+  
+  public void startDocument() {
+    startDocument("1.0");
+  }
+ 
+  public void endDocument() {}
+  
+  public void startFeed() {
+    startFeed(null);
+  }
+  
+  public void startFeed(Map<QName,String> attributes) {
+    startElement(Constants.FEED, attributes);
+  }
+
+  public void endFeed() {
+    endElement();
+  }
+  
+  public void startEntry(Map<QName,String> attributes) {
+    startElement(Constants.ENTRY, attributes);
+  }
+  
+  public void startEntry() {
+    startEntry(null);
+  }
+  
+  public void endEntry() {
+    endElement();
+  }
+  
+  public void endCategory() {
+    endElement();
+  }
+  
+  public void endContent() {
+    endElement();
+  }
+  
+  public void endLink() {
+    endElement();
+  }
+  
+  public void endPerson() {
+    endElement();
+  }
+  
+  public void endSource() {
+    endElement();
+  }
+  
+  public void endText() {
+    endElement();
+  }
+  
+  
+  public void startCategory(
+    String term, 
+    Map<QName, String> attributes) {
+      startCategory(term,null,null,attributes);
+  }
+  
+  public void startCategory(
+    String term, 
+    String scheme,
+    Map<QName, String> attributes) {
+      startCategory(term,scheme,null,attributes);
+  }
+  
+  public void startCategory(
+    String term, 
+    String scheme, 
+    String label,
+    Map<QName, String> attributes) {
+      if (attributes == null) attributes = new HashMap<QName,String>();
+      attributes.put(new QName("term"),term);
+      if (scheme != null) attributes.put(new QName("scheme"),term);
+      if (label != null) attributes.put(new QName("label"),term);
+      startElement(Constants.CATEGORY,attributes);
+  }
+
+  public void startLink(
+    String iri, 
+    String rel, 
+    String type, 
+    String title,
+    String hreflang, 
+    int length, 
+    Map<QName, String> attributes) {
+      if (attributes == null) attributes = new HashMap<QName,String>();
+      attributes.put(new QName("href"),iri);
+      if (rel != null) attributes.put(new QName("rel"),rel);
+      if (type != null) attributes.put(new QName("type"),type);
+      if (title != null) attributes.put(new QName("title"),title);
+      if (hreflang != null) attributes.put(new QName("hreflang"),hreflang);
+      if (length > -1) attributes.put(new QName("length"),String.valueOf(length));
+      startElement(Constants.LINK,attributes);
+    
+  }
+
+  public void startPerson(
+    QName qname, 
+    Map<QName, String> attributes) {
+      startElement(qname, attributes);
+  }
+  
+  public void startSource(
+    Map<QName, String> attributes) {
+      startElement(Constants.SOURCE,attributes);
+  }
+  
+  public void startText(
+    QName qname, 
+    Text.Type type,
+    Map<QName, String> attributes) {
+    if (attributes == null) attributes = new HashMap<QName,String>();
+    attributes.put(new QName("type"),type!=null?type.name().toLowerCase():"text");
+    startElement(qname,attributes);
+  }
+  
+  public void writeDate(
+    QName qname, 
+    String date, 
+    Map<QName, String> attributes) {
+      startElement(qname,attributes);
+      writeElementText(date);
+      endElement();
+  }
+  
+  public void writeIRIElement(
+    QName qname, 
+    String iri,
+    Map<QName, String> attributes) {
+      startElement(qname,attributes);
+      writeElementText(iri);
+      endElement();
+  }
+  
+  public void writePersonEmail(
+    String email, 
+    Map<QName, String> attributes) {
+      startElement(Constants.EMAIL,attributes);
+      writeElementText(email);
+      endElement();
+  }
+  
+  public void writePersonName(
+    String name, 
+    Map<QName, String> attributes) {
+      startElement(Constants.NAME,attributes);
+      writeElementText(name);
+      endElement();    
+  }
+  
+  public void writePersonUri(
+    String uri, 
+    Map<QName, String> attributes) {
+      startElement(Constants.URI,attributes);
+      writeElementText(uri);
+      endElement();
+  }
+
+  public void startContent(
+    Content.Type type, 
+    String src, 
+    Map<QName, String> attributes) {
+      startContent(type.name().toLowerCase(),src,attributes);
+  }
+  
+  public void startContent(
+    String type, 
+    String src,
+    Map<QName, String> attributes) {
+      if (attributes == null) attributes = new HashMap<QName,String>();
+      attributes.put(new QName("type"),type);
+      if (src != null) attributes.put(new QName("src"),src);
+      startElement(Constants.CONTENT,attributes);
+  }
+  
+  public void startContent(
+    Content.Type type, 
+    Map<QName, String> attributes) {
+      startContent(type,null,attributes);
+  }
+  
+  public void startContent(
+    String type, 
+    Map<QName, String> attributes) {
+      startContent(type,null,attributes);
+  }
+  
+  public void startLink(
+    String iri, 
+    Map<QName, String> attributes) {
+      startLink(iri,null,null,null,null,-1,attributes);
+  }
+  
+  public void startLink(
+    String iri, 
+    String rel, 
+    Map<QName, String> attributes) {
+      startLink(iri,rel,null,null,null,-1,attributes);
+  }
+  
+  public void startLink(
+    String iri, 
+    String rel, 
+    String type,
+    Map<QName, String> attributes) {
+      startLink(iri,rel,type,null,null,-1,attributes);
+  }
+  
+  public void writeCategory(
+    String term, Map<QName, 
+    String> attributes) {
+      startCategory(term, attributes);
+      endCategory();
+  }
+  
+  public void writeCategory(
+    String term, 
+    String scheme,
+    Map<QName, String> attributes) {
+      startCategory(term,scheme,attributes);
+      endCategory();
+  }
+  
+  public void writeCategory(
+    String term, 
+    String scheme, 
+    String label,
+    Map<QName, String> attributes) {
+      startCategory(term,scheme,label,attributes);
+      endCategory();
+  }
+  
+  public void writeContent(
+    Content.Type type, 
+    String value,
+    Map<QName, String> attributes) {
+      startContent(type,attributes);
+      writeElementText(value);
+      endContent();
+  }
+  
+  public void writeContent(
+    Content.Type type, 
+    InputStream value,
+    Map<QName, String> attributes) throws IOException {
+      startContent(type,attributes);
+      writeElementText(value);
+      endContent();    
+  }
+  
+  public void writeContent(
+    Content.Type type, 
+    DataHandler value,
+    Map<QName, String> attributes) throws IOException {
+      startContent(type,attributes);
+      writeElementText(value);
+      endContent();
+  }
+  
+  public void writeContent(
+    String type, 
+    String value,
+    Map<QName, String> attributes) {
+      startContent(type,attributes);
+      writeElementText(value);
+      endContent();
+  }
+  
+  public void writeEdited(
+    Date date, 
+    Map<QName, String> attributes) {
+      writeDate(Constants.EDITED, date, attributes);
+  }
+  
+  public void writeId(
+    String iri, 
+    Map<QName, String> attributes) {
+      writeIRIElement(Constants.ID, iri, attributes);
+  }
+  
+  public void writeIcon(
+    String iri, 
+    Map<QName,String> attributes) {
+      writeIRIElement(Constants.ICON, iri, attributes);
+  }
+  
+  public void writeLogo(
+    String iri, 
+    Map<QName,String> attributes) {
+      writeIRIElement(Constants.LOGO, iri, attributes);
+  }
+  
+  
+  public void writeLink(
+    String iri, 
+    Map<QName, String> attributes) {
+      startLink(iri, attributes);
+      endLink();
+  }
+  
+  public void writeLink(
+    String iri, 
+    String rel, 
+    Map<QName, String> attributes) {
+      startLink(iri, rel, attributes);
+      endLink();
+  }
+  
+  public void writeLink(
+    String iri, 
+    String rel, 
+    String type,
+    Map<QName, String> attributes) {
+    startLink(iri, rel, type, attributes);
+    endLink();
+  }
+  
+  public void writeLink(
+    String iri, 
+    String rel, 
+    String type, 
+    String title,
+    String hreflang, 
+    int length, 
+    Map<QName, String> attributes) {
+      startLink(iri, rel, type, title, hreflang, length, attributes);
+      endLink();
+  }
+  
+  public void writePerson(
+    QName qname, 
+    String name, 
+    String email, 
+    String uri,
+    Map<QName, String> attributes) {
+      startPerson(qname,attributes);
+      writePersonName(name,null);
+      if (email != null) writePersonEmail(email,null);
+      if (uri != null) writePersonUri(uri,null);
+      endPerson();
+  }
+  
+  public void writePublished(
+    Date date, 
+    Map<QName, String> attributes) {
+      writeDate(Constants.PUBLISHED,date,attributes);
+  }
+  
+  public void writeText(
+    QName qname, 
+    Text.Type type,
+    String value, 
+    Map<QName, String> attributes) {
+      startText(qname,type,attributes);
+      writeElementText(value);
+      endText();
+  }
+  
+  public void writeUpdated(
+    Date date, 
+    Map<QName, String> attributes) {
+      writeDate(Constants.UPDATED,date,attributes);
+  }
+  
+  public void writeUpdated(String date, Map<QName,String> attributes) {
+    writeDate(Constants.UPDATED, date, attributes);
+  }
+  
+  public void writePublished(String date, Map<QName,String> attributes) {
+    writeDate(Constants.PUBLISHED, date, attributes);
+  }
+  
+  public void writeEdited(String date, Map<QName,String> attributes) {
+    writeDate(Constants.EDITED, date, attributes);
+  }
+  
+  public void writeDate(QName qname, Date date, Map<QName,String> attributes) {
+    writeDate(qname, AtomDate.format(date), attributes);
+  }
+  
+  public void writeId(IRI iri, Map<QName,String> attributes) {
+    writeIRIElement(Constants.ID, iri, attributes);
+  }
+  
+  public void writeIcon(IRI iri, Map<QName,String> attributes) {
+    writeIRIElement(Constants.ICON, iri, attributes);
+  }
+  
+  public void writeLogo(IRI iri, Map<QName,String> attributes) {
+    writeIRIElement(Constants.LOGO, iri, attributes);
+  }
+  
+  public void writeIRIElement(QName qname, IRI iri, Map<QName,String> attributes) {
+    writeIRIElement(qname, iri.toString(), attributes);
+  }
+  
+  public void 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"));
+  }
+  
+  public void writeElementText(DataHandler value) throws IOException {
+    writeElementText(value.getInputStream());
+  }
+  
+  public void writeTitle(String value) {
+    writeText(Constants.TITLE, Text.Type.TEXT, value, null);
+  }
+  
+  public void writeTitle(Text.Type type, String value) {
+    writeText(Constants.TITLE, type, value, null);
+  }
+
+  public void writeSubtitle(String value) {
+    writeText(Constants.SUBTITLE, Text.Type.TEXT, value, null);
+  }
+  
+  public void writeSubtitle(Text.Type type, String value) {
+    writeText(Constants.SUBTITLE, type, value, null);
+  }
+  
+  public void writeSummary(String value) {
+    writeText(Constants.SUMMARY, Text.Type.TEXT, value, null);
+  }
+  
+  public void writeSummary(Text.Type type, String value) {
+    writeText(Constants.SUMMARY, type, value, null);
+  }
+  
+  public void writeRights(String value) {
+    writeText(Constants.RIGHTS, Text.Type.TEXT, value, null);
+  }
+  
+  public void writeRights(Text.Type type, String value) {
+    writeText(Constants.RIGHTS, type, value, null);
+  }
+
+
+  
+  public void writeTitle(String value, Map<QName,String> attributes) {
+    writeText(Constants.TITLE, Text.Type.TEXT, value, attributes);
+  }
+  
+  public void writeTitle(Text.Type type, String value, Map<QName,String> attributes) {
+    writeText(Constants.TITLE, type, value, attributes);
+  }
+
+  public void writeSubtitle(String value, Map<QName,String> attributes) {
+    writeText(Constants.SUBTITLE, Text.Type.TEXT, value, attributes);
+  }
+  
+  public void writeSubtitle(Text.Type type, String value, Map<QName,String> attributes) {
+    writeText(Constants.SUBTITLE, type, value, attributes);
+  }
+  
+  public void writeSummary(String value, Map<QName,String> attributes) {
+    writeText(Constants.SUMMARY, Text.Type.TEXT, value, attributes);
+  }
+  
+  public void writeSummary(Text.Type type, String value, Map<QName,String> attributes) {
+    writeText(Constants.SUMMARY, type, value, attributes);
+  }
+  
+  public void writeRights(String value, Map<QName,String> attributes) {
+    writeText(Constants.RIGHTS, Text.Type.TEXT, value, attributes);
+  }
+  
+  public void writeRights(Text.Type type, String value, Map<QName,String> attributes) {
+    writeText(Constants.RIGHTS, type, value, attributes);
+  }
+  
+  
+  
+  public void writeId(String iri) {
+    writeIRIElement(Constants.ID, iri, null); 
+  }
+  
+  public void writeIcon(String iri) {
+    writeIRIElement(Constants.ICON, iri, null);
+  }
+  
+  public void writeLogo(String iri) {
+    writeIRIElement(Constants.LOGO, iri, null);
+  }
+  
+  public void writeIRIElement(QName qname, String iri) {
+    writeIRIElement(qname, iri, null);
+  }
+
+  public void writeId(IRI iri) {
+    writeIRIElement(Constants.ID, iri, null);
+  }
+  
+  public void writeIcon(IRI iri) {
+    writeIRIElement(Constants.ICON, iri, null);
+  }
+  
+  public void writeLogo(IRI iri) {
+    writeIRIElement(Constants.LOGO, iri, null);
+  }
+  
+  public void writeIRIElement(QName qname, IRI iri) {
+    writeIRIElement(qname, iri, null);
+  }
+  
+  public void writeId() {
+    writeId((Map<QName,String>)null);
+  }
+   
+  public void writePerson(QName qname, String name, String email, String uri) {
+    writePerson(qname,name,email,uri,null);
+  }
+  
+  public void startPerson(QName qname) {
+    startPerson(qname,null);
+  }
+  
+  public void writePersonName(String name) {
+    writePersonName(name,null);
+  }
+  
+  public void writePersonEmail(String email) {
+    writePersonEmail(email,null);
+  }
+  
+  public void writePersonUri(String uri) {
+    writePersonUri(uri,null);
+  }
+ 
+
+  public void writeAuthor(String name, String email, String uri) {
+    writePerson(Constants.AUTHOR,name,email,uri,null);
+  }
+
+  public void writeAuthor(String name, String email, String uri, Map<QName,String> attributes) {
+    writePerson(Constants.AUTHOR,name,email,uri,attributes);
+  }
+  
+  public void startAuthor() {
+    startElement(Constants.AUTHOR,null);
+  }
+
+  public void startAuthor(Map<QName,String> attributes) {
+    startElement(Constants.AUTHOR,attributes);
+  }
+  
+  public void endAuthor() {
+    endElement();
+  }
+  
+
+  public void writeContributor(String name, String email, String uri) {
+    writePerson(Constants.CONTRIBUTOR,name,email,uri,null);
+  }
+
+  public void writeContributor(String name, String email, String uri, Map<QName,String> attributes) {
+    writePerson(Constants.CONTRIBUTOR,name,email,uri,attributes);
+  }
+  
+  public void startContributor() {
+    startElement(Constants.CONTRIBUTOR,null);
+  }
+
+  public void startContributor(Map<QName,String> attributes) {
+    startElement(Constants.CONTRIBUTOR,attributes);
+  }
+  
+  public void endContributor() {
+    endElement();
+  }
+  
+  public void writeGenerator(String version, String uri, String value) {
+    writeGenerator(version,uri,value,null);
+  }
+  
+  public void writeGenerator(String version, String uri, String value, Map<QName,String> attributes) {
+    if (attributes == null) attributes = new HashMap<QName,String>();
+    if (version != null) attributes.put(new QName("version"),version);
+    if (uri != null) attributes.put(new QName("uri"),uri);
+    startElement(Constants.GENERATOR,attributes);
+    writeElementText(value);
+    endElement();
+  }
+
+  public void startGenerator(String version, String uri) {
+    startGenerator(version,uri,null);
+  }
+  
+  public void startGenerator(String version, String uri, Map<QName,String> attributes) {
+    if (attributes == null) attributes = new HashMap<QName,String>();
+    if (version != null) attributes.put(new QName("version"),version);
+    if (uri != null) attributes.put(new QName("uri"),uri);
+    startElement(Constants.GENERATOR,attributes);    
+  }
+  
+  public void endGenerator() {
+    endElement();
+  }
+  
+  
+  public void writeUpdated(Date date) {
+    writeUpdated(date,null);
+  }
+  
+  public void writePublished(Date date) {
+    writePublished(date,null);
+  }
+  
+  public void writeEdited(Date date) {
+    writeEdited(date,null);
+  }
+  
+  public void writeDate(QName qname, Date date) {
+    writeDate(qname,date,null);
+  }
+
+  public void writeUpdated(String date) {
+    writeUpdated(date,null);
+  }
+  
+  public void writePublished(String date) {
+    writePublished(date,null);
+  }
+  
+  public void writeEdited(String date) {
+    writeEdited(date,null);
+  }
+  
+  public void writeDate(QName qname, String date) {
+    writeDate(qname, date,null);
+  }
+  
+  
+  public void writeLink(String iri) {
+    writeLink(iri,(Map<QName,String>)null);
+  }
+  
+  public void writeLink(String iri, String rel) {
+    writeLink(iri,rel,(Map<QName,String>)null);
+  }
+  
+  public void writeLink(String iri, String rel, String type) {
+    writeLink(iri,rel,type,(Map<QName,String>)null);
+  }
+  
+  public void writeLink(String iri, String rel, String type, String title, String hreflang, int length) {
+    writeLink(iri,rel,type,title,hreflang,length,(Map<QName,String>)null);
+  }
+  
+  public void startLink(String iri) {
+    startLink(iri,(Map<QName,String>)null);
+  }
+
+  public void startLink(String iri, String rel) {
+    startLink(iri,rel,(Map<QName,String>)null);
+  }
+  
+  public void startLink(String iri, String rel, String type) {
+    startLink(iri,rel,type,(Map<QName,String>)null);
+  }
+  
+  public void startLink(String iri, String rel, String type, String title, String hreflang, int length) {
+    startLink(iri,rel,type,title,hreflang,length,(Map<QName,String>)null);
+  }
+  
+  
+  public void writeCategory(String term) {
+   writeCategory(term,(Map<QName,String>)null); 
+  }
+  
+  public void writeCategory(String term, String scheme) {
+   writeCategory(term,scheme,(Map<QName,String>)null); 
+  }
+  
+  public void writeCategory(String term, String scheme, String label) {
+   writeCategory(term,scheme,label,(Map<QName,String>)null); 
+  }
+  
+  public void startCategory(String term) {
+   startCategory(term,(Map<QName,String>)null); 
+  }
+  
+  public void startCategory(String term, String scheme) {
+   startCategory(term,scheme,(Map<QName,String>)null); 
+  }
+  
+  public void startCategory(String term, String scheme, String label) {
+   startCategory(term,scheme,label,(Map<QName,String>)null); 
+  }
+  
+  public void startSource() {
+    startElement(Constants.SOURCE,null);
+  }
+  
+  public void writeText(QName qname, Text.Type type, String value) {
+    writeText(qname,type,value,null);
+  }
+  
+  public void startText(QName qname, Text.Type type) {
+    startText(qname,type,null);
+  }
+  
+  
+  public void writeContent(Content.Type type, String value) {
+    writeContent(type,value,null);
+  }
+  
+  public void writeContent(Content.Type type, InputStream value) throws IOException {
+    writeContent(type,value,null);
+  }
+  
+  public void writeContent(Content.Type type, DataHandler value) throws IOException {
+    writeContent(type,value,null);
+  }
+  
+  public void writeContent(String type, String value) {
+    writeContent(type,value,null);
+  }
+  
+  
+  public void startContent(Content.Type type) {
+    startContent(type,(Map<QName,String>)null);
+  }
+  
+  public void startContent(String type) {
+    startContent(type,(Map<QName,String>)null);
+  }
+  
+  public void startContent(Content.Type type, String src) {
+    startContent(type,(Map<QName,String>)null);
+  }
+  
+  public void startContent(String type, String src) {
+    startContent(type,(Map<QName,String>)null);
+  }
+  
+  public void startElement(QName qname) {
+    startElement(qname,null);
+  }
+  
+  
+  
+  public void startService() {
+    startElement(Constants.SERVICE);
+  }
+  
+  public void startService(Map<QName,String> attributes) {
+    startElement(Constants.SERVICE,attributes);
+  }
+  
+  public void endService() {
+    endElement();
+  }
+  
+  public void startWorkspace() {
+    startElement(Constants.WORKSPACE, null);
+  }
+  
+  public void startWorkspace(Map<QName,String> attributes) {
+    startElement(Constants.WORKSPACE, attributes);
+  }
+  
+  public void endWorkspace() {
+    endElement();
+  }
+  
+  public void startCollection(String href) {
+    startCollection(href, null);
+  }
+  
+  public void startCollection(String href, Map<QName,String> attributes) {
+    if (attributes == null) attributes = new HashMap<QName,String>();
+    attributes.put(new QName("href"),href);
+    startElement(Constants.COLLECTION, attributes);
+  }
+  
+  public void endCollection() {
+    endElement();
+  }
+  
+  public void writeAccepts(String... accepts) {
+    for (String accept : accepts) {
+      startElement(Constants.ACCEPT,null);
+      writeElementText(accept);
+      endElement();
+    }
+  }
+  
+  public void startCategories() {
+    startCategories(false,null,null);
+  }
+  
+  public void startCategories(boolean fixed) {
+    startCategories(fixed,null,null);
+  }
+  
+  public void startCategories(boolean fixed, String scheme) {
+    startCategories(fixed,scheme,null);
+  }
+  
+  public void startCategories(Map<QName,String> attributes) {
+    startCategories(false,null,attributes);
+  }
+  
+  public void startCategories(boolean fixed, Map<QName,String> attributes) {
+    startCategories(fixed,null,attributes);
+  }
+  
+  public void startCategories(boolean fixed, String scheme, Map<QName,String> attributes) {
+    if (attributes == null) attributes = new HashMap<QName,String>();
+    if (fixed) attributes.put(new QName("fixed"),"true");
+    else attributes.remove("fixed");
+    if (scheme != null) attributes.put(new QName("scheme"),scheme);
+    startElement(Constants.CATEGORIES, attributes);
+  }
+  
+  public void endCategories() {
+    endElement();
+  }
+
+  public void startControl() {
+    startElement(Constants.CONTROL,null);
+  }
+  
+  public void startControl(Map<QName,String> attributes) {
+    startElement(Constants.CONTROL, attributes);
+  }
+  
+  public void endControl() {
+    endElement();
+  }
+  
+  public void writeDraft(boolean draft) {
+    startElement(Constants.DRAFT);
+    writeElementText(draft?"yes":"no");
+    endElement();
+  }
+  
+}

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java Fri Nov  2 17:32:39 2007
@@ -27,14 +27,17 @@
   public static final String CONFIG_PARSERFACTORY = "org.apache.abdera.parser.ParserFactory";
   public static final String CONFIG_WRITERFACTORY = "org.apache.abdera.writer.WriterFactory";
   public static final String CONFIG_WRITER        = "org.apache.abdera.writer.Writer";
+  public static final String CONFIG_STREAMWRITER  = "org.apache.abdera.writer.StreamWriter";
   public static final String DEFAULT_PARSER       = "org.apache.abdera.parser.stax.FOMParser";
   public static final String DEFAULT_FACTORY      = "org.apache.abdera.parser.stax.FOMFactory";
   public static final String DEFAULT_XPATH        = "org.apache.abdera.parser.stax.FOMXPath";
   public static final String DEFAULT_PARSERFACTORY= "org.apache.abdera.parser.stax.FOMParserFactory";
   public static final String DEFAULT_WRITERFACTORY= "org.apache.abdera.parser.stax.FOMWriterFactory";
   public static final String DEFAULT_WRITER       = "org.apache.abdera.parser.stax.FOMWriter";
+  public static final String DEFAULT_STREAMWRITER = "org.apache.abdera.parser.stax.StaxStreamWriter";
   public static final String NAMED_WRITER         = "META-INF/services/org.apache.abdera.writer.NamedWriter";
   public static final String NAMED_PARSER         = "META-INF/services/org.apache.abdera.parser.NamedParser";
+  public static final String STREAM_WRITER        = "META-INF/services/org.apache.abdera.writer.StreamWriter";
   public static final String PREFIX               = "";
   public static final String APP_PREFIX           = "";
   public static final String CONTROL_PREFIX       = "";

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/ServiceUtil.java Fri Nov  2 17:32:39 2007
@@ -18,9 +18,9 @@
 package org.apache.abdera.util;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.net.URL;
 import java.util.ArrayList;
@@ -34,6 +34,7 @@
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.parser.ParserFactory;
+import org.apache.abdera.writer.StreamWriter;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
 import org.apache.abdera.xpath.XPath;
@@ -121,6 +122,13 @@
       abdera);
   }
   
+  public static StreamWriter newStreamWriterInstance(Abdera abdera) {
+    return (StreamWriter) newInstance(
+      CONFIG_STREAMWRITER,
+      abdera.getConfiguration().getDefaultStreamWriter(),
+      abdera);    
+  }
+  
   /**
    * Get the context class loader for this thread
    */
@@ -211,17 +219,21 @@
     return null;
   }
   
-  @SuppressWarnings("unchecked")
   public static Object locateInstance(ClassLoader loader, String id, Abdera abdera) {
+    return locateInstance(loader,id,abdera,false);
+  }
+  
+  @SuppressWarnings("unchecked")
+  public static Object locateInstance(ClassLoader loader, String id, Abdera abdera, boolean classesonly) {
     try {
       Class _class = loader.loadClass(id);
-      return _create(_class, abdera);
+      return classesonly ? _class : _create(_class, abdera);
     } catch (Exception e) {
       // Nothing
     }
     try {
       Class _class = ClassLoader.getSystemClassLoader().loadClass(id);
-      return _create(_class, abdera);
+      return classesonly ? _class : _create(_class, abdera);
     } catch (Exception e) {
       // Nothing
     }
@@ -314,7 +326,7 @@
   }
   
   @SuppressWarnings("unchecked")
-  protected static <T>List<T> _loadimpls(String sid) {
+  protected static <T>List<T> _loadimpls(String sid, boolean classesonly) {
     List<T> impls = Collections.synchronizedList(new ArrayList<T>());
     ClassLoader loader = getClassLoader();
     try {
@@ -353,5 +365,10 @@
     }
     
     return impls;
+  }
+ 
+  @SuppressWarnings("unchecked")
+  protected static <T>List<T> _loadimpls(String sid) {
+    return _loadimpls(sid,false);
   }
 }

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/NamedWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/NamedWriter.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/NamedWriter.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/NamedWriter.java Fri Nov  2 17:32:39 2007
@@ -17,15 +17,12 @@
 */
 package org.apache.abdera.writer;
 
+import org.apache.abdera.NamedItem;
+
 /**
  * Named Writers provide a means of extending Abdera's built in serialization.
  */
-public interface NamedWriter extends Writer {
-
-  /**
-   * Return the name used to acquire an instance of this Writer (case insensitive)
-   */
-  String getName();
+public interface NamedWriter extends Writer, NamedItem {
 
   /**
    * Return a listing of MIME Media formats this NamedWriter is capable 

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java?rev=591523&view=auto
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java (added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java Fri Nov  2 17:32:39 2007
@@ -0,0 +1,1213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.writer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.NamedItem;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.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 
+ */
+public interface StreamWriter 
+  extends NamedItem {
+
+  /**
+   * Set the target java.io.Writer
+   */
+  void setWriter(java.io.Writer writer);
+  
+  /**
+   * Set the target java.io.OutputStream
+   */
+  void setOutputStream(java.io.OutputStream out);
+  
+  /**
+   * Set the target java.io.OutputStream
+   */
+  void setOutputStream(java.io.OutputStream out, String charset);
+  
+  /**
+   * Start the document
+   * @param xmlversion The XML version
+   * @param charset the Character Encoding
+   */
+  void startDocument(String xmlversion, String charset);
+
+  /**
+   * Start the document
+   * @param xmlversion The XML version
+   */
+  void startDocument(String xmlversion);
+  
+  /**
+   * Start the document
+   */
+  void startDocument();
+ 
+  /**
+   * End the document
+   */
+  void endDocument();
+  
+  /**
+   * Start an atom:feed element
+   */
+  void startFeed();
+
+  /**
+   * Start an atom:feed element
+   * @param attribute Extension attributes
+   */
+  void startFeed(Map<QName,String> attributes);
+  
+  /**
+   * End the atom:feed element
+   */
+  void endFeed();
+  
+  /**
+   * Start an atom:entry element
+   */
+  void startEntry();
+  
+  /**
+   * Start an atom:entry element
+   * @param attribute Extension attributes
+   */
+  void startEntry(Map<QName,String> attributes);
+  
+  /**
+   * End the atom:entry element
+   */
+  void endEntry();
+  
+  /**
+   * Write an atom:id element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeId(String iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:icon element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeIcon(String iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:logo element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeLogo(String iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an IRI element element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeIRIElement(QName qname, String iri, Map<QName,String> attributes);
+
+  /**
+   * Write an atom:id element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeId(IRI iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:icon element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeIcon(IRI iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:logo element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeLogo(IRI iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:iri element
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeIRIElement(QName qname, IRI iri, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:id element
+   * @param iri The value
+   */
+  void writeId(String iri);
+  
+  /**
+   * Write an atom:icon element
+   * @param iri The value
+   */
+  void writeIcon(String iri);
+  
+  /**
+   * Write an atom:logo element
+   * @param iri The value
+   */
+  void writeLogo(String iri);
+  
+  /**
+   * Write an IRI element
+   * @param iri The value
+   */
+  void writeIRIElement(QName qname, String iri);
+
+  /**
+   * Write an atom:id element
+   * @param iri The value
+   */
+  void writeId(IRI iri);
+  
+  /**
+   * Write an atom:icon element
+   * @param iri The value
+   */
+  void writeIcon(IRI iri);
+  
+  /**
+   * Write an atom:logo element
+   * @param iri The value
+   */
+  void writeLogo(IRI iri);
+  
+  /**
+   * Write an IRI element
+   * @param iri The value
+   */
+  void writeIRIElement(QName qname, IRI iri);
+  
+  /**
+   * Write an atom:id element with a new IRI value
+   * @param iri The value
+   */
+  void writeId();
+
+  /**
+   * Write an atom:id element with a new IRI value
+   * @param iri The value
+   * @param attribute Extension attributes
+   */
+  void writeId(Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:updated element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writeUpdated(Date date, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:published element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writePublished(Date date, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:edited element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writeEdited(Date date, Map<QName,String> attributes);
+  
+  /**
+   * Write a Date element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writeDate(QName qname, Date date, Map<QName,String> attributes);
+
+  /**
+   * Write an atom:updated element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writeUpdated(String date, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:published element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writePublished(String date, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:edited element
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writeEdited(String date, Map<QName,String> attributes);
+  
+  /**
+   * Write a Date element
+   * @param qname The element qname
+   * @param date The date value
+   * @param attributes Extension attributes
+   */
+  void writeDate(QName qname, String date, Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:updated element
+   * @param date The date value
+   */
+  void writeUpdated(Date date);
+  
+  /**
+   * Write an atom:published element
+   * @param date The date value
+   */
+  void writePublished(Date date);
+  
+  /**
+   * Write an atom:edited element
+   * @param date The date value
+   */
+  void writeEdited(Date date);
+  
+  /**
+   * Write a Date element
+   * @param qname The element qname
+   * @param date The date value
+   */
+  void writeDate(QName qname, Date date);
+
+  /**
+   * Write an atom:updated element
+   * @param date The date value
+   */
+  void writeUpdated(String date);
+  
+  /**
+   * Write an atom:published element
+   * @param date The date value
+   */
+  void writePublished(String date);
+  
+  /**
+   * Write an atom:edited element
+   * @param date The date value
+   */
+  void writeEdited(String date);
+  
+  /**
+   * Write a Date element
+   * @param qname The element qname
+   * @param date The date value
+   */
+  void writeDate(QName qname, String date);
+  
+  /**
+   * Write a person element
+   * @param qname The element qname
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   * @param attributes Extension attributes
+   */  
+  void writePerson(QName qname, String name, String email, String uri, Map<QName,String> attributes);
+  
+  /**
+   * Start a person element
+   * @param qname The element qname
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   * @param attributes Extension attributes
+   */  
+  void startPerson(QName qname, Map<QName,String> attributes);
+  
+  /**
+   * Write a person name element
+   * @param name The person name
+   * @param attributes Extension attributes
+   */
+  void writePersonName(String name,Map<QName,String> attributes);
+  
+  /**
+   * Write a person email element
+   * @param email The person email
+   * @param attributes Extension attributes
+   */
+  void writePersonEmail(String email,Map<QName,String> attributes);
+  
+  /**
+   * Write a person uri element
+   * @param uri The person uri
+   * @param attributes Extension attributes
+   */
+  void writePersonUri(String uri,Map<QName,String> attributes);
+  
+  /**
+   * End the person element
+   */
+  void endPerson();
+  
+  
+  /**
+   * Write an atom:link element
+   * @param iri The href value
+   * @param attributes Extension attributes
+   */
+  void writeLink(String iri,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:link element
+   * @param iri The href value
+   * @param rel The rel value
+   * @param attributes Extension attributes
+   */
+  void writeLink(String iri, String rel,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:link element
+   * @param iri The href value
+   * @param rel The rel value
+   * @param type The type value
+   * @param attributes Extension attributes
+   */
+  void writeLink(String iri, String rel, String type,Map<QName,String> attributes);
+  
+  /**
+   * 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
+   * @param attributes Extension attributes
+   */
+  void writeLink(String iri, String rel, String type, String title, String hreflang, int length,Map<QName,String> attributes);
+
+  /**
+   * Start a atom:link element
+   * @param iri The href value
+   * @param attributes Extension attributes
+   */
+  void startLink(String iri,Map<QName,String> attributes);
+
+  /**
+   * Start an atom:link element
+   * @param iri The href value
+   * @param rel The rel value
+   * @param attributes Extension attributes
+   */
+  void startLink(String iri, String rel,Map<QName,String> attributes);
+
+  /**
+   * Start an atom:link element
+   * @param iri The href value
+   * @param rel The rel value
+   * @param type The type value
+   * @param attributes Extension attributes
+   */
+  void startLink(String iri, String rel, String type,Map<QName,String> attributes);
+
+  /**
+   * 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
+   * @param attributes Extension attributes
+   */
+  void startLink(String iri, String rel, String type, String title, String hreflang, int length,Map<QName,String> attributes);
+  
+  /**
+   * End the atom:link
+   */
+  void endLink();
+
+  /**
+   * Write an atom:link element
+   * @param iri The href value
+   */
+  void writeLink(String iri);
+
+  /**
+   * Write an atom:link element
+   * @param iri The href value
+   * @param rel The rel value
+   */
+  void 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
+   */
+  void 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
+   */
+  void writeLink(String iri, String rel, String type, String title, String hreflang, int length);
+  
+  /**
+   * Start an atom:link element
+   * @param iri The href value
+   */
+  void startLink(String iri);
+
+  /**
+   * Start an atom:link element
+   * @param iri The href value
+   * @param rel The rel value
+   */
+  void 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
+   */
+  void 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
+   */
+  void startLink(String iri, String rel, String type, String title, String hreflang, int length);
+  
+  /**
+   * Write an atom:category element
+   * @param term The term value
+   * @param attributes Extension attributes
+   */
+  void writeCategory(String term,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:category element
+   * @param term The term value
+   * @param scheme The term value
+   * @param attributes Extension attributes
+   */
+  void writeCategory(String term, String scheme,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:category element
+   * @param term The term value
+   * @param scheme The term value
+   * @param label The term value
+   * @param attributes Extension attributes
+   */
+  void writeCategory(String term, String scheme, String label,Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:category element
+   * @param term The term value
+   * @param attributes Extension attributes
+   */
+  void startCategory(String term,Map<QName,String> attributes);
+
+  /**
+   * Start an atom:category element
+   * @param term The term value
+   * @param scheme The term value
+   * @param attributes Extension attributes
+   */
+  void startCategory(String term, String scheme,Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:category element
+   * @param term The term value
+   * @param scheme The term value
+   * @param label The term value
+   * @param attributes Extension attributes
+   */
+  void startCategory(String term, String scheme, String label,Map<QName,String> attributes);
+  
+  /**
+   * End the atom:category
+   */
+  void endCategory();
+
+  /**
+   * Write an atom:category element
+   * @param term The term value
+   */
+  void writeCategory(String term);
+  
+  /**
+   * Write an atom:category element
+   * @param term The term value
+   * @param scheme The term value
+   */
+  void 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
+   */
+  void writeCategory(String term, String scheme, String label);
+  
+  /**
+   * Start an atom:category element
+   * @param term The term value
+   */
+  void startCategory(String term);
+  
+  /**
+   * Start an atom:category element
+   * @param term The term value
+   * @param scheme The term value
+   */
+  void 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
+   */
+  void startCategory(String term, String scheme, String label);
+  
+  
+  /**
+   * Start an atom:source element
+   * @param attributes Extension attributes
+   */
+  void startSource(Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:source element
+   */
+  void startSource();
+  
+  /**
+   * End the atom:source
+   */
+  void endSource();
+  
+  /**
+   * Write a Text element
+   * @param qname The element qname
+   * @param type The text type
+   * @param value The text value
+   * @param attribute Extension attributes
+   */
+  void writeText(QName qname, Text.Type type, String value,Map<QName,String> attributes);
+  
+  /**
+   * Start a Text element
+   * @param qname The element qname
+   * @param type The text type
+   * @param attribute Extension attributes
+   */
+  void startText(QName qname, Text.Type type,Map<QName,String> attributes);
+
+  /**
+   * Write a Text element
+   * @param qname The element qname
+   * @param type The text type
+   * @param value The text value
+   */
+  void writeText(QName qname, Text.Type type, String value);
+  
+  /**
+   * Start a Text element
+   * @param qname The element qname
+   * @param type The text type
+   */
+  void startText(QName qname, Text.Type type);
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   * @param attribute Extension attributes
+   */
+  void writeContent(Content.Type type, String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   * @param attribute Extension attributes
+   */
+  void writeContent(Content.Type type, InputStream value,Map<QName,String> attributes) throws IOException;
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   * @param attribute Extension attributes
+   */
+  void writeContent(Content.Type type, DataHandler value,Map<QName,String> attributes) throws IOException;
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   * @param attribute Extension attributes
+   */
+  void writeContent(String type, String value,Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   * @param value The text value
+   * @param attribute Extension attributes
+   */
+  void startContent(Content.Type type,Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   * @param attribute Extension attributes
+   */
+  void startContent(String type,Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   * @param src The src value
+   * @param attribute Extension attributes
+   */
+  void startContent(Content.Type type, String src,Map<QName,String> attributes);
+
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   * @param src The text value
+   * @param attribute Extension attributes
+   */
+  void startContent(String type, String src,Map<QName,String> attributes);
+    
+  /**
+   * End the atom:content element
+   */
+  void endContent();
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   */  
+  void writeContent(Content.Type type, String value);
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   */  
+  void writeContent(Content.Type type, InputStream value) throws IOException;
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   */  
+  void writeContent(Content.Type type, DataHandler value) throws IOException;
+  
+  /**
+   * Write an atom:content element
+   * @param type The text type
+   * @param value The text value
+   */  
+  void writeContent(String type, String value);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   */  
+  void startContent(Content.Type type);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   */  
+  void startContent(String type);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   * @param src The src value
+   */  
+  void startContent(Content.Type type, String src);
+  
+  /**
+   * Start an atom:content element
+   * @param type The text type
+   * @param src The src value
+   */  
+  void startContent(String type, String src);
+  
+  /**
+   * Start an element
+   * @param qname Element qname
+   * @param attributes Extension attributes
+   */  
+  void startElement(QName qname,Map<QName,String> attributes);
+  
+  /**
+   * Start an element
+   * @param qname Element qname
+   */  
+  void startElement(QName qname);
+  
+  /**
+   * Write element text
+   * @param value The text value
+   */  
+  void writeElementText(String value);
+  
+  /**
+   * Write element text
+   * @param datahandler The text value
+   */  
+  void writeElementText(DataHandler datahandler) throws IOException;
+  
+  /**
+   * Write element text
+   * @param in The text value
+   */  
+  void writeElementText(InputStream in) throws IOException;
+  
+  /**
+   * End the element
+   */
+  void endElement();
+  
+  /**
+   * Write an atom:title element
+   * @param value The text value
+   */
+  void writeTitle(String value);
+  
+  /**
+   * Write an atom:title element
+   * @param type The text type
+   * @param value The text value
+   */
+  void writeTitle(Text.Type type, String value);
+
+  /**
+   * Write an atom:subtitle element
+   * @param value The text value
+   */
+  void writeSubtitle(String value);
+  
+  /**
+   * Write an atom:subtitle element
+   * @param type The text type
+   * @param value The text value
+   */
+  void writeSubtitle(Text.Type type, String value);
+  
+  /**
+   * Write an atom:summary element
+   * @param value The text value
+   */
+  void writeSummary(String value);
+  
+  /**
+   * Write an atom:summary element
+   * @param type The text type
+   * @param value The text value
+   */
+  void writeSummary(Text.Type type, String value);
+  
+  /**
+   * Write an atom:rights element
+   * @param value The text value
+   */
+  void writeRights(String value);
+  
+  /**
+   * Write an atom:rights element
+   * @param type The text type
+   * @param value The text value
+   */
+  void writeRights(Text.Type type, String value);
+  
+  /**
+   * Write an atom:title element
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeTitle(String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:title element
+   * @param type The text type
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeTitle(Text.Type type, String value,Map<QName,String> attributes);
+
+  /**
+   * Write an atom:subtitle element
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeSubtitle(String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:subtitle element
+   * @param type The text type
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeSubtitle(Text.Type type, String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:summary element
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeSummary(String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:summary element
+   * @param type The text type
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeSummary(Text.Type type, String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:rights element
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeRights(String value,Map<QName,String> attributes);
+  
+  /**
+   * Write an atom:rights element
+   * @param type The text type
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeRights(Text.Type type, String value,Map<QName,String> attributes);
+  
+  
+  /**
+   * Write a person element
+   * @param qname the element qname
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   */
+  void writePerson(QName qname, String name, String email, String uri);
+
+  /**
+   * Start a person element
+   * @param qname The element qname
+   */  
+  void startPerson(QName qname);
+  
+  /**
+   * Write a person name
+   * @param name The person name
+   */
+  void writePersonName(String name);
+
+  /**
+   * Write a person email
+   * @param email The person email
+   */
+  void writePersonEmail(String email);
+
+  /**
+   * Write a person uri
+   * @param uri The person uri
+   */
+  void writePersonUri(String uri);
+  
+  /**
+   * Write an atom:author element
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   */
+  void writeAuthor(String name, String email, String uri);
+  
+  /**
+   * Write an atom:author element
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   * @param attribute ExtensionAttributes
+   */
+  void writeAuthor(String name, String email, String uri, Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:author element
+   */
+  void startAuthor();
+  
+  /**
+   * Start an atom:author element
+   * @params attributes ExtensionAttributes
+   */
+  void startAuthor(Map<QName,String> attributes);
+  
+  /**
+   * End the atom:author element
+   */
+  void endAuthor();
+  
+  /**
+   * Write an atom:contributor element
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   */
+  void writeContributor(String name, String email, String uri);
+  
+  /**
+   * Write an atom:contributor element
+   * @param name The person name
+   * @param email The person email
+   * @param uri The person uri
+   * @param attributes Extension attributes
+   */
+  void writeContributor(String name, String email, String uri, Map<QName,String> attributes);
+  
+  /**
+   * Start an atom:contributor element
+   */
+  void startContributor();
+  
+  /**
+   * Start an atom:contributor element
+   * @param attributes Extension attributes
+   */
+  void startContributor(Map<QName,String> attributes);
+  
+  /**
+   * End an atom:contributor element
+   */
+  void endContributor();
+  
+  /**
+   * Write an atom:generator element
+   * @param version The version value
+   * @param uri The uri value
+   * @param value The text value
+   */
+  void writeGenerator(String version, String uri, String value);
+
+  /**
+   * Write an atom:generator element
+   * @param version The version value
+   * @param uri The uri value
+   * @param value The text value
+   * @param attributes Extension attributes
+   */
+  void writeGenerator(String version, String uri, String value, Map<QName,String> attributes);
+
+  /**
+   * Start an atom:generator element
+   * @param version The version value
+   * @param uri The uri value
+   */
+  void startGenerator(String version, String uri);
+  
+  /**
+   * Start an atom:generator element
+   * @param version The version value
+   * @param uri The uri value
+   * @param attributes Extension attributes
+   */
+  void startGenerator(String version, String uri, Map<QName,String> attributes);
+  
+  /**
+   * End the atom:generator element
+   */
+  void endGenerator();
+  
+  /**
+   * Write an XML comment
+   */
+  void writeComment(String value);
+  
+  /**
+   * Write an XML Processing Instruction
+   */
+  void writePI(String value);
+
+  /**
+   * Write an XML Processing Instruction
+   */
+  void writePI(String value, String target);
+  
+  
+  /**
+   * Start an app:service element
+   */
+  void startService();
+  
+  /**
+   * Start an app:service element
+   * @param attributes Extension attributes
+   */
+  void startService(Map<QName,String> attributes);
+  
+  /**
+   * End an app:service element
+   */
+  void endService();
+  
+  /**
+   * Start an app:workspace element
+   */
+  void startWorkspace();
+  
+  /**
+   * Start an app:workspace element
+   * @param attributes Extension attributes
+   */
+  void startWorkspace(Map<QName,String> attributes);
+  
+  /**
+   * End an app:workspace element
+   */
+  void endWorkspace();
+  
+  /**
+   * Start an app:collection element
+   * @param href The href value
+   */
+  void startCollection(String href);
+  
+  /**
+   * Start an app:collection element
+   * @param href The href value
+   * @param attributes Extension attributes
+   */
+  void startCollection(String href, Map<QName,String> attributes);
+  
+  /**
+   * End an app:collection element
+   */
+  void endCollection();
+  
+  /**
+   * Writes app:accept elements
+   * @param accepts accept element values
+   */
+  void writeAccepts(String... accepts);
+  
+  /**
+   * Start an app:categories element
+   */
+  void startCategories();
+  
+  /**
+   * Start an app:categories element
+   * @param fixed True if the app:categories element is fixed
+   */
+  void startCategories(boolean fixed);
+  
+  /**
+   * Start an app:categories element
+   * @param fixed True if the app:categories element is fixed
+   * @param scheme The scheme value
+   */
+  void startCategories(boolean fixed, String scheme);
+  
+  /**
+  * Start an app:categories element
+  * @param attributes Extension attributes
+  */
+  void startCategories(Map<QName,String> attributes);
+  
+  /**
+  * Start an app:categories element
+  * @param fixed True if the app:categories element is fixed
+  * @param attributes Extension attributes
+  */
+  void startCategories(boolean fixed, Map<QName,String> attributes);
+  
+  /**
+   * Start an app:categories element
+   * @param fixed True if the app:categories element is fixed
+   * @param scheme The scheme value
+   * @param attributes Extension attributes
+   */
+  void startCategories(boolean fixed, String scheme, Map<QName,String> attributes);
+  
+  /**
+   * End the app:categories element
+   */
+  void endCategories();
+
+  /**
+   * Start the app:control element
+   */
+  void startControl();
+  
+  /**
+   * Start the app:control element
+   * @param attributes Extension attributes
+   */
+  void startControl(Map<QName,String> attributes);
+  
+  /**
+   * End the app:control element
+   */
+  void endControl();
+  
+  /**
+   * Write an app:draft element
+   * @param draft true if app:draft=yes
+   */
+  void writeDraft(boolean draft);
+  
+}
+

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/WriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/WriterFactory.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/WriterFactory.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/WriterFactory.java Fri Nov  2 17:32:39 2007
@@ -44,4 +44,19 @@
    * @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);
 }

Added: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/StreamWriterExample.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/StreamWriterExample.java?rev=591523&view=auto
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/StreamWriterExample.java (added)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/simple/StreamWriterExample.java Fri Nov  2 17:32:39 2007
@@ -0,0 +1,86 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.examples.simple;
+
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.writer.StreamWriter;
+
+/**
+ * Demonstrates the use of the Abdera StreamWriter interface
+ */
+public class StreamWriterExample {
+
+  public static void main(String... args) {
+    
+    Abdera abdera = Abdera.getInstance();
+    
+    StreamWriter out = abdera.newStreamWriter();
+    
+    out.setOutputStream(System.out,"UTF-8");
+    
+    out.startDocument();
+    out.startFeed();
+    
+    out.writeId("http://example.org");
+    out.writeTitle("<Testing 123>");
+    out.writeSubtitle("Foo");
+    out.writeAuthor("James", null, null);
+    out.writeUpdated(new Date());
+      
+    out.writeLink("http://example.org/foo");
+    out.writeLink("http://example.org/bar","self");
+      
+    out.writeCategory("foo");
+    out.writeCategory("bar");
+      
+    out.writeLogo("logo");
+    out.writeIcon("icon");
+    out.writeGenerator("1.0", "http://example.org", "foo");
+      
+    for (int n = 0; n < 100; n++) {
+      out.startEntry();
+      
+      out.writeId("http://example.org/" + n);
+      out.writeTitle("Entry #" + n);
+      out.writeUpdated(new Date());
+      out.writePublished(new Date());
+      out.writeEdited(new Date());
+      out.writeSummary("This is text summary");
+      out.writeAuthor("James", null, null);
+      out.writeContributor("Joe", null, null);
+      out.startContent("application/xml");
+        out.startElement(new QName("a","b","c"));
+          out.startElement(new QName("x","y","z"));
+            out.writeElementText("This is a test");
+          out.endElement();
+        out.endElement();
+      out.endContent();
+      out.endEntry();
+    }
+      
+    out.endFeed();
+    out.endDocument();
+
+    
+  }
+  
+}

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWriterFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWriterFactory.java?rev=591523&r1=591522&r2=591523&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWriterFactory.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWriterFactory.java Fri Nov  2 17:32:39 2007
@@ -21,7 +21,9 @@
 import java.util.Map;
 
 import org.apache.abdera.Abdera;
+import org.apache.abdera.util.Messages;
 import org.apache.abdera.writer.NamedWriter;
+import org.apache.abdera.writer.StreamWriter;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
 
@@ -31,6 +33,7 @@
 
   private final Abdera abdera;
   private final Map<String,NamedWriter> writers;
+  private final Map<String,Class<? extends StreamWriter>> streamwriters;
   
   public FOMWriterFactory() {
     this(new Abdera());
@@ -40,6 +43,9 @@
     this.abdera = abdera;
     Map<String,NamedWriter>  w = getAbdera().getConfiguration().getNamedWriters();
     writers = (w != null) ? w : new HashMap<String,NamedWriter>();
+    
+    Map<String,Class<? extends StreamWriter>> s = getAbdera().getConfiguration().getStreamWriters();
+    streamwriters = (s != null) ? s : new HashMap<String,Class<? extends StreamWriter>>();
   }
   
   protected Abdera getAbdera() {
@@ -65,6 +71,30 @@
   
   private Map<String,NamedWriter> getWriters() {
     return writers;
+  }
+
+  private Map<String,Class<? extends StreamWriter>> getStreamWriters() {
+    return streamwriters;
+  }
+  
+  public <T extends StreamWriter> T newStreamWriter() {
+    return (T)getAbdera().newStreamWriter();
+  }
+
+  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(
+          Messages.format(
+            "IMPLEMENTATION.NOT.AVAILABLE",
+            "StreamWriter"),e);
+      }
+    }
+    return (T)sw;
   }
   
 }

Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java?rev=591523&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java (added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java Fri Nov  2 17:32:39 2007
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.parser.stax;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.abdera.parser.stax.util.FOMHelper;
+import org.apache.abdera.util.AbstractStreamWriter;
+import org.apache.axiom.om.util.StAXUtils;
+
+public class StaxStreamWriter 
+  extends AbstractStreamWriter {
+  
+  private static final String NAME = "default";
+  
+  private XMLStreamWriter writer;
+  
+  public StaxStreamWriter() {
+    super(NAME);
+  }
+  
+  public StaxStreamWriter(
+    Writer writer) {
+    super(NAME);
+    setWriter(writer);
+  }
+
+  public StaxStreamWriter(
+    OutputStream out) {
+      super(NAME);
+      setOutputStream(out);
+  }
+  
+  public StaxStreamWriter(
+    OutputStream out, 
+    String charset) {
+    super(NAME);
+    setOutputStream(out,charset);
+  }
+
+  public void setWriter(java.io.Writer writer) {
+    try {
+      this.writer = StAXUtils.createXMLStreamWriter(writer);
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+  public void setOutputStream(java.io.OutputStream out) {
+    try {
+      this.writer = StAXUtils.createXMLStreamWriter(out,"UTF-8");
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+  public void setOutputStream(java.io.OutputStream out, String charset) {
+    try {
+      this.writer = StAXUtils.createXMLStreamWriter(out,charset);
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  public void startDocument(String xmlversion, String charset) {
+    try {
+      writer.writeStartDocument(xmlversion,charset);
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }    
+  }
+  
+  public void startDocument(String xmlversion) {
+    try {
+      writer.writeStartDocument(xmlversion);
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  public void endDocument() {
+    try {
+      writer.writeEndDocument();
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+ 
+  public void endElement() {
+    try {
+      pop();
+      writer.writeEndElement();
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  private void writeNamespace(QName qname, boolean attr) throws XMLStreamException {
+    String prefix = qname.getPrefix();
+    String namespace = qname.getNamespaceURI();
+    prefix = prefix != null ? prefix : "";
+    if (!declared(prefix,namespace)) {
+      if (attr && (namespace == null || "".equals(namespace))) return;
+      if (prefix != null)
+        writer.writeNamespace(prefix,namespace);
+      else
+        writer.writeDefaultNamespace(namespace);
+      declare(prefix,namespace);
+    }
+  }
+  
+  public void startElement(QName qname, Map<QName, String> attributes) {
+    try {
+      push();
+      writer.writeStartElement(qname.getPrefix(),qname.getLocalPart(),qname.getNamespaceURI());
+      writeNamespace(qname,false);
+      if (attributes != null) {
+        for (QName attr : attributes.keySet()) 
+          writeNamespace(attr,true);
+        for (QName attr : attributes.keySet()) {
+          writer.writeAttribute(
+            attr.getPrefix(), 
+            attr.getNamespaceURI(),
+            attr.getLocalPart(),
+            attributes.get(attr));
+        }
+      }
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  public void writeElementText(String value) {
+    try {
+      writer.writeCharacters(value);
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public void writeComment(String value) {
+    try {
+      writer.writeComment(value);
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public void writePI(String value) {
+    try {
+      writer.writeProcessingInstruction(value);
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public void writePI(String value, String target) {
+    try {
+      writer.writeProcessingInstruction(value,target);
+    } catch(XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  private final Stack<Map<String,String>> namespaces = new Stack<Map<String,String>>();
+  
+  private void push() {
+    namespaces.push(new HashMap<String,String>());
+  }
+  
+  private void pop() {
+    if (!namespaces.isEmpty()) namespaces.pop();
+  }
+  
+  private boolean declared(String prefix, String namespace) {
+    for (int n = namespaces.size() - 1; n >= 0; n--) {
+      Map<String,String> frame = namespaces.get(n);
+      String chk = frame.get(prefix);
+      if (chk == null && namespace == null) return true;
+      if (chk == null && namespace != null) continue;
+      if (chk != null && namespace == null) continue;
+      if (chk.equals(namespace)) return true;
+    }
+    return false;
+  }
+  
+  private void declare(String prefix, String namespace) {
+    if (namespaces.isEmpty()) return;
+    Map<String,String> frame = namespaces.peek();
+    frame.put(prefix, namespace);
+  }
+
+  public void writeId(Map<QName,String> attributes) {
+    writeId(FOMHelper.generateUuid(),attributes);
+  }
+    
+}



Mime
View raw message