abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r596789 - in /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera: util/AbstractStreamWriter.java writer/StreamWriter.java
Date Tue, 20 Nov 2007 19:22:46 GMT
Author: jmsnell
Date: Tue Nov 20 11:22:45 2007
New Revision: 596789

URL: http://svn.apache.org/viewvc?rev=596789&view=rev
Log:
Utility variants that allow writing Dates, longs, ints and doubles easier (other than strings,
these tend to be the most common data types used for element and attribute values)

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

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=596789&r1=596788&r2=596789&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 20 11:22:45 2007
@@ -654,4 +654,180 @@
     this.autoindent = indent;
     return this;
   }
+  
+  public StreamWriter writeAttribute(
+    QName qname, 
+    Date value) {
+      return writeAttribute(
+        qname.getLocalPart(), 
+        qname.getNamespaceURI(), 
+        qname.getPrefix(), 
+        value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    Date value) {
+      return writeAttribute(
+        name, null, null, value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    Date value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        null, 
+        value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    String prefix, 
+    Date value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        prefix, 
+        AtomDate.format(value));
+  }
+  
+  public StreamWriter writeAttribute(
+    QName qname, 
+    int value) {
+      return writeAttribute(
+          qname.getLocalPart(), 
+          qname.getNamespaceURI(), 
+          qname.getPrefix(), 
+          value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    int value) {
+      return writeAttribute(
+        name, null, null, value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    int value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        null, 
+        value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    String prefix, 
+    int value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        prefix, 
+        Integer.toString(value));
+  }
+
+  public StreamWriter writeAttribute(
+    QName qname, 
+    long value) {
+      return writeAttribute(
+          qname.getLocalPart(), 
+          qname.getNamespaceURI(), 
+          qname.getPrefix(), 
+          value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    long value) {
+      return writeAttribute(
+        name, null, null, value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    long value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        null, 
+        value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    String prefix, 
+    long value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        prefix, 
+        Long.toString(value));
+  }
+  
+  public StreamWriter writeAttribute(
+    QName qname, 
+    double value) {
+      return writeAttribute(
+          qname.getLocalPart(), 
+          qname.getNamespaceURI(), 
+          qname.getPrefix(), 
+          value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    double value) {
+      return writeAttribute(
+        name, null, null, value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    double value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        null, 
+        value);
+  }
+  
+  public StreamWriter writeAttribute(
+    String name, 
+    String namespace, 
+    String prefix, 
+    double value) {
+      return writeAttribute(
+        name, 
+        namespace, 
+        prefix, 
+        Double.toString(value));
+  }
+  
+  public StreamWriter writeElementText(Date value) {
+    return writeElementText(AtomDate.format(value));
+  }
+
+  public StreamWriter writeElementText(int value) {
+    return writeElementText(Integer.toString(value));
+  }
+  
+  public StreamWriter writeElementText(long value) {
+    return writeElementText(Long.toString(value));
+  }
+  
+  public StreamWriter writeElementText(double value) {
+    return writeElementText(Double.toString(value));
+  }
 }

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=596789&r1=596788&r2=596789&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 20 11:22:45 2007
@@ -480,6 +480,30 @@
    * @param in The text value
    */  
   StreamWriter writeElementText(InputStream in) throws IOException;
+
+  /**
+   * Write element text
+   * @param value The text value
+   */  
+  StreamWriter writeElementText(Date value);
+
+  /**
+   * Write element text
+   * @param value The text value
+   */  
+  StreamWriter writeElementText(int value);
+  
+  /**
+   * Write element text
+   * @param value The text value
+   */  
+  StreamWriter writeElementText(long value);
+  
+  /**
+   * Write element text
+   * @param value The text value
+   */  
+  StreamWriter writeElementText(double value);
   
   /**
    * End the element
@@ -722,6 +746,11 @@
   /**
    * Write an attribute
    */
+  StreamWriter writeAttribute(QName qname, String value);
+  
+  /**
+   * Write an attribute
+   */
   StreamWriter writeAttribute(String name, String value);
   
   /**
@@ -737,7 +766,83 @@
   /**
    * Write an attribute
    */
-  StreamWriter writeAttribute(QName qname, String value);
+  StreamWriter writeAttribute(QName qname, Date value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, Date value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, Date value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, String prefix, Date value);
+
+
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(QName qname, int value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, int value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, int value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, String prefix, int value);
+
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(QName qname, long value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, long value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, long value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, String prefix, long value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(QName qname, double value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, double value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, double value);
+  
+  /**
+   * Write an attribute
+   */
+  StreamWriter writeAttribute(String name, String namespace, String prefix, double value);
   
   /**
    * Write a new line and indent



Mime
View raw message