abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r533421 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ core/src/main/java/org/apache/abdera/util/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Sat, 28 Apr 2007 19:49:43 GMT
Author: jmsnell
Date: Sat Apr 28 12:49:42 2007
New Revision: 533421

URL: http://svn.apache.org/viewvc?view=rev&rev=533421
Log:
 * acceptsNothing utility method on the Collection class
 * method to get a PI from a document.
 * cache a parsed AtomDate in FOMDateTime rather than recreating it on every call
 * do not declare the default namespace in parent elements
 * allow null prefix to be passed in to addExtension(namespace,localpart,prefix)

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/AtomDate.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Document.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/AtomDate.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/AtomDate.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/AtomDate.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/AtomDate.java Sat
Apr 28 12:49:42 2007
@@ -28,6 +28,8 @@
  * <p>Provides an implementation of the Atom Date Construct, 
  * which is itself a specialization of the RFC3339 date-time.</p>
  * 
+ * <p>Accessors on this class are not synchronized.</p>
+ * 
  * <p>Per RFC4287:</p>
  * 
  * <pre>

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
Sat Apr 28 12:49:42 2007
@@ -124,10 +124,15 @@
   boolean accepts(String mediaType);
   
   /**
-   * Returns true if the collections accepts Atom entry documents 
+   * Returns true if the collection accepts Atom entry documents 
    * (equivalent to calling accepts("application/atom+xml;type=entry");)
    */
   boolean acceptsEntry();
+  
+  /**
+   * Returns true if the collection accepts nothing (i.e. there is an empty accept element)
+   */
+  boolean acceptsNothing();
   
   /**
    * Sets the appropriate accept element to indicate that entries are accepted

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Document.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Document.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Document.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Document.java Sat
Apr 28 12:49:42 2007
@@ -112,6 +112,11 @@
   void addProcessingInstruction(String target, String value);
   
   /**
+   * Get the values for the given processing instruction
+   */
+  String[] getProcessingInstruction(String target);
+  
+  /**
    * Add a xml-stylesheet processing instruction to the document
    * @param href The href of the stylesheet
    * @param media The media target for this stylesheet or null if none

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
Sat Apr 28 12:49:42 2007
@@ -29,7 +29,8 @@
 import org.apache.abdera.writer.NamedWriter;
 
 /**
- * Provides the basic configuration for the Abdera default implementation.
+ * Provides the basic configuration for the Abdera default implementation.  This
+ * class should not be accessed by applications directly without very good reason.
  */
 public final class AbderaConfiguration 
   implements Constants, Cloneable {

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
Sat Apr 28 12:49:42 2007
@@ -215,6 +215,10 @@
   public boolean acceptsEntry() {
     return accepts("application/atom+xml;type=entry");
   }
+  
+  public boolean acceptsNothing() {
+    return accepts("");
+  }
 
   public boolean accepts(String mediaType) {
     String[] accept = getAccept();

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
Sat Apr 28 12:49:42 2007
@@ -35,6 +35,7 @@
   implements DateTime {
   
   private static final long serialVersionUID = -6611503566172011733L;
+  private AtomDate value;
 
   public FOMDateTime(QName qname) {
     super(qname);
@@ -92,15 +93,17 @@
   }
   
   public AtomDate getValue() {
-    AtomDate value = null;
-    String v = getText();
-    if (v != null) {
-      value = AtomDate.valueOf(v);
+    if (value == null) {
+      String v = getText();
+      if (v != null) {
+        value = AtomDate.valueOf(v);
+      }
     }
     return value;
   }
 
   public void setValue(AtomDate dateTime) {
+    value = null;
     if (dateTime != null)
       setText(dateTime.getValue());
     else 
@@ -108,6 +111,7 @@
   }
 
   public void setDate(Date date) {
+    value = null;
     if (date != null)
       setText(AtomDate.valueOf(date).getValue());
     else 
@@ -115,6 +119,7 @@
   }
 
   public void setCalendar(Calendar date) {
+    value = null;
     if (date != null)
       setText(AtomDate.valueOf(date).getValue());
     else 
@@ -122,10 +127,12 @@
   }
 
   public void setTime(long date) {
+    value = null;
     setText(AtomDate.valueOf(date).getValue());
   }
 
   public void setString(String date) {
+    value = null;
     if (date != null)
       setText(AtomDate.valueOf(date).getValue());
     else 

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
Sat Apr 28 12:49:42 2007
@@ -20,8 +20,10 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.List;
 
 import javax.activation.MimeType;
 import javax.activation.MimeTypeParseException;
@@ -193,6 +195,19 @@
 
   public Factory getFactory() {
     return (Factory) this.factory;
+  }
+  
+  public String[] getProcessingInstruction(String target) {
+    List<String> values = new ArrayList<String>();
+    for (Iterator i = getChildren(); i.hasNext();) {
+      OMNode node = (OMNode) i.next();
+      if (node.getType() == OMNode.PI_NODE) {
+        OMProcessingInstruction pi = (OMProcessingInstruction) node;
+        if (pi.getTarget().equalsIgnoreCase(target))
+          values.add(pi.getValue());
+      }
+    }
+    return values.toArray(new String[values.size()]);
   }
 
   public void addProcessingInstruction(String target, String value) {

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Sat Apr 28 12:49:42 2007
@@ -688,7 +688,7 @@
   }
   
   protected void declareIfNecessary(String ns, String prefix) {
-    if (prefix != null && !isDeclared(ns, prefix)) {
+    if (prefix != null && !prefix.equals("") && !isDeclared(ns, prefix))
{
       declareNS(ns,prefix);
     }
   }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java?view=diff&rev=533421&r1=533420&r2=533421
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
Sat Apr 28 12:49:42 2007
@@ -117,7 +117,9 @@
   @SuppressWarnings("unchecked")
   public <T extends Element>T addExtension(String namespace, String localpart, String
prefix) {
     declareIfNecessary(namespace, prefix);
-    return (T)addExtension(new QName(namespace, localpart, prefix));
+    return (prefix != null) ? 
+      (T)addExtension(new QName(namespace, localpart, prefix)) :
+      (T)addExtension(new QName(namespace, localpart, ""));
   }
   
   public Element addSimpleExtension(QName qname, String value) {
@@ -136,10 +138,14 @@
     String value) {
       declareIfNecessary(namespace,prefix);
       return addSimpleExtension(
-        new QName(
-          namespace, 
-          localPart, 
-          prefix), 
+        (prefix != null) ?
+          new QName(
+            namespace, 
+            localPart, 
+            prefix) :
+          new QName(
+            namespace, 
+            localPart), 
         value);
   }
   



Mime
View raw message