SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
System.out.println("You asked to list documents....");
URL feedUrl = FeedUris.getDocumentsFeedUrl();
DocumentQuery query = new DocumentQuery(feedUrl);
if (parser.containsKey("onlydeleted")) {
System.out.println("...that are deleted");
query.setOnlydeleted(true);
}
if (parser.containsKey("onlyhidden")) {
System.out.println("...that are hidden");
Query.CategoryFilter filter = new Query.CategoryFilter();
filter.addCategory(new HiddenCategory());
query.addCategoryFilter(filter);
}
if (parser.containsKey("excludehidden")) {
System.out.println("...that are not hidden");
Query.CategoryFilter filter = new Query.CategoryFilter();
filter.addExcludeCategory(new HiddenCategory());
query.addCategoryFilter(filter);
}
String sharedWithEmail = parser.getValue("sharedwith");
if (sharedWithEmail != null) {
System.out.println("...that are shared with " + sharedWithEmail);
query.setSharedWithEmailId(sharedWithEmail);
}
String startIndex = parser.getValue("start-index");
if (startIndex != null) {
System.out.println("...that start from position " + startIndex);
query.setStartIndex(Integer.parseInt(startIndex));
}
String maxResults = parser.getValue("max-results");
if (maxResults != null) {
System.out.println("...and you don't want more than " + maxResults
+ " results");
query.setMaxResults(Integer.parseInt(maxResults));
}
return query;
}