abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r530126 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Wed, 18 Apr 2007 18:44:59 GMT
Author: jmsnell
Date: Wed Apr 18 11:44:58 2007
New Revision: 530126

URL: http://svn.apache.org/viewvc?view=rev&rev=530126
Log:
Add the ability to select collections by the media types they support.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Service.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Workspace.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Service.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Service.java?view=diff&rev=530126&r1=530125&r2=530126
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Service.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Service.java Wed
Apr 18 11:44:58 2007
@@ -19,6 +19,8 @@
 
 import java.util.List;
 
+import javax.activation.MimeType;
+
 /**
  * <p>Represents the root of an Atom Publishing Protocol Introspection Document.</p>
  * 
@@ -76,4 +78,34 @@
    */
   Collection getCollection(String workspace, String collection);
   
+  /**
+   * Returns a collection that accepts the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A matching app:collection element
+   */
+  Collection getCollectionThatAccepts(MimeType... type);
+  
+  /**
+   * Returns a collection that accepts the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A matching app:collection element
+   */
+  Collection getCollectionThatAccepts(String... type);
+  
+  
+  /**
+   * Returns collections that accept the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A listing matching app:collection elements
+   */
+  List<Collection> getCollectionsThatAccept(MimeType... type);
+  
+  /**
+   * Returns collections that accept the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A listing of matching app:collection elements
+   */
+  List<Collection> getCollectionsThatAccept(String... type);
+  
 }
+

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Workspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Workspace.java?view=diff&rev=530126&r1=530125&r2=530126
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Workspace.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Workspace.java
Wed Apr 18 11:44:58 2007
@@ -19,6 +19,8 @@
 
 import java.util.List;
 
+import javax.activation.MimeType;
+
 import org.apache.abdera.i18n.iri.IRISyntaxException;
 
 /**
@@ -107,5 +109,34 @@
     String title, 
     String href) 
       throws IRISyntaxException;
+  
+  /**
+   * Returns a collection that accepts the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A matching app:collection element
+   */
+  Collection getCollectionThatAccepts(MimeType... type);
+  
+  /**
+   * Returns a collection that accepts the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A matching app:collection element
+   */
+  Collection getCollectionThatAccepts(String... type);
+  
+  
+  /**
+   * Returns collections that accept the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A listing matching app:collection elements
+   */
+  List<Collection> getCollectionsThatAccept(MimeType... type);
+  
+  /**
+   * Returns collections that accept the specified media types
+   * @param a listing of media types the collection must accept
+   * @return A listing of matching app:collection elements
+   */
+  List<Collection> getCollectionsThatAccept(String... type);
   
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java?view=diff&rev=530126&r1=530125&r2=530126
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
Wed Apr 18 11:44:58 2007
@@ -17,8 +17,10 @@
 */
 package org.apache.abdera.parser.stax;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import javax.activation.MimeType;
 import javax.xml.namespace.QName;
 
 import org.apache.abdera.model.Collection;
@@ -126,6 +128,42 @@
       col = w.getCollection(collection);
     }
     return col;
+  }
+
+  public Collection getCollectionThatAccepts(MimeType... types) {
+    Collection collection = null;
+    for (Workspace workspace : getWorkspaces()) {
+      collection = workspace.getCollectionThatAccepts(types);
+      if (collection != null) break;
+    }
+    return collection;
+  }
+
+  public Collection getCollectionThatAccepts(String... types) {
+    Collection collection = null;
+    for (Workspace workspace : getWorkspaces()) {
+      collection = workspace.getCollectionThatAccepts(types);
+      if (collection != null) break;
+    }
+    return collection;
+  }
+
+  public List<Collection> getCollectionsThatAccept(MimeType... types) {
+    List<Collection> collections = new ArrayList<Collection>();
+    for (Workspace workspace : getWorkspaces()) {
+      List<Collection> colls = workspace.getCollectionsThatAccept(types);
+      collections.addAll(colls);
+    }
+    return collections;
+  }
+
+  public List<Collection> getCollectionsThatAccept(String... types) {
+    List<Collection> collections = new ArrayList<Collection>();
+    for (Workspace workspace : getWorkspaces()) {
+      List<Collection> colls = workspace.getCollectionsThatAccept(types);
+      collections.addAll(colls);
+    }
+    return collections;
   }
 
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java?view=diff&rev=530126&r1=530125&r2=530126
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
Wed Apr 18 11:44:58 2007
@@ -17,8 +17,10 @@
 */
 package org.apache.abdera.parser.stax;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import javax.activation.MimeType;
 import javax.xml.namespace.QName;
 
 import org.apache.abdera.model.Collection;
@@ -145,4 +147,55 @@
     collection.setHref(href);
     return collection;
   }
+  
+  public Collection getCollectionThatAccepts(MimeType... types) {
+    Collection collection = null;
+    for (Collection coll : getCollections()) {
+      int matches = 0;
+      for (MimeType type : types) if (coll.accepts(type)) matches++;
+      if (matches == types.length) {
+        collection = coll;
+        break;
+      }
+    }
+    return collection;
+  }
+
+  public Collection getCollectionThatAccepts(String... types) {
+    Collection collection = null;
+    for (Collection coll : getCollections()) {
+      int matches = 0;
+      for (String type : types) if (coll.accepts(type)) matches++;
+      if (matches == types.length) {
+        collection = coll;
+        break;
+      }
+    }
+    return collection;
+  }
+
+  public List<Collection> getCollectionsThatAccept(MimeType... types) {
+    List<Collection> collections = new ArrayList<Collection>();
+    for (Collection coll : getCollections()) {
+      int matches = 0;
+      for (MimeType type : types) if (coll.accepts(type)) matches++;
+      if (matches == types.length) {
+        collections.add(coll);
+      }
+    }
+    return collections;
+  }
+
+  public List<Collection> getCollectionsThatAccept(String... types) {
+    List<Collection> collections = new ArrayList<Collection>();
+    for (Collection coll : getCollections()) {
+      int matches = 0;
+      for (String type : types) if (coll.accepts(type)) matches++;
+      if (matches == types.length) {
+        collections.add(coll);
+      }
+    }
+    return collections;
+  }
+
 }



Mime
View raw message