You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2011/10/20 23:15:38 UTC
svn commit: r1187052 - in
/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext:
features/FeatureSelector.java features/FeaturesHelper.java
history/FeedPagingHelper.java license/LicenseHelper.java
Author: jmsnell
Date: Thu Oct 20 21:15:37 2011
New Revision: 1187052
URL: http://svn.apache.org/viewvc?rev=1187052&view=rev
Log:
Additional Guava integration...
Modified:
abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java
abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java
abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java
abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/license/LicenseHelper.java
Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java?rev=1187052&r1=1187051&r2=1187052&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java Thu Oct 20 21:15:37 2011
@@ -25,10 +25,10 @@ import org.apache.abdera2.common.selecto
import org.apache.abdera2.ext.features.FeaturesHelper.Status;
import org.apache.abdera2.model.Collection;
-@SuppressWarnings("rawtypes")
+
public class FeatureSelector
-extends AbstractSelector
-implements Selector {
+extends AbstractSelector<Collection>
+implements Selector<Collection> {
private static final long serialVersionUID = -8943638085557912175L;
private final Set<String> features = new LinkedHashSet<String>();
Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java?rev=1187052&r1=1187051&r2=1187052&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeaturesHelper.java Thu Oct 20 21:15:37 2011
@@ -33,6 +33,8 @@ import org.apache.abdera2.model.Service;
import org.apache.abdera2.model.Workspace;
import org.apache.abdera2.protocol.client.AbderaClient;
+import com.google.common.base.Predicate;
+
/**
* Implementation of the current APP Features Draft
* (http://www.ietf.org/internet-drafts/draft-snell-atompub-feature-08.txt)
@@ -284,6 +286,19 @@ public final class FeaturesHelper {
return collection.addExtension(FEATURES);
}
+ public static Predicate<Collection> hasFeature(String... features) {
+ final FeatureSelector fs = new FeatureSelector(features);
+ return new Predicate<Collection>() {
+ public boolean apply(Collection input) {
+ return fs.apply(input);
+ }
+ };
+ }
+
+ public static Iterable<Collection> select(Service service, String... features) {
+ return select(service, new FeatureSelector(features));
+ }
+
/**
* Select a Collection from the service document
*/
Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java?rev=1187052&r1=1187051&r2=1187052&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java Thu Oct 20 21:15:37 2011
@@ -41,6 +41,7 @@ import org.apache.abdera2.protocol.clien
import org.apache.abdera2.protocol.client.RequestOptions;
import com.google.common.base.Function;
+import com.google.common.base.Predicate;
/**
* Initial support for Mark Nottingham's Feed Paging and Archiving draft
@@ -100,6 +101,30 @@ public final class FeedPagingHelper {
el.getExtension(qname).discard();
}
+ public static Predicate<Source> isArchive() {
+ return new Predicate<Source>() {
+ public boolean apply(Source input) {
+ return isArchive(input);
+ }
+ };
+ }
+
+ public static Predicate<Source> isPaged() {
+ return new Predicate<Source>() {
+ public boolean apply(Source input) {
+ return isPaged(input);
+ }
+ };
+ }
+
+ public static Predicate<Source> isComplete() {
+ return new Predicate<Source>() {
+ public boolean apply(Source input) {
+ return isComplete(input);
+ }
+ };
+ }
+
/**
* Return true if the feed has been marked as an archive
*
@@ -265,6 +290,102 @@ public final class FeedPagingHelper {
return _getLink(feed,REL_CURRENT);
}
+ public static <E extends Element>Function<Source,Document<E>> fetchNext(final AbderaSession session) {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchNext(input,session);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchPrevious(final AbderaSession session) {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchPrevious(input,session);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchCurrent(final AbderaSession session) {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchCurrent(input,session);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchLast(final AbderaSession session) {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchLast(input,session);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchNextArchive(final AbderaSession session) {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchNextArchive(input,session);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchPreviousArchive(final AbderaSession session) {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchPreviousArchive(input,session);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchNext() {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchNext(input);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchPrevious() {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchPrevious(input);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchCurrent() {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchCurrent(input);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchLast() {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchLast(input);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchNextArchive() {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchNextArchive(input);
+ }
+ };
+ }
+
+ public static <E extends Element>Function<Source,Document<E>> fetchPreviousArchive() {
+ return new Function<Source,Document<E>>() {
+ public Document<E> apply(Source input) {
+ return fetchPreviousArchive(input);
+ }
+ };
+ }
+
public static <E extends Element>Document<E> fetchNext(Source source) {
AbderaClient client = new AbderaClient();
AbderaSession session = client.newSession();
Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/license/LicenseHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/license/LicenseHelper.java?rev=1187052&r1=1187051&r2=1187052&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/license/LicenseHelper.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/license/LicenseHelper.java Thu Oct 20 21:15:37 2011
@@ -25,6 +25,8 @@ import org.apache.abdera2.model.Entry;
import org.apache.abdera2.model.Link;
import org.apache.abdera2.model.Source;
+import com.google.common.base.Predicate;
+
/**
* Implementation of the Atom License Extension, RFC 4946
*/
@@ -69,6 +71,54 @@ public final class LicenseHelper {
return getLicense(base, true);
}
+ public static Predicate<Base> hasUnspecifiedLicense() {
+ return new Predicate<Base>() {
+ public boolean apply(Base input) {
+ return hasUnspecifiedLicense(input,false);
+ }
+ };
+ }
+
+ public static Predicate<Base> hasInheritedUnspecifiedLicense() {
+ return new Predicate<Base>() {
+ public boolean apply(Base input) {
+ return hasUnspecifiedLicense(input,true);
+ }
+ };
+ }
+
+ public static Predicate<Base> hasLicense(final String uri) {
+ return new Predicate<Base>() {
+ public boolean apply(Base input) {
+ return hasLicense(input,uri, false);
+ }
+ };
+ }
+
+ public static Predicate<Base> hasInheritedLicense(final String uri) {
+ return new Predicate<Base>() {
+ public boolean apply(Base input) {
+ return hasLicense(input,uri, true);
+ }
+ };
+ }
+
+ public static Predicate<Base> hasLicense() {
+ return new Predicate<Base>() {
+ public boolean apply(Base input) {
+ return hasLicense(input);
+ }
+ };
+ }
+
+ public static Predicate<Base> hasInheritedLicense() {
+ return new Predicate<Base>() {
+ public boolean apply(Base input) {
+ return hasLicense(input,true);
+ }
+ };
+ }
+
public static boolean hasUnspecifiedLicense(Base base, boolean inherited) {
return hasLicense(base, UNSPECIFIED_LICENSE, inherited);
}