abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r443005 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/Categories.java parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
Date Wed, 13 Sep 2006 15:58:03 GMT
Author: jmsnell
Date: Wed Sep 13 08:58:02 2006
New Revision: 443005

URL: http://svn.apache.org/viewvc?view=rev&rev=443005
Log:
>From Draft -10, Section 7.2.1

   If an app:category child element has no "scheme" attribute it
   inherits the attribute from its app:categories parent.  An app:
   category child element with an existing "scheme" attribute does not
   inherit the "scheme" value of its "app:categories" parent element.

Add a getCategoriesWithScheme() method that returns a copy of an app:categories
list of atom:category elements with the scheme attribute properly set.  This creates
a clone of the categories listing so that the original set of atom:category elements 
are not modified.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java?view=diff&rev=443005&r1=443004&r2=443005
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
Wed Sep 13 08:58:02 2006
@@ -65,7 +65,7 @@
   void setScheme(String scheme) throws URISyntaxException;
 
   /**
-   * Lists the complete set of categories listed for the entry
+   * Lists the complete set of categories
    */
   List<Category> getCategories();
   
@@ -76,19 +76,24 @@
   List<Category> getCategories(String scheme) throws URISyntaxException;
   
   /**
-   * Adds an individual category to the entry
+   * Returns a copy of the complete set of categories with the scheme attribute set
+   * as specified in 7.2.1. (child categories that do not have a scheme
+   * attribute inherit the scheme attribute of the parent)
+   * @throws URISyntaxException 
    */
-  void addCategory(Category category);
+  List<Category> getCategoriesWithScheme() throws URISyntaxException;
 
   /**
-   * Adds a category to the feed
+   * Returns a copy of the complete set of categories with the scheme 
+   * attribute set as specified in 7.2.1. (child categories that do not have a 
+   * scheme attribute inherit the scheme attribute of the parent)
    */
+  List<Category> getCategoriesWithScheme(String scheme) throws URISyntaxException;
+  
+  void addCategory(Category category);
+
   Category addCategory(String term);
 
-  /**
-   * Adds a category to the feed
-   * @throws URISyntaxException 
-   */
   Category addCategory(String scheme, String term, String label) throws URISyntaxException;
     
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java?view=diff&rev=443005&r1=443004&r2=443005
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
Wed Sep 13 08:58:02 2006
@@ -19,6 +19,7 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -121,6 +122,28 @@
 
   public List<Category> getCategories(String scheme) throws URISyntaxException {
     return FOMHelper.getCategories(this, scheme);
+  }
+  
+  private List<Category> copyCategoriesWithScheme(
+    List<Category> cats) 
+      throws URISyntaxException {
+    List<Category> newcats = new ArrayList<Category>();
+    URI scheme = getScheme();
+    for (Category cat : cats) {
+      Category newcat = (Category) cat.clone();
+      if (newcat.getScheme() == null && scheme != null) 
+        newcat.setScheme(scheme.toString());
+      newcats.add(newcat);
+    }
+    return newcats;
+  }
+  
+  public List<Category> getCategoriesWithScheme() throws URISyntaxException {
+    return copyCategoriesWithScheme(getCategories());
+  }
+  
+  public List<Category> getCategoriesWithScheme(String scheme) throws URISyntaxException
{
+    return copyCategoriesWithScheme(getCategories(scheme));
   }
 
   public java.net.URI getScheme() throws URISyntaxException {



Mime
View raw message