abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r639945 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/factory/StreamBuilder.java core/src/main/java/org/apache/abdera/writer/StreamWriter.java parser/src/main/java/org/apache/abdera/parser/stax/StaxStreamWriter.java
Date Sat, 22 Mar 2008 03:15:33 GMT
Author: jmsnell
Date: Fri Mar 21 20:15:32 2008
New Revision: 639945

URL: http://svn.apache.org/viewvc?rev=639945&view=rev
Log:
method on streamwriter for writing a namespace declaration. for most cases, this is handled
automatically; but this is here to make it a bit easier

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/StreamBuilder.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/factory/StreamBuilder.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/StreamBuilder.java?rev=639945&r1=639944&r2=639945&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/StreamBuilder.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/StreamBuilder.java
Fri Mar 21 20:15:32 2008
@@ -35,6 +35,7 @@
 import org.apache.abdera.model.Element;
 import org.apache.abdera.model.Content.Type;
 import org.apache.abdera.util.AbstractStreamWriter;
+import org.apache.abdera.writer.StreamWriter;
 
 /**
  * StreamBuilder is a special implementation of the StreamWriter interface that
@@ -847,6 +848,18 @@
 
   public StreamBuilder writeUpdated(String date) {
     return (StreamBuilder)super.writeUpdated(date);
+  }
+
+  public StreamWriter writeDefaultNamespace(String uri) {
+    if (!(current instanceof Element)) throw new IllegalStateException("Not currently an
element");
+    ((Element)current).declareNS(uri, "");
+    return this;
+  }
+
+  public StreamWriter writeNamespace(String prefix, String uri) {
+    if (!(current instanceof Element)) throw new IllegalStateException("Not currently an
element");
+    ((Element)current).declareNS(uri, prefix);
+    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=639945&r1=639944&r2=639945&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
Fri Mar 21 20:15:32 2008
@@ -1101,5 +1101,18 @@
    * Write the xml:lang attribute
    */
   StreamWriter writeLanguage(Locale locale);
+  
+  /**
+   * Write a namespace declaration to an element
+   */
+  StreamWriter writeNamespace(
+      String prefix,
+      String uri);
+  
+  /**
+   * Write the default namespace declaration to an element
+   */
+  StreamWriter writeDefaultNamespace(String uri);
+  
 }
 

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=639945&r1=639944&r2=639945&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
Fri Mar 21 20:15:32 2008
@@ -227,6 +227,26 @@
     return writeId(FOMHelper.generateUuid());
   }
 
+  public StreamWriter writeDefaultNamespace(String uri) {
+    try {
+      writer.writeDefaultNamespace(uri);
+    } catch (XMLStreamException e) {
+      throw new RuntimeException(e);
+    }
+    return this;
+  }
+  
+  public StreamWriter writeNamespace(
+    String prefix,
+    String uri) {
+      try {
+        writer.writeNamespace(prefix, uri);
+      } catch (XMLStreamException e) {
+        throw new RuntimeException(e);
+      }
+      return this;
+  }
+  
   public StreamWriter writeAttribute(
     String name, 
     String namespace,



Mime
View raw message