abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r583218 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ core/src/test/java/org/apache/abdera/test/core/ parser/src/main/java/org/apache/abdera/parser/stax/ parser/src/test/java/org/apache/abdera/test/parser/stax/
Date Tue, 09 Oct 2007 16:37:50 GMT
Author: jmsnell
Date: Tue Oct  9 09:37:49 2007
New Revision: 583218

URL: http://svn.apache.org/viewvc?rev=583218&view=rev
Log:
First step to resolving ABDERA-70. Provides a method to ensure that the Element or Document
is fully parsed without resorting to clone().  For now, this simply delegates to toString,
but eventually we might want to make it more efficient.  We also may want to edit all of the
modification methods to ensure that this is called automatically.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Base.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
    incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.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/test/java/org/apache/abdera/test/parser/stax/EntryLinkTest.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Base.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Base.java?rev=583218&r1=583217&r2=583218&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Base.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Base.java Tue Oct
 9 09:37:49 2007
@@ -100,4 +100,13 @@
    */
   void addComment(String value);
   
+  /**
+   * Ensure that the underlying streams are fully parsed.
+   * 
+   * Calling complete on an Element does not necessarily mean
+   * that the underlying stream is fully consumed, only that
+   * that particular element has been completely parsed.
+   */
+  void complete();
+  
 }

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java?rev=583218&r1=583217&r2=583218&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
Tue Oct  9 09:37:49 2007
@@ -264,4 +264,7 @@
     return internal.getDefaultWriterOptions();
   }
   
+  public void complete() {
+    internal.complete();
+  }
 }

Modified: incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java?rev=583218&r1=583217&r2=583218&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
(original)
+++ incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
Tue Oct  9 09:37:49 2007
@@ -726,6 +726,8 @@
     public <T extends Element> T addExtension(QName qname, QName before) {
       return null;
     }
+
+    public void complete() {}
     
   }
   
@@ -1375,6 +1377,8 @@
     public <T extends Element> T addExtension(QName qname, QName before) {
       return null;
     }
+
+    public void complete() {}
     
   }
 }

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?rev=583218&r1=583217&r2=583218&view=diff
==============================================================================
--- 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
Tue Oct  9 09:37:49 2007
@@ -342,4 +342,15 @@
   public WriterOptions getDefaultWriterOptions() {
     return new FOMWriter().getDefaultWriterOptions();
   }
+  
+  /**
+   * Ensure that the underlying streams are fully parsed. 
+   * We might eventually need to find a more efficient way
+   * of doing this, but for now, calling toString() will
+   * ensure that this particular object is fully parsed and ready 
+   * to be modified.
+   */
+  public void complete() {
+    toString();
+  }
 }

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?rev=583218&r1=583217&r2=583218&view=diff
==============================================================================
--- 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
Tue Oct  9 09:37:49 2007
@@ -798,4 +798,19 @@
   public WriterOptions getDefaultWriterOptions() {
     return new FOMWriter().getDefaultWriterOptions();
   }
+  
+  /**
+   * Ensure that the underlying streams are fully parsed. 
+   * We might eventually need to find a more efficient way
+   * of doing this, but for now, calling toString() will
+   * ensure that this particular object is fully parsed and ready 
+   * to be modified.
+   * 
+   * Calling complete on an Element does not necessarily mean
+   * that the underlying stream is fully consumed, only that
+   * that particular element has been completely parsed.
+   */
+  public void complete() {
+    toString();
+  }
 }

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/EntryLinkTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/EntryLinkTest.java?rev=583218&r1=583217&r2=583218&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/EntryLinkTest.java
(original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/EntryLinkTest.java
Tue Oct  9 09:37:49 2007
@@ -45,9 +45,13 @@
         Parser parser = abdera.getParser();
         Document<Entry> doc = parser.parse(this.getClass().getResourceAsStream("/entry.xml"));
         Entry entry = doc.getRoot();
+        
         // Workaround for ABDERA-70 suggested by James Snell.
-        entry = (Entry) entry.clone();
+        //entry = (Entry) entry.clone();
         // End workaround
+        // first step to a better solution that does not require cloning
+        entry.complete();
+        
         Link link = factory.newLink();
         link.setHref(entry.getId().toString());
         link.setRel(Link.REL_EDIT);



Mime
View raw message