abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1186541 [6/8] - in /abdera/abdera2: ./ .settings/ activities/ activities/.settings/ activities/src/main/java/org/apache/abdera2/activities/client/ activities/src/main/java/org/apache/abdera2/activities/extra/ activities/src/main/java/org/a...
Date Wed, 19 Oct 2011 22:33:52 GMT
Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractStreamWriter.java Wed Oct 19 22:33:04 2011
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.channels.Channels;
 import java.nio.channels.WritableByteChannel;
-import java.util.Date;
 import java.util.Formatter;
 import java.util.HashSet;
 import java.util.Locale;
@@ -31,13 +30,15 @@ import java.util.Set;
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 
+import org.joda.time.DateTime;
+
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.common.Constants;
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.lang.Lang;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.xml.XMLVersion;
-import org.apache.abdera2.common.date.DateTime;
+import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.model.Content;
 import org.apache.abdera2.model.Text;
 import org.apache.abdera2.model.Text.Type;
@@ -245,7 +246,7 @@ public abstract class AbstractStreamWrit
         return startContent(type).writeElementText(value).endContent();
     }
 
-    public StreamWriter writeEdited(Date date) {
+    public StreamWriter writeEdited(DateTime date) {
         writeDate(Constants.EDITED, date);
         return this;
     }
@@ -282,7 +283,7 @@ public abstract class AbstractStreamWrit
         return startPerson(qname).writePersonName(name).writePersonEmail(email).writePersonUri(uri).endPerson();
     }
 
-    public StreamWriter writePublished(Date date) {
+    public StreamWriter writePublished(DateTime date) {
         return writeDate(Constants.PUBLISHED, date);
     }
 
@@ -290,7 +291,7 @@ public abstract class AbstractStreamWrit
         return startText(qname, type).writeElementText(value).endElement();
     }
 
-    public StreamWriter writeUpdated(Date date) {
+    public StreamWriter writeUpdated(DateTime date) {
         return writeDate(Constants.UPDATED, date);
     }
 
@@ -306,8 +307,8 @@ public abstract class AbstractStreamWrit
         return writeDate(Constants.EDITED, date);
     }
 
