abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r592532 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/util/ core/src/main/java/org/apache/abdera/writer/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Tue, 06 Nov 2007 19:45:54 GMT
Author: jmsnell
Date: Tue Nov  6 11:45:54 2007
New Revision: 592532

URL: http://svn.apache.org/viewvc?rev=592532&view=rev
Log:
Add chaining to the StreamWriter..  In preliminary testing on the StreamWriter interface, I was 
able to write out 1000 simple feeds with 500 entries each in around 14000ms.  That's a major 
improvement over using the FOM.  When all we need to do is write out a document, the streamwriter should
be preferred over building up an object model with the FOM.

e.g. 
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    StreamWriter sw = abdera.newStreamWriter();
    sw.setOutputStream(out)
      .startDocument()
      .startFeed()
        .writeId("http://example.org")
        .writeTitle("Testing")
        .writeSubtitle("Foo")
        .writeLink("http://example.org")
        .writeCategory("foo")
        .writeUpdated(new Date())
        .startEntry()
          .writeId("http://example.org/foo")
          .writeTitle(Text.Type.HTML,"Entry title")
          .writeUpdated(new Date())
          .writeLink("http://example.org/1")
          .writeAuthor("James",null,null)
        .endEntry()
      .endFeed()
      .endDocument();

Modified:
    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/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java

Modified: 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=592532&r1=592531&r2=592532&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractStreamWriter.java Tue Nov  6 11:45:54 2007
@@ -47,75 +47,92 @@
     return name;
   }
   
