abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r443121 - 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 21:02:40 GMT
Author: jmsnell
Date: Wed Sep 13 14:02:39 2006
New Revision: 443121

URL: http://svn.apache.org/viewvc?view=rev&rev=443121
Log:
Utility methods for checking to see if a Categories element contains a given category.

This is useful for APP in that if the categories are fixed and clients use a category that
is not
listed in the categories element the server can reject the request.  This gives us a simple
means 
of determining whether or not a given collection can be used.

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=443121&r1=443120&r2=443121
==============================================================================
--- 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 14:02:39 2006
@@ -96,5 +96,9 @@
 
   Category addCategory(String scheme, String term, String label) throws URISyntaxException;
     
+  boolean contains(String term) throws URISyntaxException;
+  
+  boolean contains(String term, String scheme) 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=443121&r1=443120&r2=443121
==============================================================================
--- 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 14:02:39 2006
@@ -184,6 +184,31 @@
     else 
       removeAttribute(HREF);
   }
+
+  public boolean contains(
+    String term) 
+      throws URISyntaxException {
+    return contains(term,null);
+  }
+
+  public boolean contains(
+    String term, 
+    String scheme) 
+      throws URISyntaxException {
+    List<Category> categories = getCategories();
+    URI catscheme = getScheme();
+    URI uri = (scheme != null) ? 
+      new URI(scheme) : catscheme;
+    for (Category category : categories) {
+      String t = category.getTerm();
+      URI s = (category.getScheme() != null) ? 
+        category.getScheme() : catscheme;
+      if (t.equals(term) && 
+          ((uri!=null)? uri.equals(s) : s == null))
+            return true;
+    }
+    return false;
+  }
   
 
 



Mime
View raw message