-    public StreamWriter writeDate(QName qname, Date date) {
-        return writeDate(qname, DateTime.format(date));
+    public StreamWriter writeDate(QName qname, DateTime date) {
+        return writeDate(qname, DateTimes.format(date));
     }
 
     public StreamWriter writeId(IRI iri) {
@@ -542,20 +543,20 @@ public abstract class AbstractStreamWrit
         return this;
     }
 
-    public StreamWriter writeAttribute(QName qname, Date value) {
+    public StreamWriter writeAttribute(QName qname, DateTime value) {
         return writeAttribute(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix(), value);
     }
 
-    public StreamWriter writeAttribute(String name, Date value) {
+    public StreamWriter writeAttribute(String name, DateTime value) {
         return writeAttribute(name, null, null, value);
     }
 
-    public StreamWriter writeAttribute(String name, String namespace, Date value) {
+    public StreamWriter writeAttribute(String name, String namespace, DateTime value) {
         return writeAttribute(name, namespace, null, value);
     }
 
-    public StreamWriter writeAttribute(String name, String namespace, String prefix, Date value) {
-        return writeAttribute(name, namespace, prefix, DateTime.format(value));
+    public StreamWriter writeAttribute(String name, String namespace, String prefix, DateTime value) {
+        return writeAttribute(name, namespace, prefix, DateTimes.format(value));
     }
 
     public StreamWriter writeAttribute(QName qname, int value) {
@@ -606,8 +607,8 @@ public abstract class AbstractStreamWrit
         return writeAttribute(name, namespace, prefix, Double.toString(value));
     }
 
-    public StreamWriter writeElementText(Date value) {
-        return writeElementText(DateTime.format(value));
+    public StreamWriter writeElementText(DateTime value) {
+        return writeElementText(DateTimes.format(value));
     }
 
     public StreamWriter writeElementText(int value) {
@@ -666,15 +667,15 @@ public abstract class AbstractStreamWrit
         return startElement(name).writeElementText(iri).endElement();
     }
 
-    public StreamWriter writeDate(String name, Date date) {
+    public StreamWriter writeDate(String name, DateTime date) {
         return startElement(name).writeElementText(date).endElement();
     }
 
-    public StreamWriter writeDate(String name, String namespace, Date date) {
+    public StreamWriter writeDate(String name, String namespace, DateTime date) {
         return startElement(name, namespace).writeElementText(date).endElement();
     }
 
-    public StreamWriter writeDate(String name, String namespace, String prefix, Date date) {
+    public StreamWriter writeDate(String name, String namespace, String prefix, DateTime date) {
         return startElement(name, namespace, prefix).writeElementText(date).endElement();
     }
 
@@ -774,4 +775,54 @@ public abstract class AbstractStreamWrit
       }
       return false;
   }
+
+  public StreamWriter writeUpdatedNow() {
+    return writeUpdated(DateTime.now());
+  }
+
+  public StreamWriter writePublishedNow() {
+    return writePublished(DateTime.now());
+  }
+
+  public StreamWriter writeEditedNow() {
+    return writeEdited(DateTime.now());
+  }
+
+  public StreamWriter writeDateNow(QName qname) {
+    return writeDate(qname,DateTime.now());
+  }
+
+  public StreamWriter writeDateNow(String name, String namespace, String prefix) {
+    return writeDate(name,namespace,prefix,DateTime.now());
+  }
+
+  public StreamWriter writeDateNow(String name, String namespace) {
+    return writeDate(name,namespace,DateTime.now());
+  }
+
+  public StreamWriter writeDateNow(String name) {
+    return writeDate(name,DateTime.now());
+  }
+
+  public StreamWriter writeElementTextNow() {
+    return writeElementText(DateTime.now());
+  }
+
+  public StreamWriter writeAttributeNow(QName qname) {
+    return writeAttribute(qname,DateTime.now());
+  }
+
+  public StreamWriter writeAttributeNow(String name) {
+    return writeAttribute(name,DateTime.now());
+  }
+
+  public StreamWriter writeAttributeNow(String name, String namespace) {
+    return writeAttribute(name,namespace,DateTime.now());
+  }
+
+  public StreamWriter writeAttributeNow(String name, String namespace,
+      String prefix) {
+    return writeAttribute(name,namespace,prefix,DateTime.now());
+  }
+  
 }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/StreamWriter.java Wed Oct 19 22:33:04 2011
@@ -22,9 +22,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.channels.WritableByteChannel;
-import java.util.Date;
 import java.util.Locale;
 
+import org.joda.time.DateTime;
+
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 
@@ -255,58 +256,112 @@ public interface StreamWriter extends Ap
      * 
      * @param date The date value
      */
-    StreamWriter writeUpdated(Date date);
+    StreamWriter writeUpdated(DateTime date);
+    
+    /**
+     * Write an atom:updated element
+     */
+    StreamWriter writeUpdatedNow();
 
     /**
      * Write an atom:published element
      * 
      * @param date The date value
      */
-    StreamWriter writePublished(Date date);
+    StreamWriter writePublished(DateTime date);
 
     /**
+     * Write an atom:published element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writePublishedNow();
+    
+    /**
      * Write an atom:edited element
      * 
      * @param date The date value
      */
-    StreamWriter writeEdited(Date date);
+    StreamWriter writeEdited(DateTime date);
 
     /**
+     * Write an atom:edited element
+     * 
+     * @param date The date value
+     */
+    StreamWriter writeEditedNow();
+    
+    /**
      * Write a Date element
      * 
      * @param qname The element qname
      * @param date The date value
      */
-    StreamWriter writeDate(QName qname, Date date);
+    StreamWriter writeDate(QName qname, DateTime date);
 
     /**
      * Write a Date element
      * 
+     * @param qname The element qname
+     * @param date The date value
+     */
+    StreamWriter writeDateNow(QName qname);
+    
+    /**
+     * Write a Date element
+     * 
      * @param name The element localname
      * @param namespace The element namespace
      * @param prefix The element prefix
      * @param date The date value
      */
-    StreamWriter writeDate(String name, String namespace, String prefix, Date date);
+    StreamWriter writeDate(String name, String namespace, String prefix, DateTime date);
 
     /**
      * Write a Date element
      * 
      * @param name The element localname
      * @param namespace The element namespace
+     * @param prefix The element prefix
      * @param date The date value
      */
-    StreamWriter writeDate(String name, String namespace, Date date);
+    StreamWriter writeDateNow(String name, String namespace, String prefix);
+    
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param namespace The element namespace
+     * @param date The date value
+     */
+    StreamWriter writeDate(String name, String namespace, DateTime date);
 
     /**
      * Write a Date element
      * 
      * @param name The element localname
+     * @param namespace The element namespace
+     * @param date The date value
+     */
+    StreamWriter writeDateNow(String name, String namespace);
+    
+    /**
+     * Write a Date element
+     * 
+     * @param name The element localname
      * @param date The date value
      */
-    StreamWriter writeDate(String name, Date date);
+    StreamWriter writeDate(String name, DateTime date);
 
     /**
+     * Write a Date element
+     * 
+     * @param name The element localname
+     * @param date The date value
+     */
+    StreamWriter writeDateNow(String name);
+    
+    /**
      * Write an atom:updated element
      * 
      * @param date The date value
@@ -707,13 +762,20 @@ public interface StreamWriter extends Ap
      * 
      * @param value The text value
      */
-    StreamWriter writeElementText(Date value);
+    StreamWriter writeElementText(DateTime value);
 
     /**
      * Write element text
      * 
      * @param value The text value
      */
+    StreamWriter writeElementTextNow();
+    
+    /**
+     * Write element text
+     * 
+     * @param value The text value
+     */
     StreamWriter writeElementText(int value);
 
     /**
@@ -1093,26 +1155,46 @@ public interface StreamWriter extends Ap
     /**
      * Write an attribute
      */
-    StreamWriter writeAttribute(QName qname, Date value);
+    StreamWriter writeAttribute(QName qname, DateTime value);
 
     /**
      * Write an attribute
      */
-    StreamWriter writeAttribute(String name, Date value);
+    StreamWriter writeAttributeNow(QName qname);
+    
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, DateTime value);
 
     /**
      * Write an attribute
      */
-    StreamWriter writeAttribute(String name, String namespace, Date value);
+    StreamWriter writeAttributeNow(String name);
+    
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, DateTime value);
 
     /**
      * Write an attribute
      */
-    StreamWriter writeAttribute(String name, String namespace, String prefix, Date value);
+    StreamWriter writeAttributeNow(String name, String namespace);
+    
+    /**
+     * Write an attribute
+     */
+    StreamWriter writeAttribute(String name, String namespace, String prefix, DateTime value);
 
     /**
      * Write an attribute
      */
+    StreamWriter writeAttributeNow(String name, String namespace, String prefix);
+    
+    /**
+     * Write an attribute
+     */
     StreamWriter writeAttribute(QName qname, int value);
 
     /**

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writers.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writers.java?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writers.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/Writers.java Wed Oct 19 22:33:04 2011
@@ -0,0 +1,202 @@
+package org.apache.abdera2.writer;
+
+import java.io.Closeable;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.misc.ExceptionHelper;
+import org.apache.abdera2.model.Base;
+
+import com.google.common.base.Function;
+
+public final class Writers {
+
+  private Writers() {}
+  
+  public static abstract class WriterFunction 
+    implements Function<Base,Void> { 
+    protected final Closeable closeable;
+    protected WriterFunction(Closeable closeable) {
+      this.closeable = closeable;
+    }
+    public WriterFunction closing() {
+      return new ClosingWriterFunction(this);
+    }
+  }
+  private static class ClosingWriterFunction
+    extends WriterFunction
+    implements Function<Base,Void> {
+      private final WriterFunction function;
+      public ClosingWriterFunction(
+          WriterFunction function) {
+        super(function.closeable);
+        this.function = function;
+      }
+      public Void apply(Base input) {
+        try {
+          function.apply(input);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        } finally {
+          try {
+            closeable.close();
+          } catch (Throwable t) {
+            throw ExceptionHelper.propogate(t);
+          }
+        }
+      }
+  }
+
+  public static WriterFunction forWriter(
+    final java.io.Writer w) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          Abdera.getInstance().getWriter().writeTo(input, w);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forWriter(
+    final Writer writer, 
+    final java.io.Writer w) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          writer.writeTo(input, w);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forWriter(
+    final Writer writer, 
+    final java.io.Writer w, 
+    final WriterOptions options) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          writer.writeTo(input, w, options);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forWriter(
+    final String writer, 
+    final java.io.Writer w) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          Abdera.getInstance().getWriterFactory().getWriter(writer).writeTo(input, w);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forWriter(
+    final String writer, 
+    final java.io.Writer w, 
+    final WriterOptions options) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          Abdera.getInstance().getWriterFactory().getWriter(writer).writeTo(input, w, options);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  
+  public static WriterFunction forOutputStream(
+    final java.io.OutputStream w) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          Abdera.getInstance().getWriter().writeTo(input, w);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forOutputStream(
+    final Writer writer, 
+    final java.io.OutputStream w) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          writer.writeTo(input, w);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forOutputStream(
+    final Writer writer, 
+    final java.io.OutputStream w, 
+    final WriterOptions options) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          writer.writeTo(input, w, options);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forOutputStream(
+    final String writer, 
+    final java.io.OutputStream w) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          Abdera.getInstance().getWriterFactory().getWriter(writer).writeTo(input, w);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static WriterFunction forOutputStream(
+    final String writer, 
+    final java.io.OutputStream w, 
+    final WriterOptions options) {
+    return new WriterFunction(w) {
+      public Void apply(Base input) {
+        try {
+          Abdera.getInstance().getWriterFactory().getWriter(writer).writeTo(input, w, options);
+          return null;
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+}

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

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPaths.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPaths.java?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPaths.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/xpath/XPaths.java Wed Oct 19 22:33:04 2011
@@ -0,0 +1,194 @@
+package org.apache.abdera2.xpath;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Base;
+
+import com.google.common.base.Function;
+
+@SuppressWarnings("unchecked")
+public final class XPaths  {
+
+  private XPaths() {}
+  
+  protected static abstract class XPathFunction<E extends Base, X>
+    implements Function<E,X> {
+    
+    protected final XPath xpath;
+    protected final String path;
+    protected final Map<String,String> namespaces =
+      new HashMap<String,String>();
+    
+    public XPathFunction(XPath xpath, String query) {
+      this.xpath = xpath;
+      this.path = query;
+      this.namespaces.putAll(xpath.getDefaultNamespaces());     
+    }
+    
+    public XPathFunction(String query) {
+      this(Abdera.getInstance().getXPath(),query);
+    }
+    
+    public XPathFunction(
+      XPath xpath,
+      String query,
+      Map<String,String> namespaces) {
+        this.xpath = xpath;
+        this.path = query;
+        this.namespaces.putAll(namespaces);
+    }
+    
+    public XPathFunction(
+      String query, 
+      Map<String,String> namespaces) {
+      this(Abdera.getInstance().getXPath(),query,namespaces);
+    }
+  }
+  
+  public static <E extends Base>XPathFunction<E, Boolean> booleanValueOf(final String query) {
+    return new XPathFunction<E,Boolean>(query) {
+      public Boolean apply(E input) {
+        return xpath.booleanValueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,Boolean> booleanValueOf(final XPath xpath, final String query) {
+    return new XPathFunction<E,Boolean>(xpath,query) {
+      public Boolean apply(E input) {
+        return xpath.booleanValueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,Boolean> booleanValueOf(final XPath xpath, final String query, Map<String,String> ns) {
+    return new XPathFunction<E,Boolean>(xpath,query,ns) {
+      public Boolean apply(E input) {
+        return xpath.booleanValueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X>XPathFunction<E,X> evaluate(final String query) {
+    return new XPathFunction<E,X>(query) {
+      public X apply(E input) {
+        return (X)xpath.evaluate(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X>XPathFunction<E,X> evaluate(final XPath xpath, final String query) {
+    return new XPathFunction<E,X>(xpath,query) {
+      public X apply(E input) {
+        return (X)xpath.evaluate(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X>XPathFunction<E, X> evaluate(final XPath xpath, final String query, Map<String,String> ns) {
+    return new XPathFunction<E, X>(xpath,query,ns) {
+      public X apply(E input) {
+        return (X)xpath.evaluate(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X extends Number>XPathFunction<E,X> numericValueOf(final String query) {
+    return new XPathFunction<E,X>(query) {
+      public X apply(E input) {
+        return (X)xpath.numericValueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X extends Number>XPathFunction<E,X> numericValueOf(final XPath xpath, final String query) {
+    return new XPathFunction<E,X>(xpath,query) {
+      public X apply(E input) {
+        return (X)xpath.numericValueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X extends Number>XPathFunction<E,X> numericValueOf(final XPath xpath, final String query, Map<String,String> ns) {
+    return new XPathFunction<E,X>(xpath,query,ns) {
+      public X apply(E input) {
+        return (X)xpath.numericValueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,Collection<?>> selectNodes(final String query) {
+    return new XPathFunction<E,Collection<?>>(query) {
+      public Collection<?> apply(E input) {
+        return xpath.selectNodes(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,Collection<?>> selectNodes(final XPath xpath, final String query) {
+    return new XPathFunction<E,Collection<?>>(xpath,query) {
+      public Collection<?> apply(E input) {
+        return xpath.selectNodes(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,Collection<?>> selectNodes(final XPath xpath, final String query, Map<String,String> ns) {
+    return new XPathFunction<E,Collection<?>>(xpath,query,ns) {
+      public Collection<?> apply(E input) {
+        return xpath.selectNodes(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X>XPathFunction<E,X> selectSingleNode(final String query) {
+    return new XPathFunction<E,X>(query) {
+      public X apply(E input) {
+        return (X)xpath.selectSingleNode(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X>XPathFunction<E,X> selectSingleNode(final XPath xpath, final String query) {
+    return new XPathFunction<E,X>(xpath,query) {
+      public X apply(E input) {
+        return (X)xpath.selectSingleNode(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base, X>XPathFunction<E,X> selectSingleNode(final XPath xpath, final String query, Map<String,String> ns) {
+    return new XPathFunction<E,X>(xpath,query,ns) {
+      public X apply(E input) {
+        return (X)xpath.selectSingleNode(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,String> valueOf(final String query) {
+    return new XPathFunction<E,String>(query) {
+      public String apply(E input) {
+        return xpath.valueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,String> valueOf(final XPath xpath, final String query) {
+    return new XPathFunction<E,String>(xpath,query) {
+      public String apply(E input) {
+        return xpath.valueOf(path, input, namespaces);
+      }
+    };
+  }
+  
+  public static <E extends Base>XPathFunction<E,String> valueOf(final XPath xpath, final String query, Map<String,String> ns) {
+    return new XPathFunction<E,String>(xpath,query,ns) {
+      public String apply(Base input) {
+        return xpath.valueOf(path, input, namespaces);
+      }
+    };
+  }
+}

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

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java Wed Oct 19 22:33:04 2011
@@ -9,7 +9,7 @@ public class MiscellaneousExamples {
 
   public static void main(String... args) throws Exception {
     
-    // Working with URI Templates.. the Misc.ASContext 
+    // Working with URI Templates.. the ASContext class
     // provides a URI Template Context implementation
     // that wraps an Activity Streams object, making it 
     // easier to construct IRI/URI's using properties

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java Wed Oct 19 22:33:04 2011
@@ -17,8 +17,6 @@ package org.apache.abdera2.examples.acti
  * directory of this distribution.
  */
 
-
-import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.logging.Logger;
@@ -91,7 +89,7 @@ public class MyActivitiesAdapter extends
         String entryId = getObjectIdFromUri(object.getId().toString());
         if (c != -1) entryId += c;
         if (object.getUpdated() == null) {
-            object.setUpdated(new Date());
+            object.setUpdatedNow();
         }
         addEditLinkToObject(object);
         storeObject(entryId, object);
@@ -105,7 +103,7 @@ public class MyActivitiesAdapter extends
             throw new Exception(ERROR_INVALID_ENTRY);
         
         if (object.getUpdated() == null) {
-            object.setUpdated(new Date());
+            object.setUpdatedNow();
         }
         addEditLinkToObject(object);
         storeObject((String)entryId, object);

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java Wed Oct 19 22:33:04 2011
@@ -17,7 +17,6 @@
  */
 package org.apache.abdera2.examples.appclient;
 
-import java.util.Date;
 import java.util.List;
 
 import org.apache.abdera2.Abdera;
@@ -32,6 +31,7 @@ import org.apache.abdera2.protocol.clien
 import org.apache.abdera2.protocol.client.AbderaSession;
 import org.apache.abdera2.protocol.client.Client;
 import org.apache.abdera2.common.iri.IRI;
+import org.joda.time.DateTime;
 
 public class Main {
 
@@ -53,7 +53,7 @@ public class Main {
         Entry entry = factory.newEntry();
         entry.setId("tag:example.org,2006:foo");
         entry.setTitle("This is the title");
-        entry.setUpdated(new Date());
+        entry.setUpdated(DateTime.now());
         entry.addAuthor("James");
         entry.setContent("This is the content");
         report("The Entry to Post", entry.toString());

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java Wed Oct 19 22:33:04 2011
@@ -17,13 +17,14 @@
  */
 package org.apache.abdera2.examples.appserver.employee;
 
-import java.util.Date;
+
+import org.joda.time.DateTime;
 
 // START SNIPPET: employee
 public class Employee {
     private int id;
     private String name;
-    private Date updated;
+    private DateTime updated;
 
     public int getId() {
         return id;
@@ -41,11 +42,11 @@ public class Employee {
         this.name = name;
     }
 
-    public Date getUpdated() {
+    public DateTime getUpdated() {
         return updated;
     }
 
-    public void setUpdated(Date updated) {
+    public void setUpdated(DateTime updated) {
         this.updated = updated;
     }
 }

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java Wed Oct 19 22:33:04 2011
@@ -18,7 +18,6 @@
 package org.apache.abdera2.examples.appserver.employee;
 
 import java.util.Arrays;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +31,7 @@ import org.apache.abdera2.model.Person;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContextException;
 import org.apache.abdera2.protocol.server.impl.AbstractEntityCollectionAdapter;
+import org.joda.time.DateTime;
 
 public class EmployeeCollectionAdapter extends AbstractEntityCollectionAdapter<Employee> {
     private static final String ID_PREFIX = "tag:acme.com,2007:employee:entry:";
@@ -97,7 +97,7 @@ public class EmployeeCollectionAdapter e
         return entry.getName();
     }
 
-    public Date getUpdated(Employee entry) {
+    public DateTime getUpdated(Employee entry) {
         return entry.getUpdated();
     }
 
@@ -118,7 +118,7 @@ public class EmployeeCollectionAdapter e
     public Employee postEntry(String title,
                               IRI id,
                               String summary,
-                              Date updated,
+                              DateTime updated,
                               List<Person> authors,
                               Content content,
                               RequestContext request) throws ResponseContextException {
@@ -132,7 +132,7 @@ public class EmployeeCollectionAdapter e
 
     public void putEntry(Employee employee,
                          String title,
-                         Date updated,
+                         DateTime updated,
                          List<Person> authors,
                          String summary,
                          Content content,

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java Wed Oct 19 22:33:04 2011
@@ -18,7 +18,6 @@
 package org.apache.abdera2.examples.ext;
 
 import org.apache.abdera2.Abdera;
-import org.apache.abdera2.common.geo.Coordinate;
 import org.apache.abdera2.ext.geo.GeoHelper;
 import org.apache.abdera2.common.geo.Point;
 import org.apache.abdera2.common.geo.Position;
@@ -35,7 +34,7 @@ public class Geo {
         Entry entry = abdera.newEntry();
         entry.setTitle("Middle of the Ocean");
 
-        Point point = new Point(new Coordinate(37.0625, -95.677068));
+        Point point = Point.at(37.0625, -95.677068);
         
         // Output position as ISO 6709 standard format
         System.out.println(point.getCoordinate().asIsoPosition());

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DHEnc.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DHEnc.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DHEnc.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DHEnc.java Wed Oct 19 22:33:04 2011
@@ -27,6 +27,7 @@ import org.apache.abdera2.security.Secur
 import org.apache.abdera2.security.Encryption;
 import org.apache.abdera2.security.EncryptionOptions;
 import org.apache.abdera2.security.util.DHContext;
+import org.joda.time.DateTime;
 
 public class DHEnc {
 
@@ -43,7 +44,7 @@ public class DHEnc {
 
         Entry entry = factory.newEntry();
         entry.setId("http://example.org/foo/entry");
-        entry.setUpdated(new java.util.Date());
+        entry.setUpdated(DateTime.now());
         entry.setTitle("This is an entry");
         entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
         entry.addAuthor("James");

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DSig.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DSig.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DSig.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/DSig.java Wed Oct 19 22:33:04 2011
@@ -31,6 +31,7 @@ import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.security.Security;
 import org.apache.abdera2.security.Signature;
 import org.apache.abdera2.security.SignatureOptions;
+import org.joda.time.DateTime;
 
 public class DSig {
 
@@ -57,7 +58,7 @@ public class DSig {
 
         Entry entry = factory.newEntry();
         entry.setId("http://example.org/foo/entry");
-        entry.setUpdated(new java.util.Date());
+        entry.setUpdated(DateTime.now());
         entry.setTitle("This is an entry");
         entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
         entry.addAuthor("James");

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/Enc.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/Enc.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/Enc.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/security/Enc.java Wed Oct 19 22:33:04 2011
@@ -28,6 +28,7 @@ import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.security.Security;
 import org.apache.abdera2.security.Encryption;
 import org.apache.abdera2.security.EncryptionOptions;
+import org.joda.time.DateTime;
 
 public class Enc {
 
@@ -49,7 +50,7 @@ public class Enc {
 
         Entry entry = factory.newEntry();
         entry.setId("http://example.org/foo/entry");
-        entry.setUpdated(new java.util.Date());
+        entry.setUpdated(DateTime.now());
         entry.setTitle("This is an entry");
         entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
         entry.addAuthor("James");

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Create.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Create.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Create.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Create.java Wed Oct 19 22:33:04 2011
@@ -18,7 +18,6 @@
 package org.apache.abdera2.examples.simple;
 
 import java.net.URL;
-import java.util.Date;
 
 import javax.activation.DataHandler;
 import javax.activation.URLDataSource;
@@ -29,6 +28,7 @@ import org.apache.abdera2.model.Content;
 import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.common.iri.IRI;
+import org.joda.time.DateTime;
 
 public class Create {
 
@@ -41,7 +41,7 @@ public class Create {
 
         feed.setTitle("Example Feed");
         feed.addLink("http://example.org/");
-        feed.setUpdated(new Date());
+        feed.setUpdated(DateTime.now());
         feed.addAuthor("John Doe");
         feed.setId("urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
         feed.addContributor("Bob Jones");
@@ -52,7 +52,7 @@ public class Create {
         entry.setTitle("Atom-Powered Robots Run Amok");
         entry.addLink("http://example.org/2003/12/13/atom03");
         entry.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a");
-        entry.setUpdated(new Date());
+        entry.setUpdated(DateTime.now());
         entry.setSummary("Some text.");
 
         // Creates an entry and inserts it at the beginning of the list
@@ -60,7 +60,7 @@ public class Create {
         entry2.setTitle("re: Atom-Powered Robots Run Amok");
         entry2.addLink("/2003/12/13/atom03/1");
         entry2.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5b");
-        entry2.setUpdated(new Date());
+        entry2.setUpdated(DateTime.now());
         entry2.setSummary("A response");
 
         // Creates an entry and appends it to the end of the list
@@ -69,7 +69,7 @@ public class Create {
         entry3.addLink("/2003/12/13/atom03/2");
         entry3.setId("HTTP://www.Example.org/foo/../bar", true); // normalizes the id to the value
                                                                  // http://www.example.org/bar
-        entry3.setUpdated(new Date());
+        entry3.setUpdated(DateTime.now());
         entry3.setSummaryAsHtml("<p><a href=\"foo\">Test</a></p>").setBaseUri("http://example.org/site/");
         entry3.setSource(feed.getAsSource());
 
@@ -78,7 +78,7 @@ public class Create {
         entry4.setTitle("re: Atom-Powered Robots Run Amok");
         entry4.addLink("/2003/12/13/atom03/3");
         entry4.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-cafebabecafe");
-        entry4.setUpdated(new Date());
+        entry4.setUpdated(DateTime.now());
         entry4.setSummary("An entry with out-of-line content");
         entry4.setContent(new IRI("http://example.org/0xcafebabe"), "text/html");
 
@@ -87,7 +87,7 @@ public class Create {
         entry5.setTitle("re: Atom-Powered Robots Run Amok");
         entry5.addLink("/2003/12/13/atom03/4");
         entry5.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5c");
-        entry5.setUpdated(new Date());
+        entry5.setUpdated(DateTime.now());
         entry5.setSummary("A simple Base64 encoded binary image");
         URL url = Create.class.getResource("/atom-logo75px.gif");
         entry5.setContent(new DataHandler(new URLDataSource(url)), "image/gif");
@@ -97,7 +97,7 @@ public class Create {
         entry6.setTitle("re: Atom-Powered Robots Run Amok");
         entry6.addLink("/2003/12/13/atom03/5");
         entry6.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5d");
-        entry6.setUpdated(new Date());
+        entry6.setUpdated(DateTime.now());
         entry6.setSummary("XML content");
         entry6.setContent("<a xmlns='urn:foo'><b/></a>", Content.Type.XML);
 

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Parse.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Parse.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Parse.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/Parse.java Wed Oct 19 22:33:04 2011
@@ -18,12 +18,21 @@
 package org.apache.abdera2.examples.simple;
 
 import java.io.InputStream;
+import java.util.List;
 
 import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.model.selector.Selectors;
 import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.parser.Parsers;
+import org.apache.abdera2.writer.Writers;
+import org.apache.abdera2.writer.Writers.WriterFunction;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
 
 public class Parse {
 
@@ -52,7 +61,27 @@ public class Parse {
         System.out.println(entry.getUpdated());
         System.out.println(entry.getSummary());
         System.out.println(entry.getSummaryType());
-
+        
+        // Selectors can be used to filter out unwanted entries
+        List<Entry> entries = 
+          feed.getEntries(
+            Selectors.updated(
+              DateTimes.afterNow()));
+        System.out.println(entries);
+        
+
+        // We can also use the Guava (com.google.common.*) Function interface
+        in = Parse.class.getResourceAsStream("/simple.xml");
+        Function<InputStream,Document<Feed>> pf = 
+          Parsers.forInputStream();
+        doc = pf.apply(in);
+        
+        // Which means we can chain things together in interesting ways...
+        in = Parse.class.getResourceAsStream("/simple.xml");
+        pf = Parsers.forInputStream();
+        WriterFunction wf = Writers.forOutputStream("activity", System.out);
+        Function<InputStream,Void> f = Functions.compose(wf, pf);
+        f.apply(in);
     }
 
 }

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java Wed Oct 19 22:33:04 2011
@@ -26,7 +26,7 @@ import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.Parser;
 import org.apache.abdera2.parser.ParserOptions;
-import org.apache.abdera2.parser.filter.SetParseFilter;
+import org.apache.abdera2.parser.filter.ParseFilter;
 import org.apache.abdera2.parser.filter.WhiteListParseFilter;
 import org.apache.abdera2.common.Constants;
 
@@ -45,10 +45,13 @@ public class PrintTitles {
 
         ParserOptions opts = parser.getDefaultParserOptions();
 
-        SetParseFilter filter = new WhiteListParseFilter();
-        filter.add(Constants.FEED);  // we only want entry titles, 
-        filter.add(Constants.ENTRY); // but we have to include
-        filter.add(Constants.TITLE); // the parent elements too
+        ParseFilter filter = 
+          WhiteListParseFilter
+            .make()
+            .add(Constants.FEED)
+            .add(Constants.ENTRY)
+            .add(Constants.TITLE)
+            .get();
         opts.setParseFilter(filter);
 
         Document<Feed> doc;
@@ -62,10 +65,11 @@ public class PrintTitles {
 
         Feed feed = doc.getRoot();
 
-        List<Entry> entries = feed.getEntries();
+        List<Entry> entries = 
+          feed.getEntries();
 
-        for (Entry e : entries) {
-            System.out.println(e.getTitle());
-        }
+        for (Entry e : entries)
+          System.out.println(
+            e.getTitle());
     }
 }

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamBuilderExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamBuilderExample.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamBuilderExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamBuilderExample.java Wed Oct 19 22:33:04 2011
@@ -17,8 +17,6 @@
  */
 package org.apache.abdera2.examples.simple;
 
-import java.util.Date;
-
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.factory.StreamBuilder;
 import org.apache.abdera2.model.Document;
@@ -39,17 +37,17 @@ public class StreamBuilderExample {
             .writeId("http://example.org").writeTitle("<Testing 123>").writeSubtitle("Foo").writeAuthor("James",
                                                                                                         null,
                                                                                                         null)
-            .writeUpdated(new Date()).writeLink("http://example.org/foo").writeLink("http://example.org/bar", "self")
+            .writeUpdatedNow().writeLink("http://example.org/foo").writeLink("http://example.org/bar", "self")
             .writeCategory("foo").writeCategory("bar").writeLogo("logo").writeIcon("icon")
             .writeGenerator("1.0", "http://example.org", "foo");
 
         for (int n = 0; n < 100; n++) {
-            out.startEntry().writeId("http://example.org/" + n).writeTitle("Entry #" + n).writeUpdated(new Date())
-                .writePublished(new Date()).writeEdited(new Date()).writeSummary("This is text summary")
+            out.startEntry().writeId("http://example.org/" + n).writeTitle("Entry #" + n).writeUpdatedNow()
+                .writePublishedNow().writeEditedNow().writeSummary("This is text summary")
                 .writeAuthor("James", null, null).writeContributor("Joe", null, null).startContent("application/xml")
                 .startElement("a", "b", "c").startElement("x", "y", "z").writeElementText("This is a test")
                 .startElement("a").writeElementText("foo").endElement().startElement("b", "bar")
-                .writeAttribute("foo", new Date()).writeAttribute("bar", 123L).writeElementText(123.123).endElement()
+                .writeAttributeNow("foo").writeAttribute("bar", 123L).writeElementText(123.123).endElement()
                 .endElement().endElement().endContent().endEntry();
         }
 

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamWriterExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamWriterExample.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamWriterExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/StreamWriterExample.java Wed Oct 19 22:33:04 2011
@@ -17,8 +17,6 @@
  */
 package org.apache.abdera2.examples.simple;
 
-import java.util.Date;
-
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.writer.StreamWriter;
 
@@ -37,19 +35,19 @@ public class StreamWriterExample {
                 .writeId("http://example.org").writeTitle("<Testing 123>").writeSubtitle("Foo").writeAuthor("James",
                                                                                                             null,
                                                                                                             null)
-                .writeUpdated(new Date()).writeLink("http://example.org/foo").writeLink("http://example.org/bar",
+                .writeUpdatedNow().writeLink("http://example.org/foo").writeLink("http://example.org/bar",
                                                                                         "self").writeCategory("foo")
                 .writeCategory("bar").writeLogo("logo").writeIcon("icon").writeGenerator("1.0",
                                                                                          "http://example.org",
                                                                                          "foo").flush();
 
         for (int n = 0; n < 100; n++) {
-            out.startEntry().writeId("http://example.org/" + n).writeTitle("Entry #" + n).writeUpdated(new Date())
-                .writePublished(new Date()).writeEdited(new Date()).writeSummary("This is text summary")
+            out.startEntry().writeId("http://example.org/" + n).writeTitle("Entry #" + n).writeUpdatedNow()
+                .writePublishedNow().writeEditedNow().writeSummary("This is text summary")
                 .writeAuthor("James", null, null).writeContributor("Joe", null, null).startContent("application/xml")
                 .startElement("a", "b", "c").startElement("x", "y", "z").writeElementText("This is a test")
                 .startElement("a").writeElementText("foo").endElement().startElement("b", "bar")
-                .writeAttribute("foo", new Date()).writeAttribute("bar", 123L).writeElementText(123.123).endElement()
+                .writeAttributeNow("foo").writeAttribute("bar", 123L).writeElementText(123.123).endElement()
                 .endElement().endElement().endContent().endEntry().flush();
         }
 

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java Wed Oct 19 22:33:04 2011
@@ -25,7 +25,7 @@ import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.Parser;
 import org.apache.abdera2.parser.ParserOptions;
 import org.apache.abdera2.parser.filter.BlackListParseFilter;
-import org.apache.abdera2.parser.filter.SetParseFilter;
+import org.apache.abdera2.parser.filter.ParseFilter;
 
 public class UnacceptableElementsExample {
 
@@ -33,33 +33,20 @@ public class UnacceptableElementsExample
 
         Parser parser = Abdera.getInstance().getParser();
 
-        /**
-         * By subclassing BlackListParseFilter, we can throw an error when 
-         * the parsed XML contains any content we don't want
-         */
-        SetParseFilter exceptionFilter = new BlackListParseFilter() {
-            private static final long serialVersionUID = 7564587859561916928L;
-
-            @Override
-            public boolean acceptable(QName qname) {
-                boolean answer = super.acceptable(qname);
-                if (!(answer)) {
-                    throw new RuntimeException("Unacceptable element ::" + qname);
-                }
-                return answer;
-            }
-
-            @Override
-            public boolean acceptable(QName qname, QName attribute) {
-                return true;
-            }
-        };
-        exceptionFilter.add(new QName("http://example.org", "a"));
-
+        ParseFilter exceptionFilter =
+          BlackListParseFilter
+            .make()
+            .add(new QName("http://example.org", "a"))
+            .throwOnUnacceptable()
+            .get();
+        
         ParserOptions options = parser.getDefaultParserOptions();
         options.setParseFilter(exceptionFilter);
         Document<Feed> doc =
-            parser.parse(UnacceptableElementsExample.class.getResourceAsStream("/xmlcontent.xml"), null, options);
+            parser.parse(
+              UnacceptableElementsExample.class.getResourceAsStream("/xmlcontent.xml"), 
+              null, 
+              options);
 
         // this will throw a FOMException
         doc.writeTo(System.out);

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/i18nExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/i18nExample.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/i18nExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/i18nExample.java Wed Oct 19 22:33:04 2011
@@ -17,14 +17,13 @@
  */
 package org.apache.abdera2.examples.simple;
 
-import java.util.Date;
-
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.ext.bidi.BidiHelper;
 import org.apache.abdera2.ext.bidi.BidiHelper.Direction;
 import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
+import org.joda.time.DateTime;
 
 /**
  * Simple example demonstrating Abdera's i18n support
@@ -43,7 +42,7 @@ public class i18nExample {
 
         feed.setBaseUri("http://\u0645\u062b\u0627\u0644.org/ar/feed.xml");
         feed.setId("tag:\u0645\u062b\u0627\u0644.org,2007:/\u0645\u062b\u0627\u0644");
-        feed.setUpdated(new Date());
+        feed.setUpdated(DateTime.now());
         feed
             .setTitle("\u0645\u062b\u0644\u0627\u0020\u0627\u0644\u0646\u0635\u0020\u0627\u0644\u0639\u0631\u0628\u064a");
         feed.addAuthor("\u062c\u064a\u0645\u0633");
@@ -53,7 +52,7 @@ public class i18nExample {
         Entry entry = feed.addEntry();
         entry.setId("tag:\u0645\u062b\u0627\u0644.org,2007:/\u0645\u062b\u0627\u0644/1");
         entry.setTitle("\u0645\u062b\u0627\u0644\u0020\u062f\u062e\u0648\u0644");
-        entry.setUpdated(new Date());
+        entry.setUpdated(DateTime.now());
         entry.addLink("http://\u0645\u062b\u0627\u0644.org/ar/blog/1");
         entry
             .setSummaryAsXhtml("<p xml:lang=\"ar\" dir=\"rtl\">\u0648\u0647\u0630\u0627\u0020\u0645\u062b\u0627\u0644\u0020\u0639\u0644\u0649\u0020\u0648\u062c\u0648\u062f\u0020\u0041\u0074\u006f\u006d\u0020\u0031\u002e\u0030\u0020\u0052\u0054\u004c\u0020\u0627\u0644\u0627\u0639\u0644\u0627\u0641\u0020\u0627\u0644\u062a\u064a\u0020\u062a\u062d\u062a\u0648\u064a\u0020\u0639\u0644\u0649\u0020\u0627\u0644\u0646\u0635\u0020\u0627\u0644\u0639\u0631\u0628\u064a</p>");

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/uritemplates/TemplateManagerExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/uritemplates/TemplateManagerExample.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/uritemplates/TemplateManagerExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/uritemplates/TemplateManagerExample.java Wed Oct 19 22:33:04 2011
@@ -19,10 +19,12 @@ public class TemplateManagerExample {
     defaults.put("a", "foo");
     defaults.put("b", "bar");
     
-    TemplateManager<Keys> tm = new TemplateManager<Keys>(defaults);
-    
-    tm.add(Keys.A, "http://example.org{?a}");
-    tm.add(Keys.B, "https://example.org{?b}");
+    TemplateManager<Keys> tm = 
+      TemplateManager.<Keys>make()
+        .withDefaults(defaults)
+        .add(Keys.A, "http://example.org{?a}")
+        .add(Keys.B, "https://example.org{?b}")
+        .get();
     
     System.out.println("Template for Keys.A using Default Context: " + tm.expand(Keys.A));
     System.out.println("Template for Keys.B using Default Context: " + tm.expand(Keys.B));

Added: abdera/abdera2/ext/.classpath
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/.classpath?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/ext/.classpath (added)
+++ abdera/abdera2/ext/.classpath Wed Oct 19 22:33:04 2011
@@ -0,0 +1,29 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="target/maven-shared-archive-resources" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="src" path="/abdera2-activities"/>
+  <classpathentry kind="src" path="/abdera2-client"/>
+  <classpathentry kind="src" path="/abdera2-common"/>
+  <classpathentry kind="src" path="/abdera2-core"/>
+  <classpathentry kind="src" path="/abdera2-server"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ws/commons/axiom/axiom-api/1.2.12/axiom-api-1.2.12.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ws/commons/axiom/axiom-impl/1.2.12/axiom-impl-1.2.12.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.5/commons-codec-1.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.1/geronimo-activation_1.1_spec-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.6/geronimo-javamail_1.4_spec-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/1.7.1/gson-1.7.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/nu/validator/htmlparser/htmlparser/1.2.1/htmlparser-1.2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.1.2/httpclient-4.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient-cache/4.1.2/httpclient-cache-4.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.1.2/httpcore-4.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpmime/4.1.2/httpmime-4.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/ibm/icu/icu4j/4.8.1.1/icu4j-4.8.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/javaee-web-api/6.0/javaee-web-api-6.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6.jar"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+</classpath>
\ No newline at end of file

Propchange: abdera/abdera2/ext/.classpath
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/ext/.project
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/.project?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/ext/.project (added)
+++ abdera/abdera2/ext/.project Wed Oct 19 22:33:04 2011
@@ -0,0 +1,19 @@
+<projectDescription>
+  <name>abdera2-ext</name>
+  <comment>Atom Publishing Protocol Client Implementation. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+  <projects>
+    <project>abdera2-activities</project>
+    <project>abdera2-client</project>
+    <project>abdera2-common</project>
+    <project>abdera2-core</project>
+    <project>abdera2-server</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Propchange: abdera/abdera2/ext/.project
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/ext/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/.settings/org.eclipse.jdt.core.prefs?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/ext/.settings/org.eclipse.jdt.core.prefs (added)
+++ abdera/abdera2/ext/.settings/org.eclipse.jdt.core.prefs Wed Oct 19 22:33:04 2011
@@ -0,0 +1,5 @@
+#Thu Sep 29 16:38:20 PDT 2011
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6

Propchange: abdera/abdera2/ext/.settings/org.eclipse.jdt.core.prefs
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedConverter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedConverter.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedConverter.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedConverter.java Wed Oct 19 22:33:04 2011
@@ -1,7 +1,5 @@
 package org.apache.abdera2.ext.activities;
 
-import java.util.Date;
-
 import javax.xml.namespace.QName;
 
 import org.apache.abdera2.activities.model.ASObject;
@@ -10,6 +8,7 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.common.xml.XMLVersion;
 import org.apache.abdera2.model.Text;
 import org.apache.abdera2.writer.StreamWriter;
+import org.joda.time.DateTime;
 
 public class ActivityToFeedConverter {
 
@@ -117,7 +116,7 @@ public class ActivityToFeedConverter {
     StreamWriter writer) {
     id(stream,writer);
     title(stream,writer);
-    Date updated = stream.getUpdated();
+    DateTime updated = stream.getUpdated();
     if (updated != null) 
       writer.writeUpdated(updated);    
   }
@@ -138,10 +137,10 @@ public class ActivityToFeedConverter {
       summary(activity,writer);
       if (activity.getUpdated() != null)
         writer.writeUpdated(activity.getUpdated());
-      else writer.writeUpdated(new Date());
+      else writer.writeUpdated(DateTime.now());
       if (activity.getPublished() != null)
         writer.writePublished(activity.getPublished());
-      else writer.writePublished(new Date());
+      else writer.writePublished(DateTime.now());
       if (activity.getUrl() != null)
         writer.writeLink(activity.getUrl().toString());
       actor(activity,writer);

Added: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java (added)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java Wed Oct 19 22:33:04 2011
@@ -0,0 +1,83 @@
+package org.apache.abdera2.ext.activities;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Reader;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.activities.model.ASBase;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.parser.AbstractParser;
+import org.apache.abdera2.parser.AbstractParserOptions;
+import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.parser.ParserOptions;
+import org.apache.abdera2.writer.StreamWriter;
+import static com.google.common.base.Preconditions.*;
+
+@Name("activity")
+public class ActivityToFeedParser 
+  extends AbstractParser {
+
+  private static final ActivityToFeedConverter a2fc = 
+    new ActivityToFeedConverter();
+
+  private final IO io;
+  
+  public ActivityToFeedParser() {
+    this(null);
+  }
+
+  public ActivityToFeedParser(Abdera abdera) {
+    super(abdera);
+    io = IO.get();
+  }
+
+  protected ParserOptions initDefaultParserOptions() {
+    return new AbstractParserOptions() {
+      protected void initFactory() {}
+      protected void checkFactory(Factory factory) {}
+    };
+  }
+  
+  @SuppressWarnings("unchecked")
+  public <T extends Element> Document<T> parse(
+    Reader in, 
+    String base,
+    ParserOptions options) 
+      throws ParseException {
+    
+    // first, we read it in as an activity stream thingy
+    ASBase as = io.read(in);
+    checkNotNull(as);
+    checkArgument(as instanceof Collection || as instanceof Activity);
+    StreamWriter sw = abdera.create(StreamWriter.class);
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    sw.setAutoclose(true)
+      .setOutputStream(out,"UTF-8");
+    if (as instanceof Collection) {
+      a2fc.convert((Collection<Activity>)as,sw);
+    } else {
+      a2fc.convert((Activity)as,sw);
+    }
+    ByteArrayInputStream input = 
+      new ByteArrayInputStream(out.toByteArray());
+    return abdera.getParser().parse(input);
+  }
+
+  public <T extends Element> Document<T> parse(
+    XMLStreamReader reader,
+    String base, 
+    ParserOptions options) 
+      throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+}

Propchange: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityConverter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityConverter.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityConverter.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityConverter.java Wed Oct 19 22:33:04 2011
@@ -51,6 +51,7 @@ public class FeedToActivityConverter {
     return item(entry);
   }
   
+  @SuppressWarnings("rawtypes")
   public void convert(
     Feed feed, 
     CollectionWriter writer, 
@@ -105,9 +106,12 @@ public class FeedToActivityConverter {
   
   protected Activity item(Entry entry) {
     Activity activity = new Activity();
-    activity.setId(entry.getId().toString());
-    activity.setUpdated(entry.getUpdated());
-    activity.setPublished(entry.getPublished());
+    if (entry.getId() != null)
+      activity.setId(entry.getId().toString());
+    if (entry.getUpdated() != null)
+      activity.setUpdated(entry.getUpdated());
+    if (entry.getPublished() != null)
+      activity.setPublished(entry.getPublished());
     activity.setUrl(entry.getAlternateLinkResolvedHref());
     activity.setTitle(entry.getTitle());
     activity.setSummary(entry.getSummary());

Added: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityWriter.java?rev=1186541&view=auto
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityWriter.java (added)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityWriter.java Wed Oct 19 22:33:04 2011
@@ -0,0 +1,104 @@
+package org.apache.abdera2.ext.activities;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.activities.model.CollectionWriter;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.model.Base;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.writer.AbstractWriter;
+import org.apache.abdera2.writer.AbstractWriterOptions;
+import org.apache.abdera2.writer.Writer;
+import org.apache.abdera2.writer.WriterOptions;
+import static com.google.common.base.Preconditions.*;
+
+@Name("activity")
+public class FeedToActivityWriter 
+  extends AbstractWriter 
+  implements Writer {
+
+  private static final FeedToActivityConverter f2ac = 
+    new FeedToActivityConverter();
+
+  public FeedToActivityWriter(Abdera abdera) {
+    super(
+      "application/json", 
+      "application/javascript", 
+      "application/ecmascript", 
+      "text/javascript", 
+      "text/ecmascript");
+  }
+  
+  public void writeTo(
+    Base base, 
+    OutputStream out, 
+    WriterOptions options)
+      throws IOException {
+    checkNotNull(base);
+    checkNotNull(out);
+    checkNotNull(options);
+    if (base instanceof Document) {
+      base = ((Document<?>)base).getRoot();
+      checkNotNull(base);
+    }
+    checkArgument(base instanceof Feed || base instanceof Entry);
+    if (options.getCompressionCodecs() != null && 
+        options.getCompressionCodecs().length > 0) 
+      out = Compression.wrap(out, options.getCompressionCodecs());
+    if (base instanceof Entry) {
+       f2ac.convert((Entry)base).writeTo(out,options.getCharset());
+    } else if (base instanceof Feed) {
+      CollectionWriter cw = 
+        IO.get().getCollectionWriter(
+          out,options.getCharset());
+      f2ac.convert((Feed)base, cw);
+    }
+    if (options.getAutoClose())
+      out.close();
+  }
+
+  public void writeTo(
+    Base base, 
+    java.io.Writer out, 
+    WriterOptions options)
+      throws IOException {
+    checkNotNull(base);
+    checkNotNull(out);
+    checkNotNull(options);
+    checkArgument(base instanceof Feed || base instanceof Entry);
+    if (base instanceof Entry) {
+       f2ac.convert((Entry)base).writeTo(out);
+    } else if (base instanceof Feed) {
+      CollectionWriter cw = 
+        IO.get().getCollectionWriter(out);
+      f2ac.convert((Feed)base, cw);
+    }
+    if (options.getAutoClose())
+      out.close();
+  }
+
+  public Object write(Base base, WriterOptions options) throws IOException {
+    try {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        writeTo(base, out, options);
+        return new String(out.toByteArray(), options.getCharset());
+    } catch (IOException i) {
+        throw i;
+    } catch (Exception e) {
+        throw new IOException(e.getMessage());
+    }
+  }
+
+  protected WriterOptions initDefaultWriterOptions() {
+    return new AbstractWriterOptions() {
+    };
+  }
+
+}

Propchange: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/FeedToActivityWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java Wed Oct 19 22:33:04 2011
@@ -20,11 +20,15 @@ package org.apache.abdera2.ext.features;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
+import org.apache.abdera2.common.selector.AbstractSelector;
 import org.apache.abdera2.common.selector.Selector;
 import org.apache.abdera2.ext.features.FeaturesHelper.Status;
 import org.apache.abdera2.model.Collection;
 
-public class FeatureSelector implements Selector {
+@SuppressWarnings("rawtypes")
+public class FeatureSelector 
+extends AbstractSelector
+implements Selector {
 
     private static final long serialVersionUID = -8943638085557912175L;
     private final Set<String> features = new LinkedHashSet<String>();

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java Wed Oct 19 22:33:04 2011
@@ -37,6 +37,7 @@ import org.apache.abdera2.protocol.clien
  * Implementation of the current APP Features Draft
  * (http://www.ietf.org/internet-drafts/draft-snell-atompub-feature-08.txt)
  */
+@SuppressWarnings({ "unchecked", "rawtypes" })
 public final class FeaturesHelper {
 
     public enum Status {

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/geo/GeoHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/geo/GeoHelper.java?rev=1186541&r1=1186540&r2=1186541&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/geo/GeoHelper.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/geo/GeoHelper.java Wed Oct 19 22:33:04 2011
@@ -104,6 +104,16 @@ public class GeoHelper {
         }
     }
 
+    public static String toString(Multiple multiple) {
+      StringBuffer buf = new StringBuffer();
+      for (Coordinate coord : multiple) {
+          if (buf.length() > 0)
+              buf.append(" ");
+          buf.append(coord);
+      }
+      return buf.toString();
+    }
+    
     private static void addGmlPosition(ExtensibleElement element, Position position) {
         ExtensibleElement pos = element.addExtension(QNAME_WHERE);
         if (position instanceof Point) {
@@ -113,13 +123,13 @@ public class GeoHelper {
         } else if (position instanceof Line) {
             Multiple m = (Multiple)position;
             ExtensibleElement p = pos.addExtension(QNAME_GML_LINESTRING);
-            p.addSimpleExtension(QNAME_GML_POSLIST, m.getCoordinates().toString());
+            p.addSimpleExtension(QNAME_GML_POSLIST, toString(m));
         } else if (position instanceof Polygon) {
             Multiple m = (Multiple)position;
             ExtensibleElement p = pos.addExtension(QNAME_GML_POLYGON);
             p = p.addExtension(QNAME_GML_EXTERIOR);
             p = p.addExtension(QNAME_GML_LINEARRING);
-            p.addSimpleExtension(QNAME_GML_POSLIST, m.getCoordinates().toString());
+            p.addSimpleExtension(QNAME_GML_POSLIST, toString(m));
         } else if (position instanceof Box) {
             Box m = (Box)position;
             ExtensibleElement p = pos.addExtension(QNAME_GML_ENVELOPE);
@@ -142,7 +152,7 @@ public class GeoHelper {
                 position instanceof Line ? QNAME_SIMPLE_LINE : position instanceof Box ? QNAME_SIMPLE_BOX
                     : position instanceof Polygon ? QNAME_SIMPLE_POLYGON : null;
             if (qname != null) {
-                pos = element.addSimpleExtension(qname, line.getCoordinates().toString());
+                pos = element.addSimpleExtension(qname, toString(line));
             }
         }
         setPositionAttributes(pos, position);
@@ -202,17 +212,17 @@ public class GeoHelper {
         if (qname.equals(QNAME_GML_POINT)) {
             element = traverse((ExtensibleElement)element, QNAME_GML_POS);
             if (element != null && text != null) {
-                pos = new Point(text.trim());
+              pos = GeoHelper.<Point.Builder>getPositionAttributes(element,Point.make(text.trim())).get();
             }
         } else if (qname.equals(QNAME_GML_LINESTRING)) {
             element = traverse((ExtensibleElement)element, QNAME_GML_POSLIST);
             if (element != null && text != null) {
-                pos = new Line(text.trim());
+              pos = GeoHelper.<Line.Builder>getPositionAttributes(element,Line.make(Multiple.parse(text.trim()))).get();
             }
         } else if (qname.equals(QNAME_GML_POLYGON)) {
             element = traverse((ExtensibleElement)element, QNAME_GML_EXTERIOR, QNAME_GML_LINEARRING, QNAME_GML_POSLIST);
             if (element != null && text != null) {
-                pos = new Polygon(text.trim());
+                pos = GeoHelper.<Polygon.Builder>getPositionAttributes(element,Polygon.make(Multiple.parse(text.trim()))).get();
             }
         } else if (qname.equals(QNAME_GML_ENVELOPE)) {
             String lc = ((ExtensibleElement)element).getSimpleExtension(QNAME_GML_LOWERCORNER);
@@ -220,16 +230,16 @@ public class GeoHelper {
             if (lc != null && uc != null) {
                 Coordinate c1 = new Coordinate(lc);
                 Coordinate c2 = new Coordinate(uc);
-                pos = new Box(c1, c2);
+                pos = GeoHelper.<Box.Builder>getPositionAttributes(element,Box.make(c1,c2)).get();
             }
         } else if (qname.equals(QNAME_SIMPLE_POINT) && text != null) {
-            pos = new Point(text.trim());
+            pos = GeoHelper.<Point.Builder>getPositionAttributes(element,Point.make(text.trim())).get();
         } else if (qname.equals(QNAME_SIMPLE_LINE) && text != null) {
-            pos = new Line(text.trim());
+            pos = GeoHelper.<Line.Builder>getPositionAttributes(element,Line.make(Multiple.parse(text.trim()))).get();
         } else if (qname.equals(QNAME_SIMPLE_BOX) && text != null) {
-            pos = new Box(text.trim());
+            pos = GeoHelper.<Box.Builder>getPositionAttributes(element,Box.make(Multiple.parse(text.trim()))).get();
         } else if (qname.equals(QNAME_SIMPLE_POLYGON) && text != null) {
-            pos = new Polygon(text.trim());
+            pos = GeoHelper.<Polygon.Builder>getPositionAttributes(element,Polygon.make(Multiple.parse(text.trim()))).get();
         } else if (qname.equals(QNAME_W3C_POINT) || qname.equals(Constants.ENTRY)) {
             Set<Position> list = new LinkedHashSet<Position>();
             getW3CPosition((ExtensibleElement)element, list);
@@ -249,10 +259,7 @@ public class GeoHelper {
         Iterable<Element> elements = element.getExtensions(SIMPLE_GEO_NS);
         for (Element el : elements) {
             Position pos = getAsPosition(el);
-            if (pos != null) {
-                getPositionAttributes(el, pos);
-                list.add(pos);
-            }
+            list.add(pos);
         }
     }
 
@@ -263,14 +270,32 @@ public class GeoHelper {
             List<ExtensibleElement> children = where.getElements();
             for (ExtensibleElement el : children) {
                 pos = getAsPosition(el);
-                if (pos != null) {
-                    getPositionAttributes(el, pos);
-                    list.add(pos);
-                }
+                list.add(pos);
             }
         }
     }
 
+    private static <X extends Position.Builder<?>>X getPositionAttributes(Element pos, X builder) {
+      if (builder != null) {
+          String featuretypetag = pos.getAttributeValue("featuretypetag");
+          String relationshiptag = pos.getAttributeValue("relationshiptag");
+          String elevation = pos.getAttributeValue("elev");
+          String floor = pos.getAttributeValue("floor");
+          String radius = pos.getAttributeValue("radius");
+          if (featuretypetag != null)
+              builder.featureType(featuretypetag);
+          if (featuretypetag != null)
+            builder.relationship(relationshiptag);
+          if (elevation != null)
+            builder.elevation(Double.valueOf(elevation));
+          if (floor != null)
+            builder.floor(Double.valueOf(floor));
+          if (radius != null)
+            builder.radius(Double.valueOf(radius));
+      }
+      return builder;
+  }
+    
     private static ExtensibleElement traverse(ExtensibleElement element, QName... qnames) {
         for (QName qname : qnames) {
             element = element.getExtension(qname);
@@ -280,26 +305,6 @@ public class GeoHelper {
         return element;
     }
 
-    private static void getPositionAttributes(Element pos, Position position) {
-        if (position != null) {
-            String featuretypetag = pos.getAttributeValue("featuretypetag");
-            String relationshiptag = pos.getAttributeValue("relationshiptag");
-            String elevation = pos.getAttributeValue("elev");
-            String floor = pos.getAttributeValue("floor");
-            String radius = pos.getAttributeValue("radius");
-            if (featuretypetag != null)
-                position.setFeatureTypeTag(featuretypetag);
-            if (featuretypetag != null)
-                position.setRelationshipTag(relationshiptag);
-            if (elevation != null)
-                position.setElevation(Double.valueOf(elevation));
-            if (floor != null)
-                position.setFloor(Double.valueOf(floor));
-            if (radius != null)
-                position.setRadius(Double.valueOf(radius));
-        }
-    }
-
     private static void getW3CPosition(ExtensibleElement element, Set<Position> list) {
         getSimpleW3CPosition(element, list);
         List<ExtensibleElement> points = element.getExtensions(QNAME_W3C_POINT);
@@ -310,9 +315,7 @@ public class GeoHelper {
     private static void getSimpleW3CPosition(ExtensibleElement el, Set<Position> list) {
         String slat = el.getSimpleExtension(QNAME_W3C_LAT);
         String slong = el.getSimpleExtension(QNAME_W3C_LONG);
-        if (slat != null && slong != null) {
-            Point point = new Point(slat.trim() + " " + slong.trim());
-            list.add(point);
-        }
+        if (slat != null && slong != null)
+            list.add(Point.at(slat.trim() + " " + slong.trim()));
     }
 }



Mime
View raw message