-  public void startDocument() {
+  public StreamWriter startDocument() {
     startDocument("1.0");
+    return this;
   }
  
-  public void endDocument() {}
+  public StreamWriter endDocument() {
+    return this;
+  }
   
-  public void startFeed() {
+  public StreamWriter startFeed() {
     startFeed(null);
+    return this;
   }
   
-  public void startFeed(Map<QName,String> attributes) {
+  public StreamWriter startFeed(Map<QName,String> attributes) {
     startElement(Constants.FEED, attributes);
+    return this;
   }
 
-  public void endFeed() {
+  public StreamWriter endFeed() {
     endElement();
+    return this;
   }
   
-  public void startEntry(Map<QName,String> attributes) {
+  public StreamWriter startEntry(Map<QName,String> attributes) {
     startElement(Constants.ENTRY, attributes);
+    return this;
   }
   
-  public void startEntry() {
+  public StreamWriter startEntry() {
     startEntry(null);
+    return this;
   }
   
-  public void endEntry() {
+  public StreamWriter endEntry() {
     endElement();
+    return this;
   }
   
-  public void endCategory() {
+  public StreamWriter endCategory() {
     endElement();
+    return this;
   }
   
-  public void endContent() {
+  public StreamWriter endContent() {
     endElement();
+    return this;
   }
   
-  public void endLink() {
+  public StreamWriter endLink() {
     endElement();
+    return this;
   }
   
-  public void endPerson() {
+  public StreamWriter endPerson() {
     endElement();
+    return this;
   }
   
-  public void endSource() {
+  public StreamWriter endSource() {
     endElement();
+    return this;
   }
   
-  public void endText() {
+  public StreamWriter endText() {
     endElement();
+    return this;
   }
   
   
-  public void startCategory(
+  public StreamWriter startCategory(
     String term, 
     Map<QName, String> attributes) {
       startCategory(term,null,null,attributes);
+      return this;
   }
   
-  public void startCategory(
+  public StreamWriter startCategory(
     String term, 
     String scheme,
     Map<QName, String> attributes) {
       startCategory(term,scheme,null,attributes);
+      return this;
   }
   
-  public void startCategory(
+  public StreamWriter startCategory(
     String term, 
     String scheme, 
     String label,
@@ -125,9 +142,10 @@
       if (scheme != null) attributes.put(new QName("scheme"),term);
       if (label != null) attributes.put(new QName("label"),term);
       startElement(Constants.CATEGORY,attributes);
+      return this;
   }
 
-  public void startLink(
+  public StreamWriter startLink(
     String iri, 
     String rel, 
     String type, 
@@ -143,79 +161,88 @@
       if (hreflang != null) attributes.put(new QName("hreflang"),hreflang);
       if (length > -1) attributes.put(new QName("length"),String.valueOf(length));
       startElement(Constants.LINK,attributes);
-    
+      return this;
   }
 
-  public void startPerson(
+  public StreamWriter startPerson(
     QName qname, 
     Map<QName, String> attributes) {
       startElement(qname, attributes);
+      return this;
   }
   
-  public void startSource(
+  public StreamWriter startSource(
     Map<QName, String> attributes) {
       startElement(Constants.SOURCE,attributes);
+      return this;
   }
   
-  public void startText(
+  public StreamWriter 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);
+    return this;
   }
   
-  public void writeDate(
+  public StreamWriter writeDate(
     QName qname, 
     String date, 
     Map<QName, String> attributes) {
       startElement(qname,attributes);
       writeElementText(date);
       endElement();
+      return this;
   }
   
-  public void writeIRIElement(
+  public StreamWriter writeIRIElement(
     QName qname, 
     String iri,
     Map<QName, String> attributes) {
       startElement(qname,attributes);
       writeElementText(iri);
       endElement();
+      return this;
   }
   
-  public void writePersonEmail(
+  public StreamWriter writePersonEmail(
     String email, 
     Map<QName, String> attributes) {
       startElement(Constants.EMAIL,attributes);
       writeElementText(email);
       endElement();
+      return this;
   }
   
-  public void writePersonName(
+  public StreamWriter writePersonName(
     String name, 
     Map<QName, String> attributes) {
       startElement(Constants.NAME,attributes);
       writeElementText(name);
-      endElement();    
+      endElement();
+      return this;
   }
   
-  public void writePersonUri(
+  public StreamWriter writePersonUri(
     String uri, 
     Map<QName, String> attributes) {
       startElement(Constants.URI,attributes);
       writeElementText(uri);
       endElement();
+      return this;
   }
 
-  public void startContent(
+  public StreamWriter startContent(
     Content.Type type, 
     String src, 
     Map<QName, String> attributes) {
       startContent(type.name().toLowerCase(),src,attributes);
+      return this;
   }
   
-  public void startContent(
+  public StreamWriter startContent(
     String type, 
     String src,
     Map<QName, String> attributes) {
@@ -223,151 +250,171 @@
       attributes.put(new QName("type"),type);
       if (src != null) attributes.put(new QName("src"),src);
       startElement(Constants.CONTENT,attributes);
+      return this;
   }
   
-  public void startContent(
+  public StreamWriter startContent(
     Content.Type type, 
     Map<QName, String> attributes) {
       startContent(type,null,attributes);
+      return this;
   }
   
-  public void startContent(
+  public StreamWriter startContent(
     String type, 
     Map<QName, String> attributes) {
       startContent(type,null,attributes);
+      return this;
   }
   
-  public void startLink(
+  public StreamWriter startLink(
     String iri, 
     Map<QName, String> attributes) {
       startLink(iri,null,null,null,null,-1,attributes);
+      return this;
   }
   
-  public void startLink(
+  public StreamWriter startLink(
     String iri, 
     String rel, 
     Map<QName, String> attributes) {
       startLink(iri,rel,null,null,null,-1,attributes);
+      return this;
   }
   
-  public void startLink(
+  public StreamWriter startLink(
     String iri, 
     String rel, 
     String type,
     Map<QName, String> attributes) {
       startLink(iri,rel,type,null,null,-1,attributes);
+      return this;
   }
   
-  public void writeCategory(
+  public StreamWriter writeCategory(
     String term, Map<QName, 
     String> attributes) {
       startCategory(term, attributes);
       endCategory();
+      return this;
   }
   
-  public void writeCategory(
+  public StreamWriter writeCategory(
     String term, 
     String scheme,
     Map<QName, String> attributes) {
       startCategory(term,scheme,attributes);
       endCategory();
+      return this;
   }
   
-  public void writeCategory(
+  public StreamWriter writeCategory(
     String term, 
     String scheme, 
     String label,
     Map<QName, String> attributes) {
       startCategory(term,scheme,label,attributes);
       endCategory();
+      return this;
   }
   
-  public void writeContent(
+  public StreamWriter writeContent(
     Content.Type type, 
     String value,
     Map<QName, String> attributes) {
       startContent(type,attributes);
       writeElementText(value);
       endContent();
+      return this;
   }
   
-  public void writeContent(
+  public StreamWriter writeContent(
     Content.Type type, 
     InputStream value,
     Map<QName, String> attributes) throws IOException {
       startContent(type,attributes);
       writeElementText(value);
-      endContent();    
+      endContent();
+      return this;
   }
   
-  public void writeContent(
+  public StreamWriter writeContent(
     Content.Type type, 
     DataHandler value,
     Map<QName, String> attributes) throws IOException {
       startContent(type,attributes);
       writeElementText(value);
       endContent();
+      return this;
   }
   
-  public void writeContent(
+  public StreamWriter writeContent(
     String type, 
     String value,
     Map<QName, String> attributes) {
       startContent(type,attributes);
       writeElementText(value);
       endContent();
+      return this;
   }
   
-  public void writeEdited(
+  public StreamWriter writeEdited(
     Date date, 
     Map<QName, String> attributes) {
       writeDate(Constants.EDITED, date, attributes);
+      return this;
   }
   
-  public void writeId(
+  public StreamWriter writeId(
     String iri, 
     Map<QName, String> attributes) {
       writeIRIElement(Constants.ID, iri, attributes);
+      return this;
   }
   
-  public void writeIcon(
+  public StreamWriter writeIcon(
     String iri, 
     Map<QName,String> attributes) {
       writeIRIElement(Constants.ICON, iri, attributes);
+      return this;
   }
   
-  public void writeLogo(
+  public StreamWriter writeLogo(
     String iri, 
     Map<QName,String> attributes) {
       writeIRIElement(Constants.LOGO, iri, attributes);
+      return this;
   }
   
   
-  public void writeLink(
+  public StreamWriter writeLink(
     String iri, 
     Map<QName, String> attributes) {
       startLink(iri, attributes);
       endLink();
+      return this;
   }
   
-  public void writeLink(
+  public StreamWriter writeLink(
     String iri, 
     String rel, 
     Map<QName, String> attributes) {
       startLink(iri, rel, attributes);
       endLink();
+      return this;
   }
   
-  public void writeLink(
+  public StreamWriter writeLink(
     String iri, 
     String rel, 
     String type,
     Map<QName, String> attributes) {
     startLink(iri, rel, type, attributes);
     endLink();
+    return this;
   }
   
-  public void writeLink(
+  public StreamWriter writeLink(
     String iri, 
     String rel, 
     String type, 
@@ -377,9 +424,10 @@
     Map<QName, String> attributes) {
       startLink(iri, rel, type, title, hreflang, length, attributes);
       endLink();
+      return this;
   }
   
-  public void writePerson(
+  public StreamWriter writePerson(
     QName qname, 
     String name, 
     String email, 
@@ -390,15 +438,17 @@
       if (email != null) writePersonEmail(email,null);
       if (uri != null) writePersonUri(uri,null);
       endPerson();
+      return this;
   }
   
-  public void writePublished(
+  public StreamWriter writePublished(
     Date date, 
     Map<QName, String> attributes) {
       writeDate(Constants.PUBLISHED,date,attributes);
+      return this;
   }
   
-  public void writeText(
+  public StreamWriter writeText(
     QName qname, 
     Text.Type type,
     String value, 
@@ -406,490 +456,599 @@
       startText(qname,type,attributes);
       writeElementText(value);
       endText();
+      return this;
   }
   
-  public void writeUpdated(
+  public StreamWriter writeUpdated(
     Date date, 
     Map<QName, String> attributes) {
       writeDate(Constants.UPDATED,date,attributes);
+      return this;
   }
   
-  public void writeUpdated(String date, Map<QName,String> attributes) {
+  public StreamWriter writeUpdated(String date, Map<QName,String> attributes) {
     writeDate(Constants.UPDATED, date, attributes);
+    return this;
   }
   
-  public void writePublished(String date, Map<QName,String> attributes) {
+  public StreamWriter writePublished(String date, Map<QName,String> attributes) {
     writeDate(Constants.PUBLISHED, date, attributes);
+    return this;
   }
   
-  public void writeEdited(String date, Map<QName,String> attributes) {
+  public StreamWriter writeEdited(String date, Map<QName,String> attributes) {
     writeDate(Constants.EDITED, date, attributes);
+    return this;
   }
   
-  public void writeDate(QName qname, Date date, Map<QName,String> attributes) {
+  public StreamWriter writeDate(QName qname, Date date, Map<QName,String> attributes) {
     writeDate(qname, AtomDate.format(date), attributes);
+    return this;
   }
   
-  public void writeId(IRI iri, Map<QName,String> attributes) {
+  public StreamWriter writeId(IRI iri, Map<QName,String> attributes) {
     writeIRIElement(Constants.ID, iri, attributes);
+    return this;
   }
   
-  public void writeIcon(IRI iri, Map<QName,String> attributes) {
+  public StreamWriter writeIcon(IRI iri, Map<QName,String> attributes) {
     writeIRIElement(Constants.ICON, iri, attributes);
+    return this;
   }
   
-  public void writeLogo(IRI iri, Map<QName,String> attributes) {
+  public StreamWriter writeLogo(IRI iri, Map<QName,String> attributes) {
     writeIRIElement(Constants.LOGO, iri, attributes);
+    return this;
   }
   
-  public void writeIRIElement(QName qname, IRI iri, Map<QName,String> attributes) {
+  public StreamWriter writeIRIElement(QName qname, IRI iri, Map<QName,String> attributes) {
     writeIRIElement(qname, iri.toString(), attributes);
+    return this;
   }
   
-  public void writeElementText(InputStream value) throws IOException {
+  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 void writeElementText(DataHandler value) throws IOException {
+  public StreamWriter writeElementText(DataHandler value) throws IOException {
     writeElementText(value.getInputStream());
+    return this;
   }
   
-  public void writeTitle(String value) {
+  public StreamWriter writeTitle(String value) {
     writeText(Constants.TITLE, Text.Type.TEXT, value, null);
+    return this;
   }
   
-  public void writeTitle(Text.Type type, String value) {
+  public StreamWriter writeTitle(Text.Type type, String value) {
     writeText(Constants.TITLE, type, value, null);
+    return this;
   }
 
-  public void writeSubtitle(String value) {
+  public StreamWriter writeSubtitle(String value) {
     writeText(Constants.SUBTITLE, Text.Type.TEXT, value, null);
+    return this;
   }
   
-  public void writeSubtitle(Text.Type type, String value) {
+  public StreamWriter writeSubtitle(Text.Type type, String value) {
     writeText(Constants.SUBTITLE, type, value, null);
+    return this;
   }
   
-  public void writeSummary(String value) {
+  public StreamWriter writeSummary(String value) {
     writeText(Constants.SUMMARY, Text.Type.TEXT, value, null);
+    return this;
   }
   
-  public void writeSummary(Text.Type type, String value) {
+  public StreamWriter writeSummary(Text.Type type, String value) {
     writeText(Constants.SUMMARY, type, value, null);
+    return this;
   }
   
-  public void writeRights(String value) {
+  public StreamWriter writeRights(String value) {
     writeText(Constants.RIGHTS, Text.Type.TEXT, value, null);
+    return this;
   }
   
-  public void writeRights(Text.Type type, String value) {
+  public StreamWriter writeRights(Text.Type type, String value) {
     writeText(Constants.RIGHTS, type, value, null);
+    return this;
   }
 
 
   
-  public void writeTitle(String value, Map<QName,String> attributes) {
+  public StreamWriter writeTitle(String value, Map<QName,String> attributes) {
     writeText(Constants.TITLE, Text.Type.TEXT, value, attributes);
+    return this;
   }
   
-  public void writeTitle(Text.Type type, String value, Map<QName,String> attributes) {
+  public StreamWriter writeTitle(Text.Type type, String value, Map<QName,String> attributes) {
     writeText(Constants.TITLE, type, value, attributes);
+    return this;
   }
 
-  public void writeSubtitle(String value, Map<QName,String> attributes) {
+  public StreamWriter writeSubtitle(String value, Map<QName,String> attributes) {
     writeText(Constants.SUBTITLE, Text.Type.TEXT, value, attributes);
+    return this;
   }
   
-  public void writeSubtitle(Text.Type type, String value, Map<QName,String> attributes) {
+  public StreamWriter writeSubtitle(Text.Type type, String value, Map<QName,String> attributes) {
     writeText(Constants.SUBTITLE, type, value, attributes);
+    return this;
   }
   
-  public void writeSummary(String value, Map<QName,String> attributes) {
+  public StreamWriter writeSummary(String value, Map<QName,String> attributes) {
     writeText(Constants.SUMMARY, Text.Type.TEXT, value, attributes);
+    return this;
   }
   
-  public void writeSummary(Text.Type type, String value, Map<QName,String> attributes) {
+  public StreamWriter writeSummary(Text.Type type, String value, Map<QName,String> attributes) {
     writeText(Constants.SUMMARY, type, value, attributes);
+    return this;
   }
   
-  public void writeRights(String value, Map<QName,String> attributes) {
+  public StreamWriter writeRights(String value, Map<QName,String> attributes) {
     writeText(Constants.RIGHTS, Text.Type.TEXT, value, attributes);
+    return this;
   }
   
-  public void writeRights(Text.Type type, String value, Map<QName,String> attributes) {
+  public StreamWriter writeRights(Text.Type type, String value, Map<QName,String> attributes) {
     writeText(Constants.RIGHTS, type, value, attributes);
+    return this;
   }
   
-  
-  
-  public void writeId(String iri) {
-    writeIRIElement(Constants.ID, iri, null); 
+  public StreamWriter writeId(String iri) {
+    writeIRIElement(Constants.ID, iri, null);
+    return this;
   }
   
-  public void writeIcon(String iri) {
+  public StreamWriter writeIcon(String iri) {
     writeIRIElement(Constants.ICON, iri, null);
+    return this;
   }
   
-  public void writeLogo(String iri) {
+  public StreamWriter writeLogo(String iri) {
     writeIRIElement(Constants.LOGO, iri, null);
+    return this;
   }
   
-  public void writeIRIElement(QName qname, String iri) {
+  public StreamWriter writeIRIElement(QName qname, String iri) {
     writeIRIElement(qname, iri, null);
+    return this;
   }
 
-  public void writeId(IRI iri) {
+  public StreamWriter writeId(IRI iri) {
     writeIRIElement(Constants.ID, iri, null);
+    return this;
   }
   
-  public void writeIcon(IRI iri) {
+  public StreamWriter writeIcon(IRI iri) {
     writeIRIElement(Constants.ICON, iri, null);
+    return this;
   }
   
-  public void writeLogo(IRI iri) {
+  public StreamWriter writeLogo(IRI iri) {
     writeIRIElement(Constants.LOGO, iri, null);
+    return this;
   }
   
-  public void writeIRIElement(QName qname, IRI iri) {
+  public StreamWriter writeIRIElement(QName qname, IRI iri) {
     writeIRIElement(qname, iri, null);
+    return this;
   }
   
-  public void writeId() {
+  public StreamWriter writeId() {
     writeId((Map<QName,String>)null);
+    return this;
   }
    
-  public void writePerson(QName qname, String name, String email, String uri) {
+  public StreamWriter writePerson(QName qname, String name, String email, String uri) {
     writePerson(qname,name,email,uri,null);
+    return this;
   }
   
-  public void startPerson(QName qname) {
+  public StreamWriter startPerson(QName qname) {
     startPerson(qname,null);
+    return this;
   }
   
-  public void writePersonName(String name) {
+  public StreamWriter writePersonName(String name) {
     writePersonName(name,null);
+    return this;
   }
   
-  public void writePersonEmail(String email) {
+  public StreamWriter writePersonEmail(String email) {
     writePersonEmail(email,null);
+    return this;
   }
   
-  public void writePersonUri(String uri) {
+  public StreamWriter writePersonUri(String uri) {
     writePersonUri(uri,null);
+    return this;
   }
  
-
-  public void writeAuthor(String name, String email, String uri) {
+  public StreamWriter writeAuthor(String name, String email, String uri) {
     writePerson(Constants.AUTHOR,name,email,uri,null);
+    return this;
   }
 
-  public void writeAuthor(String name, String email, String uri, Map<QName,String> attributes) {
+  public StreamWriter writeAuthor(String name, String email, String uri, Map<QName,String> attributes) {
     writePerson(Constants.AUTHOR,name,email,uri,attributes);
+    return this;
   }
   
-  public void startAuthor() {
+  public StreamWriter startAuthor() {
     startElement(Constants.AUTHOR,null);
+    return this;
   }
 
-  public void startAuthor(Map<QName,String> attributes) {
+  public StreamWriter startAuthor(Map<QName,String> attributes) {
     startElement(Constants.AUTHOR,attributes);
+    return this;
   }
   
-  public void endAuthor() {
+  public StreamWriter endAuthor() {
     endElement();
+    return this;
   }
   
 
-  public void writeContributor(String name, String email, String uri) {
+  public StreamWriter writeContributor(String name, String email, String uri) {
     writePerson(Constants.CONTRIBUTOR,name,email,uri,null);
+    return this;
   }
 
-  public void writeContributor(String name, String email, String uri, Map<QName,String> attributes) {
+  public StreamWriter writeContributor(String name, String email, String uri, Map<QName,String> attributes) {
     writePerson(Constants.CONTRIBUTOR,name,email,uri,attributes);
+    return this;
   }
   
-  public void startContributor() {
+  public StreamWriter startContributor() {
     startElement(Constants.CONTRIBUTOR,null);
+    return this;
   }
 
-  public void startContributor(Map<QName,String> attributes) {
+  public StreamWriter startContributor(Map<QName,String> attributes) {
     startElement(Constants.CONTRIBUTOR,attributes);
+    return this;
   }
   
-  public void endContributor() {
+  public StreamWriter endContributor() {
     endElement();
+    return this;
   }
   
-  public void writeGenerator(String version, String uri, String value) {
+  public StreamWriter writeGenerator(String version, String uri, String value) {
     writeGenerator(version,uri,value,null);
+    return this;
   }
   
-  public void writeGenerator(String version, String uri, String value, Map<QName,String> attributes) {
+  public StreamWriter 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();
+    return this;
   }
 
-  public void startGenerator(String version, String uri) {
+  public StreamWriter startGenerator(String version, String uri) {
     startGenerator(version,uri,null);
+    return this;
   }
   
-  public void startGenerator(String version, String uri, Map<QName,String> attributes) {
+  public StreamWriter 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);    
+    startElement(Constants.GENERATOR,attributes);
+    return this;
   }
   
-  public void endGenerator() {
+  public StreamWriter endGenerator() {
     endElement();
+    return this;
   }
   
   
-  public void writeUpdated(Date date) {
+  public StreamWriter writeUpdated(Date date) {
     writeUpdated(date,null);
+    return this;
   }
   
-  public void writePublished(Date date) {
+  public StreamWriter writePublished(Date date) {
     writePublished(date,null);
+    return this;
   }
   
-  public void writeEdited(Date date) {
+  public StreamWriter writeEdited(Date date) {
     writeEdited(date,null);
+    return this;
   }
   
-  public void writeDate(QName qname, Date date) {
+  public StreamWriter writeDate(QName qname, Date date) {
     writeDate(qname,date,null);
+    return this;
   }
 
-  public void writeUpdated(String date) {
+  public StreamWriter writeUpdated(String date) {
     writeUpdated(date,null);
+    return this;
   }
   
-  public void writePublished(String date) {
+  public StreamWriter writePublished(String date) {
     writePublished(date,null);
+    return this;
   }
   
-  public void writeEdited(String date) {
+  public StreamWriter writeEdited(String date) {
     writeEdited(date,null);
+    return this;
   }
   
-  public void writeDate(QName qname, String date) {
+  public StreamWriter writeDate(QName qname, String date) {
     writeDate(qname, date,null);
+    return this;
   }
   
   
-  public void writeLink(String iri) {
+  public StreamWriter writeLink(String iri) {
     writeLink(iri,(Map<QName,String>)null);
+    return this;
   }
   
-  public void writeLink(String iri, String rel) {
+  public StreamWriter writeLink(String iri, String rel) {
     writeLink(iri,rel,(Map<QName,String>)null);
+    return this;
   }
   
-  public void writeLink(String iri, String rel, String type) {
+  public StreamWriter writeLink(String iri, String rel, String type) {
     writeLink(iri,rel,type,(Map<QName,String>)null);
+    return this;
   }
   
-  public void writeLink(String iri, String rel, String type, String title, String hreflang, int length) {
+  public StreamWriter writeLink(String iri, String rel, String type, String title, String hreflang, int length) {
     writeLink(iri,rel,type,title,hreflang,length,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startLink(String iri) {
+  public StreamWriter startLink(String iri) {
     startLink(iri,(Map<QName,String>)null);
+    return this;
   }
 
-  public void startLink(String iri, String rel) {
+  public StreamWriter startLink(String iri, String rel) {
     startLink(iri,rel,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startLink(String iri, String rel, String type) {
+  public StreamWriter startLink(String iri, String rel, String type) {
     startLink(iri,rel,type,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startLink(String iri, String rel, String type, String title, String hreflang, int length) {
+  public StreamWriter startLink(String iri, String rel, String type, String title, String hreflang, int length) {
     startLink(iri,rel,type,title,hreflang,length,(Map<QName,String>)null);
+    return this;
   }
   
   
-  public void writeCategory(String term) {
-   writeCategory(term,(Map<QName,String>)null); 
+  public StreamWriter writeCategory(String term) {
+   writeCategory(term,(Map<QName,String>)null);
+   return this;
   }
   
-  public void writeCategory(String term, String scheme) {
-   writeCategory(term,scheme,(Map<QName,String>)null); 
+  public StreamWriter writeCategory(String term, String scheme) {
+   writeCategory(term,scheme,(Map<QName,String>)null);
+   return this;
   }
   
-  public void writeCategory(String term, String scheme, String label) {
-   writeCategory(term,scheme,label,(Map<QName,String>)null); 
+  public StreamWriter writeCategory(String term, String scheme, String label) {
+   writeCategory(term,scheme,label,(Map<QName,String>)null);
+   return this;
   }
   
-  public void startCategory(String term) {
-   startCategory(term,(Map<QName,String>)null); 
+  public StreamWriter startCategory(String term) {
+   startCategory(term,(Map<QName,String>)null);
+   return this;
   }
   
-  public void startCategory(String term, String scheme) {
-   startCategory(term,scheme,(Map<QName,String>)null); 
+  public StreamWriter startCategory(String term, String scheme) {
+   startCategory(term,scheme,(Map<QName,String>)null);
+   return this;
   }
   
-  public void startCategory(String term, String scheme, String label) {
-   startCategory(term,scheme,label,(Map<QName,String>)null); 
+  public StreamWriter startCategory(String term, String scheme, String label) {
+   startCategory(term,scheme,label,(Map<QName,String>)null);
+   return this;
   }
   
-  public void startSource() {
+  public StreamWriter startSource() {
     startElement(Constants.SOURCE,null);
+    return this;
   }
   
-  public void writeText(QName qname, Text.Type type, String value) {
+  public StreamWriter writeText(QName qname, Text.Type type, String value) {
     writeText(qname,type,value,null);
+    return this;
   }
   
-  public void startText(QName qname, Text.Type type) {
+  public StreamWriter startText(QName qname, Text.Type type) {
     startText(qname,type,null);
+    return this;
   }
   
   
-  public void writeContent(Content.Type type, String value) {
+  public StreamWriter writeContent(Content.Type type, String value) {
     writeContent(type,value,null);
+    return this;
   }
   
-  public void writeContent(Content.Type type, InputStream value) throws IOException {
+  public StreamWriter writeContent(Content.Type type, InputStream value) throws IOException {
     writeContent(type,value,null);
+    return this;
   }
   
-  public void writeContent(Content.Type type, DataHandler value) throws IOException {
+  public StreamWriter writeContent(Content.Type type, DataHandler value) throws IOException {
     writeContent(type,value,null);
+    return this;
   }
   
-  public void writeContent(String type, String value) {
+  public StreamWriter writeContent(String type, String value) {
     writeContent(type,value,null);
+    return this;
   }
   
   
-  public void startContent(Content.Type type) {
+  public StreamWriter startContent(Content.Type type) {
     startContent(type,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startContent(String type) {
+  public StreamWriter startContent(String type) {
     startContent(type,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startContent(Content.Type type, String src) {
+  public StreamWriter startContent(Content.Type type, String src) {
     startContent(type,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startContent(String type, String src) {
+  public StreamWriter startContent(String type, String src) {
     startContent(type,(Map<QName,String>)null);
+    return this;
   }
   
-  public void startElement(QName qname) {
+  public StreamWriter startElement(QName qname) {
     startElement(qname,null);
+    return this;
   }
   
   
   
-  public void startService() {
+  public StreamWriter startService() {
     startElement(Constants.SERVICE);
+    return this;
   }
   
-  public void startService(Map<QName,String> attributes) {
+  public StreamWriter startService(Map<QName,String> attributes) {
     startElement(Constants.SERVICE,attributes);
+    return this;
   }
   
-  public void endService() {
+  public StreamWriter endService() {
     endElement();
+    return this;
   }
   
-  public void startWorkspace() {
+  public StreamWriter startWorkspace() {
     startElement(Constants.WORKSPACE, null);
+    return this;
   }
   
-  public void startWorkspace(Map<QName,String> attributes) {
+  public StreamWriter startWorkspace(Map<QName,String> attributes) {
     startElement(Constants.WORKSPACE, attributes);
+    return this;
   }
   
-  public void endWorkspace() {
+  public StreamWriter endWorkspace() {
     endElement();
+    return this;
   }
   
-  public void startCollection(String href) {
+  public StreamWriter startCollection(String href) {
     startCollection(href, null);
+    return this;
   }
   
-  public void startCollection(String href, Map<QName,String> attributes) {
+  public StreamWriter 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);
+    return this;
   }
   
-  public void endCollection() {
+  public StreamWriter endCollection() {
     endElement();
+    return this;
   }
   
-  public void writeAccepts(String... accepts) {
+  public StreamWriter writeAccepts(String... accepts) {
     for (String accept : accepts) {
       startElement(Constants.ACCEPT,null);
       writeElementText(accept);
       endElement();
     }
+    return this;
   }
   
-  public void startCategories() {
+  public StreamWriter startCategories() {
     startCategories(false,null,null);
+    return this;
   }
   
-  public void startCategories(boolean fixed) {
+  public StreamWriter startCategories(boolean fixed) {
     startCategories(fixed,null,null);
+    return this;
   }
   
-  public void startCategories(boolean fixed, String scheme) {
+  public StreamWriter startCategories(boolean fixed, String scheme) {
     startCategories(fixed,scheme,null);
+    return this;
   }
   
-  public void startCategories(Map<QName,String> attributes) {
+  public StreamWriter startCategories(Map<QName,String> attributes) {
     startCategories(false,null,attributes);
+    return this;
   }
   
-  public void startCategories(boolean fixed, Map<QName,String> attributes) {
+  public StreamWriter startCategories(boolean fixed, Map<QName,String> attributes) {
     startCategories(fixed,null,attributes);
+    return this;
   }
   
-  public void startCategories(boolean fixed, String scheme, Map<QName,String> attributes) {
+  public StreamWriter 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);
+    return this;
   }
   
-  public void endCategories() {
+  public StreamWriter endCategories() {
     endElement();
+    return this;
   }
 
-  public void startControl() {
+  public StreamWriter startControl() {
     startElement(Constants.CONTROL,null);
+    return this;
   }
   
-  public void startControl(Map<QName,String> attributes) {
+  public StreamWriter startControl(Map<QName,String> attributes) {
     startElement(Constants.CONTROL, attributes);
+    return this;
   }
   
-  public void endControl() {
+  public StreamWriter endControl() {
     endElement();
+    return this;
   }
   
-  public void writeDraft(boolean draft) {
+  public StreamWriter writeDraft(boolean draft) {
     startElement(Constants.DRAFT);
     writeElementText(draft?"yes":"no");
     endElement();
+    return this;
   }
   
 }

Modified: 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=592532&r1=592531&r2=592532&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/writer/StreamWriter.java Tue Nov  6 11:45:54 2007
@@ -33,7 +33,9 @@
 /**
  * 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 
+ * alternative to building up an object model.
+ * 
+ * The StreamWriter is NOT synchronized and is NOT threadsafe
  */
 public interface StreamWriter 
   extends NamedItem {
@@ -41,238 +43,238 @@
   /**
    * Set the target java.io.Writer
    */
-  void setWriter(java.io.Writer writer);
+  StreamWriter setWriter(java.io.Writer writer);
   
   /**
    * Set the target java.io.OutputStream
    */
-  void setOutputStream(java.io.OutputStream out);
+  StreamWriter setOutputStream(java.io.OutputStream out);
   
   /**
    * Set the target java.io.OutputStream
    */
-  void setOutputStream(java.io.OutputStream out, String charset);
+  StreamWriter 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);
+  StreamWriter startDocument(String xmlversion, String charset);
 
   /**
    * Start the document
    * @param xmlversion The XML version
    */
-  void startDocument(String xmlversion);
+  StreamWriter startDocument(String xmlversion);
   
   /**
    * Start the document
    */
-  void startDocument();
+  StreamWriter startDocument();
  
   /**
    * End the document
    */
-  void endDocument();
+  StreamWriter endDocument();
   
   /**
    * Start an atom:feed element
    */
-  void startFeed();
+  StreamWriter startFeed();
 
   /**
    * Start an atom:feed element
    * @param attribute Extension attributes
    */
-  void startFeed(Map<QName,String> attributes);
+  StreamWriter startFeed(Map<QName,String> attributes);
   
   /**
    * End the atom:feed element
    */
-  void endFeed();
+  StreamWriter endFeed();
   
   /**
    * Start an atom:entry element
    */
-  void startEntry();
+  StreamWriter startEntry();
   
   /**
    * Start an atom:entry element
    * @param attribute Extension attributes
    */
-  void startEntry(Map<QName,String> attributes);
+  StreamWriter startEntry(Map<QName,String> attributes);
   
   /**
    * End the atom:entry element
    */
-  void endEntry();
+  StreamWriter endEntry();
   
   /**
    * Write an atom:id element
    * @param iri The value
    * @param attribute Extension attributes
    */
-  void writeId(String iri, Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter writeIRIElement(QName qname, IRI iri, Map<QName,String> attributes);
   
   /**
    * Write an atom:id element
    * @param iri The value
    */
-  void writeId(String iri);
+  StreamWriter writeId(String iri);
   
   /**
    * Write an atom:icon element
    * @param iri The value
    */
-  void writeIcon(String iri);
+  StreamWriter writeIcon(String iri);
   
   /**
    * Write an atom:logo element
    * @param iri The value
    */
-  void writeLogo(String iri);
+  StreamWriter writeLogo(String iri);
   
   /**
    * Write an IRI element
    * @param iri The value
    */
-  void writeIRIElement(QName qname, String iri);
+  StreamWriter writeIRIElement(QName qname, String iri);
 
   /**
    * Write an atom:id element
    * @param iri The value
    */
-  void writeId(IRI iri);
+  StreamWriter writeId(IRI iri);
   
   /**
    * Write an atom:icon element
    * @param iri The value
    */
-  void writeIcon(IRI iri);
+  StreamWriter writeIcon(IRI iri);
   
   /**
    * Write an atom:logo element
    * @param iri The value
    */
-  void writeLogo(IRI iri);
+  StreamWriter writeLogo(IRI iri);
   
   /**
    * Write an IRI element
    * @param iri The value
    */
-  void writeIRIElement(QName qname, IRI iri);
+  StreamWriter writeIRIElement(QName qname, IRI iri);
   
   /**
    * Write an atom:id element with a new IRI value
    * @param iri The value
    */
-  void writeId();
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter writeEdited(String date, Map<QName,String> attributes);
   
   /**
    * Write a Date element
@@ -280,57 +282,57 @@
    * @param date The date value
    * @param attributes Extension attributes
    */
-  void writeDate(QName qname, String date, Map<QName,String> attributes);
+  StreamWriter writeDate(QName qname, String date, Map<QName,String> attributes);
   
   /**
    * Write an atom:updated element
    * @param date The date value
    */
-  void writeUpdated(Date date);
+  StreamWriter writeUpdated(Date date);
   
   /**
    * Write an atom:published element
    * @param date The date value
    */
-  void writePublished(Date date);
+  StreamWriter writePublished(Date date);
   
   /**
    * Write an atom:edited element
    * @param date The date value
    */
-  void writeEdited(Date date);
+  StreamWriter writeEdited(Date date);
   
   /**
    * Write a Date element
    * @param qname The element qname
    * @param date The date value
    */
-  void writeDate(QName qname, Date date);
+  StreamWriter writeDate(QName qname, Date date);
 
   /**
    * Write an atom:updated element
    * @param date The date value
    */
-  void writeUpdated(String date);
+  StreamWriter writeUpdated(String date);
   
   /**
    * Write an atom:published element
    * @param date The date value
    */
-  void writePublished(String date);
+  StreamWriter writePublished(String date);
   
   /**
    * Write an atom:edited element
    * @param date The date value
    */
-  void writeEdited(String date);
+  StreamWriter writeEdited(String date);
   
   /**
    * Write a Date element
    * @param qname The element qname
    * @param date The date value
    */
-  void writeDate(QName qname, String date);
+  StreamWriter writeDate(QName qname, String date);
   
   /**
    * Write a person element
@@ -340,7 +342,7 @@
    * @param uri The person uri
    * @param attributes Extension attributes
    */  
-  void writePerson(QName qname, String name, String email, String uri, Map<QName,String> attributes);
+  StreamWriter writePerson(QName qname, String name, String email, String uri, Map<QName,String> attributes);
   
   /**
    * Start a person element
@@ -350,33 +352,33 @@
    * @param uri The person uri
    * @param attributes Extension attributes
    */  
-  void startPerson(QName qname, Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter writePersonUri(String uri,Map<QName,String> attributes);
   
   /**
    * End the person element
    */
-  void endPerson();
+  StreamWriter endPerson();
   
   
   /**
@@ -384,7 +386,7 @@
    * @param iri The href value
    * @param attributes Extension attributes
    */
-  void writeLink(String iri,Map<QName,String> attributes);
+  StreamWriter writeLink(String iri,Map<QName,String> attributes);
   
   /**
    * Write an atom:link element
@@ -392,7 +394,7 @@
    * @param rel The rel value
    * @param attributes Extension attributes
    */
-  void writeLink(String iri, String rel,Map<QName,String> attributes);
+  StreamWriter writeLink(String iri, String rel,Map<QName,String> attributes);
   
   /**
    * Write an atom:link element
@@ -401,7 +403,7 @@
    * @param type The type value
    * @param attributes Extension attributes
    */
-  void writeLink(String iri, String rel, String type,Map<QName,String> attributes);
+  StreamWriter writeLink(String iri, String rel, String type,Map<QName,String> attributes);
   
   /**
    * Write an atom:link element
@@ -413,14 +415,14 @@
    * @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);
+  StreamWriter 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);
+  StreamWriter startLink(String iri,Map<QName,String> attributes);
 
   /**
    * Start an atom:link element
@@ -428,7 +430,7 @@
    * @param rel The rel value
    * @param attributes Extension attributes
    */
-  void startLink(String iri, String rel,Map<QName,String> attributes);
+  StreamWriter startLink(String iri, String rel,Map<QName,String> attributes);
 
   /**
    * Start an atom:link element
@@ -437,7 +439,7 @@
    * @param type The type value
    * @param attributes Extension attributes
    */
-  void startLink(String iri, String rel, String type,Map<QName,String> attributes);
+  StreamWriter startLink(String iri, String rel, String type,Map<QName,String> attributes);
 
   /**
    * Start an atom:link element
@@ -449,25 +451,25 @@
    * @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);
+  StreamWriter startLink(String iri, String rel, String type, String title, String hreflang, int length,Map<QName,String> attributes);
   
   /**
    * End the atom:link
    */
-  void endLink();
+  StreamWriter endLink();
 
   /**
    * Write an atom:link element
    * @param iri The href value
    */
-  void writeLink(String iri);
+  StreamWriter writeLink(String iri);
 
   /**
    * Write an atom:link element
    * @param iri The href value
    * @param rel The rel value
    */
-  void writeLink(String iri, String rel);
+  StreamWriter writeLink(String iri, String rel);
   
   /**
    * Write an atom:link element
@@ -475,7 +477,7 @@
    * @param rel The rel value
    * @param type The type value
    */
-  void writeLink(String iri, String rel, String type);
+  StreamWriter writeLink(String iri, String rel, String type);
   
   /**
    * Write an atom:link element
@@ -486,20 +488,20 @@
    * @param hreflang The hreflang value
    * @param length The link length
    */
-  void writeLink(String iri, String rel, String type, String title, String hreflang, int length);
+  StreamWriter 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);
+  StreamWriter startLink(String iri);
 
   /**
    * Start an atom:link element
    * @param iri The href value
    * @param rel The rel value
    */
-  void startLink(String iri, String rel);
+  StreamWriter startLink(String iri, String rel);
   
   /**
    * Start an atom:link element
@@ -507,7 +509,7 @@
    * @param rel The rel value
    * @param type The type value
    */
-  void startLink(String iri, String rel, String type);
+  StreamWriter startLink(String iri, String rel, String type);
   
   /**
    * Start an atom:link element
@@ -518,14 +520,14 @@
    * @param hreflang The hreflang value
    * @param length The link length
    */
-  void startLink(String iri, String rel, String type, String title, String hreflang, int length);
+  StreamWriter 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);
+  StreamWriter writeCategory(String term,Map<QName,String> attributes);
   
   /**
    * Write an atom:category element
@@ -533,7 +535,7 @@
    * @param scheme The term value
    * @param attributes Extension attributes
    */
-  void writeCategory(String term, String scheme,Map<QName,String> attributes);
+  StreamWriter writeCategory(String term, String scheme,Map<QName,String> attributes);
   
   /**
    * Write an atom:category element
@@ -542,14 +544,14 @@
    * @param label The term value
    * @param attributes Extension attributes
    */
-  void writeCategory(String term, String scheme, String label,Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter startCategory(String term,Map<QName,String> attributes);
 
   /**
    * Start an atom:category element
@@ -557,7 +559,7 @@
    * @param scheme The term value
    * @param attributes Extension attributes
    */
-  void startCategory(String term, String scheme,Map<QName,String> attributes);
+  StreamWriter startCategory(String term, String scheme,Map<QName,String> attributes);
   
   /**
    * Start an atom:category element
@@ -566,25 +568,25 @@
    * @param label The term value
    * @param attributes Extension attributes
    */
-  void startCategory(String term, String scheme, String label,Map<QName,String> attributes);
+  StreamWriter startCategory(String term, String scheme, String label,Map<QName,String> attributes);
   
   /**
    * End the atom:category
    */
-  void endCategory();
+  StreamWriter endCategory();
 
   /**
    * Write an atom:category element
    * @param term The term value
    */
-  void writeCategory(String term);
+  StreamWriter writeCategory(String term);
   
   /**
    * Write an atom:category element
    * @param term The term value
    * @param scheme The term value
    */
-  void writeCategory(String term, String scheme);
+  StreamWriter writeCategory(String term, String scheme);
   
   /**
    * Write an atom:category element
@@ -592,20 +594,20 @@
    * @param scheme The term value
    * @param label The term value
    */
-  void writeCategory(String term, String scheme, String label);
+  StreamWriter writeCategory(String term, String scheme, String label);
   
   /**
    * Start an atom:category element
    * @param term The term value
    */
-  void startCategory(String term);
+  StreamWriter startCategory(String term);
   
   /**
    * Start an atom:category element
    * @param term The term value
    * @param scheme The term value
    */
-  void startCategory(String term, String scheme);
+  StreamWriter startCategory(String term, String scheme);
   
   /**
    * Start an atom:category element
@@ -613,24 +615,24 @@
    * @param scheme The term value
    * @param label The term value
    */
-  void startCategory(String term, String scheme, String label);
+  StreamWriter startCategory(String term, String scheme, String label);
   
   
   /**
    * Start an atom:source element
    * @param attributes Extension attributes
    */
-  void startSource(Map<QName,String> attributes);
+  StreamWriter startSource(Map<QName,String> attributes);
   
   /**
    * Start an atom:source element
    */
-  void startSource();
+  StreamWriter startSource();
   
   /**
    * End the atom:source
    */
-  void endSource();
+  StreamWriter endSource();
   
   /**
    * Write a Text element
@@ -639,7 +641,7 @@
    * @param value The text value
    * @param attribute Extension attributes
    */
-  void writeText(QName qname, Text.Type type, String value,Map<QName,String> attributes);
+  StreamWriter writeText(QName qname, Text.Type type, String value,Map<QName,String> attributes);
   
   /**
    * Start a Text element
@@ -647,7 +649,7 @@
    * @param type The text type
    * @param attribute Extension attributes
    */
-  void startText(QName qname, Text.Type type,Map<QName,String> attributes);
+  StreamWriter startText(QName qname, Text.Type type,Map<QName,String> attributes);
 
   /**
    * Write a Text element
@@ -655,14 +657,14 @@
    * @param type The text type
    * @param value The text value
    */
-  void writeText(QName qname, Text.Type type, String value);
+  StreamWriter 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);
+  StreamWriter startText(QName qname, Text.Type type);
   
   /**
    * Write an atom:content element
@@ -670,7 +672,7 @@
    * @param value The text value
    * @param attribute Extension attributes
    */
-  void writeContent(Content.Type type, String value,Map<QName,String> attributes);
+  StreamWriter writeContent(Content.Type type, String value,Map<QName,String> attributes);
   
   /**
    * Write an atom:content element
@@ -678,7 +680,7 @@
    * @param value The text value
    * @param attribute Extension attributes
    */
-  void writeContent(Content.Type type, InputStream value,Map<QName,String> attributes) throws IOException;
+  StreamWriter writeContent(Content.Type type, InputStream value,Map<QName,String> attributes) throws IOException;
   
   /**
    * Write an atom:content element
@@ -686,7 +688,7 @@
    * @param value The text value
    * @param attribute Extension attributes
    */
-  void writeContent(Content.Type type, DataHandler value,Map<QName,String> attributes) throws IOException;
+  StreamWriter writeContent(Content.Type type, DataHandler value,Map<QName,String> attributes) throws IOException;
   
   /**
    * Write an atom:content element
@@ -694,7 +696,7 @@
    * @param value The text value
    * @param attribute Extension attributes
    */
-  void writeContent(String type, String value,Map<QName,String> attributes);
+  StreamWriter writeContent(String type, String value,Map<QName,String> attributes);
   
   /**
    * Start an atom:content element
@@ -702,14 +704,14 @@
    * @param value The text value
    * @param attribute Extension attributes
    */
-  void startContent(Content.Type type,Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter startContent(String type,Map<QName,String> attributes);
   
   /**
    * Start an atom:content element
@@ -717,7 +719,7 @@
    * @param src The src value
    * @param attribute Extension attributes
    */
-  void startContent(Content.Type type, String src,Map<QName,String> attributes);
+  StreamWriter startContent(Content.Type type, String src,Map<QName,String> attributes);
 
   /**
    * Start an atom:content element
@@ -725,161 +727,161 @@
    * @param src The text value
    * @param attribute Extension attributes
    */
-  void startContent(String type, String src,Map<QName,String> attributes);
+  StreamWriter startContent(String type, String src,Map<QName,String> attributes);
     
   /**
    * End the atom:content element
    */
-  void endContent();
+  StreamWriter endContent();
   
   /**
    * Write an atom:content element
    * @param type The text type
    * @param value The text value
    */  
-  void writeContent(Content.Type type, String value);
+  StreamWriter 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;
+  StreamWriter 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;
+  StreamWriter 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);
+  StreamWriter writeContent(String type, String value);
   
   /**
    * Start an atom:content element
    * @param type The text type
    */  
-  void startContent(Content.Type type);
+  StreamWriter startContent(Content.Type type);
   
   /**
    * Start an atom:content element
    * @param type The text type
    */  
-  void startContent(String type);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter startContent(String type, String src);
   
   /**
    * Start an element
    * @param qname Element qname
    * @param attributes Extension attributes
    */  
-  void startElement(QName qname,Map<QName,String> attributes);
+  StreamWriter startElement(QName qname,Map<QName,String> attributes);
   
   /**
    * Start an element
    * @param qname Element qname
    */  
-  void startElement(QName qname);
+  StreamWriter startElement(QName qname);
   
   /**
    * Write element text
    * @param value The text value
    */  
-  void writeElementText(String value);
+  StreamWriter writeElementText(String value);
   
   /**
    * Write element text
    * @param datahandler The text value
    */  
-  void writeElementText(DataHandler datahandler) throws IOException;
+  StreamWriter writeElementText(DataHandler datahandler) throws IOException;
   
   /**
    * Write element text
    * @param in The text value
    */  
-  void writeElementText(InputStream in) throws IOException;
+  StreamWriter writeElementText(InputStream in) throws IOException;
   
   /**
    * End the element
    */
-  void endElement();
+  StreamWriter endElement();
   
   /**
    * Write an atom:title element
    * @param value The text value
    */
-  void writeTitle(String value);
+  StreamWriter 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);
+  StreamWriter writeTitle(Text.Type type, String value);
 
   /**
    * Write an atom:subtitle element
    * @param value The text value
    */
-  void writeSubtitle(String value);
+  StreamWriter 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);
+  StreamWriter writeSubtitle(Text.Type type, String value);
   
   /**
    * Write an atom:summary element
    * @param value The text value
    */
-  void writeSummary(String value);
+  StreamWriter 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);
+  StreamWriter writeSummary(Text.Type type, String value);
   
   /**
    * Write an atom:rights element
    * @param value The text value
    */
-  void writeRights(String value);
+  StreamWriter 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);
+  StreamWriter 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);
+  StreamWriter writeTitle(String value,Map<QName,String> attributes);
   
   /**
    * Write an atom:title element
@@ -887,14 +889,14 @@
    * @param value The text value
    * @param attributes Extension attributes
    */
-  void writeTitle(Text.Type type, String value,Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter writeSubtitle(String value,Map<QName,String> attributes);
   
   /**
    * Write an atom:subtitle element
@@ -902,14 +904,14 @@
    * @param value The text value
    * @param attributes Extension attributes
    */
-  void writeSubtitle(Text.Type type, String value,Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter writeSummary(String value,Map<QName,String> attributes);
   
   /**
    * Write an atom:summary element
@@ -917,14 +919,14 @@
    * @param value The text value
    * @param attributes Extension attributes
    */
-  void writeSummary(Text.Type type, String value,Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter writeRights(String value,Map<QName,String> attributes);
   
   /**
    * Write an atom:rights element
@@ -932,7 +934,7 @@
    * @param value The text value
    * @param attributes Extension attributes
    */
-  void writeRights(Text.Type type, String value,Map<QName,String> attributes);
+  StreamWriter writeRights(Text.Type type, String value,Map<QName,String> attributes);
   
   
   /**
@@ -942,31 +944,31 @@
    * @param email The person email
    * @param uri The person uri
    */
-  void writePerson(QName qname, String name, String email, String uri);
+  StreamWriter writePerson(QName qname, String name, String email, String uri);
 
   /**
    * Start a person element
    * @param qname The element qname
    */  
-  void startPerson(QName qname);
+  StreamWriter startPerson(QName qname);
   
   /**
    * Write a person name
    * @param name The person name
    */
-  void writePersonName(String name);
+  StreamWriter writePersonName(String name);
 
   /**
    * Write a person email
    * @param email The person email
    */
-  void writePersonEmail(String email);
+  StreamWriter writePersonEmail(String email);
 
   /**
    * Write a person uri
    * @param uri The person uri
    */
-  void writePersonUri(String uri);
+  StreamWriter writePersonUri(String uri);
   
   /**
    * Write an atom:author element
@@ -974,7 +976,7 @@
    * @param email The person email
    * @param uri The person uri
    */
-  void writeAuthor(String name, String email, String uri);
+  StreamWriter writeAuthor(String name, String email, String uri);
   
   /**
    * Write an atom:author element
@@ -983,23 +985,23 @@
    * @param uri The person uri
    * @param attribute ExtensionAttributes
    */
-  void writeAuthor(String name, String email, String uri, Map<QName,String> attributes);
+  StreamWriter writeAuthor(String name, String email, String uri, Map<QName,String> attributes);
   
   /**
    * Start an atom:author element
    */
-  void startAuthor();
+  StreamWriter startAuthor();
   
   /**
    * Start an atom:author element
    * @params attributes ExtensionAttributes
    */
-  void startAuthor(Map<QName,String> attributes);
+  StreamWriter startAuthor(Map<QName,String> attributes);
   
   /**
    * End the atom:author element
    */
-  void endAuthor();
+  StreamWriter endAuthor();
   
   /**
    * Write an atom:contributor element
@@ -1007,7 +1009,7 @@
    * @param email The person email
    * @param uri The person uri
    */
-  void writeContributor(String name, String email, String uri);
+  StreamWriter writeContributor(String name, String email, String uri);
   
   /**
    * Write an atom:contributor element
@@ -1016,23 +1018,23 @@
    * @param uri The person uri
    * @param attributes Extension attributes
    */
-  void writeContributor(String name, String email, String uri, Map<QName,String> attributes);
+  StreamWriter writeContributor(String name, String email, String uri, Map<QName,String> attributes);
   
   /**
    * Start an atom:contributor element
    */
-  void startContributor();
+  StreamWriter startContributor();
   
   /**
    * Start an atom:contributor element
    * @param attributes Extension attributes
    */
-  void startContributor(Map<QName,String> attributes);
+  StreamWriter startContributor(Map<QName,String> attributes);
   
   /**
    * End an atom:contributor element
    */
-  void endContributor();
+  StreamWriter endContributor();
   
   /**
    * Write an atom:generator element
@@ -1040,7 +1042,7 @@
    * @param uri The uri value
    * @param value The text value
    */
-  void writeGenerator(String version, String uri, String value);
+  StreamWriter writeGenerator(String version, String uri, String value);
 
   /**
    * Write an atom:generator element
@@ -1049,14 +1051,14 @@
    * @param value The text value
    * @param attributes Extension attributes
    */
-  void writeGenerator(String version, String uri, String value, Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter startGenerator(String version, String uri);
   
   /**
    * Start an atom:generator element
@@ -1064,115 +1066,115 @@
    * @param uri The uri value
    * @param attributes Extension attributes
    */
-  void startGenerator(String version, String uri, Map<QName,String> attributes);
+  StreamWriter startGenerator(String version, String uri, Map<QName,String> attributes);
   
   /**
    * End the atom:generator element
    */
-  void endGenerator();
+  StreamWriter endGenerator();
   
   /**
    * Write an XML comment
    */
-  void writeComment(String value);
+  StreamWriter writeComment(String value);
   
   /**
    * Write an XML Processing Instruction
    */
-  void writePI(String value);
+  StreamWriter writePI(String value);
 
   /**
    * Write an XML Processing Instruction
    */
-  void writePI(String value, String target);
+  StreamWriter writePI(String value, String target);
   
   
   /**
    * Start an app:service element
    */
-  void startService();
+  StreamWriter startService();
   
   /**
    * Start an app:service element
    * @param attributes Extension attributes
    */
-  void startService(Map<QName,String> attributes);
+  StreamWriter startService(Map<QName,String> attributes);
   
   /**
    * End an app:service element
    */
-  void endService();
+  StreamWriter endService();
   
   /**
    * Start an app:workspace element
    */
-  void startWorkspace();
+  StreamWriter startWorkspace();
   
   /**
    * Start an app:workspace element
    * @param attributes Extension attributes
    */
-  void startWorkspace(Map<QName,String> attributes);
+  StreamWriter startWorkspace(Map<QName,String> attributes);
   
   /**
    * End an app:workspace element
    */
-  void endWorkspace();
+  StreamWriter endWorkspace();
   
   /**
    * Start an app:collection element
    * @param href The href value
    */
-  void startCollection(String href);
+  StreamWriter 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);
+  StreamWriter startCollection(String href, Map<QName,String> attributes);
   
   /**
    * End an app:collection element
    */
-  void endCollection();
+  StreamWriter endCollection();
   
   /**
    * Writes app:accept elements
    * @param accepts accept element values
    */
-  void writeAccepts(String... accepts);
+  StreamWriter writeAccepts(String... accepts);
   
   /**
    * Start an app:categories element
    */
-  void startCategories();
+  StreamWriter startCategories();
   
   /**
    * Start an app:categories element
    * @param fixed True if the app:categories element is fixed
    */
-  void startCategories(boolean 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
    */
-  void startCategories(boolean fixed, String scheme);
+  StreamWriter startCategories(boolean fixed, String scheme);
   
   /**
   * Start an app:categories element
   * @param attributes Extension attributes
   */
-  void startCategories(Map<QName,String> attributes);
+  StreamWriter 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);
+  StreamWriter startCategories(boolean fixed, Map<QName,String> attributes);
   
   /**
    * Start an app:categories element
@@ -1180,34 +1182,34 @@
    * @param scheme The scheme value
    * @param attributes Extension attributes
    */
-  void startCategories(boolean fixed, String scheme, Map<QName,String> attributes);
+  StreamWriter startCategories(boolean fixed, String scheme, Map<QName,String> attributes);
   
   /**
    * End the app:categories element
    */
-  void endCategories();
+  StreamWriter endCategories();
 
   /**
    * Start the app:control element
    */
-  void startControl();
+  StreamWriter startControl();
   
   /**
    * Start the app:control element
    * @param attributes Extension attributes
    */
-  void startControl(Map<QName,String> attributes);
+  StreamWriter startControl(Map<QName,String> attributes);
   
   /**
    * End the app:control element
    */
-  void endControl();
+  StreamWriter endControl();
   
   /**
    * Write an app:draft element
    * @param draft true if app:draft=yes
    */
-  void writeDraft(boolean draft);
+  StreamWriter writeDraft(boolean draft);
   
 }
 

Modified: 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=592532&r1=592531&r2=592532&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java Tue Nov  6 11:45:54 2007
@@ -29,6 +29,7 @@
 
 import org.apache.abdera.parser.stax.util.FOMHelper;
 import org.apache.abdera.util.AbstractStreamWriter;
+import org.apache.abdera.writer.StreamWriter;
 import org.apache.axiom.om.util.StAXUtils;
 
 public class StaxStreamWriter 
@@ -61,59 +62,66 @@
     setOutputStream(out,charset);
   }
 
-  public void setWriter(java.io.Writer writer) {
+  public StreamWriter setWriter(java.io.Writer writer) {
     try {
       this.writer = StAXUtils.createXMLStreamWriter(writer);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
-  public void setOutputStream(java.io.OutputStream out) {
+  public StreamWriter setOutputStream(java.io.OutputStream out) {
     try {
       this.writer = StAXUtils.createXMLStreamWriter(out,"UTF-8");
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
-  public void setOutputStream(java.io.OutputStream out, String charset) {
+  public StreamWriter setOutputStream(java.io.OutputStream out, String charset) {
     try {
       this.writer = StAXUtils.createXMLStreamWriter(out,charset);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
   
-  public void startDocument(String xmlversion, String charset) {
+  public StreamWriter startDocument(String xmlversion, String charset) {
     try {
       writer.writeStartDocument(xmlversion,charset);
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }    
+    return this;
   }
   
-  public void startDocument(String xmlversion) {
+  public StreamWriter startDocument(String xmlversion) {
     try {
       writer.writeStartDocument(xmlversion);
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
   
-  public void endDocument() {
+  public StreamWriter endDocument() {
     try {
       writer.writeEndDocument();
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
  
-  public void endElement() {
+  public StreamWriter endElement() {
     try {
       pop();
       writer.writeEndElement();
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
   
   private void writeNamespace(QName qname, boolean attr) throws XMLStreamException {
@@ -130,7 +138,7 @@
     }
   }
   
-  public void startElement(QName qname, Map<QName, String> attributes) {
+  public StreamWriter startElement(QName qname, Map<QName, String> attributes) {
     try {
       push();
       writer.writeStartElement(qname.getPrefix(),qname.getLocalPart(),qname.getNamespaceURI());
@@ -149,38 +157,43 @@
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
   
-  public void writeElementText(String value) {
+  public StreamWriter writeElementText(String value) {
     try {
       writer.writeCharacters(value);
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
 
-  public void writeComment(String value) {
+  public StreamWriter writeComment(String value) {
     try {
       writer.writeComment(value);
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
 
-  public void writePI(String value) {
+  public StreamWriter writePI(String value) {
     try {
       writer.writeProcessingInstruction(value);
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
 
-  public void writePI(String value, String target) {
+  public StreamWriter writePI(String value, String target) {
     try {
       writer.writeProcessingInstruction(value,target);
     } catch(XMLStreamException e) {
       throw new RuntimeException(e);
     }
+    return this;
   }
   
   private final Stack<Map<String,String>> namespaces = new Stack<Map<String,String>>();
@@ -211,8 +224,9 @@
     frame.put(prefix, namespace);
   }
 
-  public void writeId(Map<QName,String> attributes) {
+  public StreamWriter writeId(Map<QName,String> attributes) {
     writeId(FOMHelper.generateUuid(),attributes);
+    return this;
   }
     
 }



Mime
View raw message