Skip to content

Commit

Permalink
javadoc update
Browse files Browse the repository at this point in the history
  • Loading branch information
JE Bailey committed Aug 7, 2018
1 parent ad8e639 commit 5e75c95
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public interface ResourceFilter {

/**
* Creates a Predicate<Resource> based on the scripted matching
* Creates a Predicate<Resource> based on the script
*
* @param filter
* @return
Expand All @@ -35,7 +35,7 @@ public interface ResourceFilter {
public Predicate<Resource> parse(String filter) throws ResourceFilterException;

/**
* Creates a Predicate<Resource> based on the scripted matching
* Creates a Predicate<Resource> based on the script
*
* @param filter
* @param charEncoding
Expand All @@ -48,16 +48,17 @@ public interface ResourceFilter {
* Add a series of key - value pairs that can then be evaluated as part of the
* filter creation
*
* @param params
* @param params Map of Key - Value pairs
* @return this
*/
public abstract ResourceFilter addParams(Map<String, Object> params);

/**
* Add a key - value pair that can then be evaluated as part of the filter
* Adds a key - value pair that can then be evaluated as part of the filter
* creation
*
* @param params
* @param key
* @param value
* @return this
*/
public abstract ResourceFilter addParam(String key, Object value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
*/
package org.apache.sling.resource.filter;

/**
* Used to wrap internally generated Parser exceptions when a malformed scipt is
* provided
*
*
*/
public class ResourceFilterException extends Exception {

public ResourceFilterException(Throwable cause) {
Expand All @@ -26,5 +32,4 @@ public ResourceFilterException(Throwable cause) {

private static final long serialVersionUID = 5893818236312416308L;


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

public interface ResourceFilterProvider {

/**
* Generates a unique ResourceFilter per request
*
* @return
*/
public ResourceFilter getResourceFilter();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.resource.filter.ResourceFilterStream;


/**
* Creates a {@link Predicate} of type {@link Resource} to identify matching
* Resource objects
Expand All @@ -42,29 +41,27 @@ public ResourceFilterStream(Resource resource, ResourceFilter filter) {
}

/**
* Creates a Stream<Resource> using the branchSelector to create the traversal
* predicate to select the appropriate child resources
* Adds a branchSelector to define which child resource are acceptable to travel
* down as part of the Resource traversal
*
* @param branchSelector
* resourceFilter script for traversal control
* @return ResourceStream
* @throws ParseException
* @return ResourceStreamFilter
* @throws ResourceFilterException
*/
public ResourceFilterStream setBranchSelector(String branchSelector) throws ResourceFilterException {
this.branchSelector = resourceFilter.parse(branchSelector);
return this;
}

/**
* Creates a Stream<Resource> using the branchSelector to create the traversal
* predicate to select the appropriate child resources
* Adds a childSelector to define which child resources should be part of the
* stream
*
* @param branchSelector
* resourceFilter script for traversal control
* @param charEncoding
* char encoding of the branch selector String
* @return ResourceStream
* @throws ParseException
* @param childSelector
* resourceFilter script to identify child resources to return
* @return ResourceStreamFilter
* @throws ResourceFilterException
*/
public ResourceFilterStream setChildSelector(String childSelector) throws ResourceFilterException {
this.childSelector = resourceFilter.parse(childSelector);
Expand Down Expand Up @@ -94,6 +91,12 @@ public ResourceFilterStream addParams(Map<String, Object> params) {
return this;
}

/**
* Stream<Resource> which uses the branchSelector as the basis of the traversal
* and then filters the resources based on the childSelector that was provided
*
* @return pre filterd Stream<Resource>
*/
public Stream<Resource> stream() {
return resources.stream(branchSelector).filter(childSelector);
}
Expand Down

0 comments on commit 5e75c95

Please sign in to comment.