本文整理汇总了Java中com.google.gdata.client.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于com.google.gdata.client包,在下文中一共展示了Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printDateRangeQueryResults
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Displays the title and modification time for any posts that have been
* created or updated in the period between the startTime and endTime
* parameters. The method creates the query, submits it to the GoogleService,
* then displays the results.
*
* Note that while the startTime is inclusive, the endTime is exclusive, so
* specifying an endTime of '2007-7-1' will include those posts up until
* 2007-6-30 11:59:59PM.
*
* @param myService An authenticated GoogleService object.
* @param startTime DateTime object specifying the beginning of the search
* period (inclusive).
* @param endTime DateTime object specifying the end of the search period
* (exclusive).
* @throws ServiceException If the service is unable to handle the request.
* @throws IOException If the URL is malformed.
*/
public static void printDateRangeQueryResults(BloggerService myService,
DateTime startTime, DateTime endTime) throws ServiceException,
IOException {
// Create query and submit a request
URL feedUrl = new URL(feedUri + POSTS_FEED_URI_SUFFIX);
Query myQuery = new Query(feedUrl);
myQuery.setUpdatedMin(startTime);
myQuery.setUpdatedMax(endTime);
Feed resultFeed = myService.query(myQuery, Feed.class);
// Print the results
System.out.println(resultFeed.getTitle().getPlainText() + " posts between "
+ startTime + " and " + endTime);
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
Entry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
System.out.println("\t" + entry.getUpdated().toStringRfc822());
}
System.out.println();
}
示例2: printAlbumLocation
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Demonstrates use of partial query to retrieve album title and location
* information for user's albums.
*/
private void printAlbumLocation(String uname)
throws IOException, ServiceException {
String albumsUrl = API_PREFIX + uname;
String fields = "entry(title,gphoto:id,gphoto:location)";
Query albumQuery = new Query(new URL(albumsUrl));
albumQuery.setFields(fields);
AlbumFeed feed = service.query(albumQuery, AlbumFeed.class);
for (GphotoEntry entry : feed.getEntries()) {
if (entry instanceof AlbumEntry) {
AlbumEntry albumEntry = (AlbumEntry) entry;
OUT.println(albumEntry.getGphotoId() + ":"
+ albumEntry.getTitle().getPlainText()
+ " (" + albumEntry.getLocation() + ")");
}
}
}
示例3: updateAlbumLocation
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Demonstrates update operation using partial patch to update location
* string for specified album.
*/
private void updateAlbumLocation(String uname)
throws IOException, ServiceException {
OUT.println("Enter album id to update:");
String albumId = IN.readLine();
// Get the current album entry
String albumEntryUrl = API_PREFIX + uname + "/" + albumId;
String fields = "@gd:etag,gphoto:location";
Query patchQuery = new Query(new URL(albumEntryUrl));
patchQuery.setFields(fields);
AlbumEntry entry = service.getEntry(patchQuery.getUrl(), AlbumEntry.class);
OUT.println("Current location: " + entry.getLocation());
// Update the location in the album entry
OUT.println("Specify new location: ");
String newLocation = IN.readLine();
entry.setLocation(newLocation);
entry.setSelectedFields("gphoto:location");
AlbumEntry updated = service.patch(new URL(albumEntryUrl), fields, entry);
OUT.println("Location set to: " + updated.getLocation());
}
示例4: processEndElement
import com.google.gdata.client.Query; //导入依赖的package包/类
@Override
public void processEndElement() throws ParseException {
if (feedState.totalResults != Query.UNDEFINED) {
throw new ParseException(
CoreErrorDomain.ERR.duplicateTotalResults);
}
if (value == null) {
throw new ParseException(
CoreErrorDomain.ERR.logoValueRequired);
}
try {
feedState.totalResults = Integer.valueOf(value).intValue();
} catch (NumberFormatException e) {
throw new ParseException(
CoreErrorDomain.ERR.totalResultsNotInteger);
}
}
示例5: printAlbumLocation
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Demonstrates use of partial query to retrieve album title and location
* information for user's albums.
*/
private void printAlbumLocation(String uname) throws IOException, ServiceException {
String albumsUrl = API_PREFIX + uname;
String fields = "entry(title,gphoto:id,gphoto:location)";
Query albumQuery = new Query(new URL(albumsUrl));
albumQuery.setFields(fields);
AlbumFeed feed = service.query(albumQuery, AlbumFeed.class);
for (GphotoEntry entry : feed.getEntries()) {
if (entry instanceof AlbumEntry) {
AlbumEntry albumEntry = (AlbumEntry) entry;
log.info(albumEntry.getGphotoId() + ":" + albumEntry.getTitle().getPlainText() + " ("
+ albumEntry.getLocation() + ")");
}
}
}
示例6: updateAlbumLocation
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Demonstrates update operation using partial patch to update location
* string for specified album.
*/
public void updateAlbumLocation(String uname, String albumId, String newLocation) throws IOException, ServiceException {
// Get the current album entry
String albumEntryUrl = API_PREFIX + uname + "/" + albumId;
String fields = "@gd:etag,gphoto:location";
Query patchQuery = new Query(new URL(albumEntryUrl));
patchQuery.setFields(fields);
AlbumEntry entry = service.getEntry(patchQuery.getUrl(), AlbumEntry.class);
log.info("Current location: " + entry.getLocation());
// Update the location in the album entry
entry.setLocation(newLocation);
entry.setSelectedFields("gphoto:location");
AlbumEntry updated = service.patch(new URL(albumEntryUrl), fields, entry);
log.info("Location set to: " + updated.getLocation());
}
示例7: getEntries
import com.google.gdata.client.Query; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<BaseContentEntry<?>> getEntries(Query query,
SitesService sitesService) throws IOException, ServiceException {
checkNotNull(query, "query");
checkNotNull(sitesService, "sitesService");
List<BaseContentEntry> baseEntries =
sitesService.getFeed(query, ContentFeed.class).getEntries();
List<BaseContentEntry<?>> adaptedEntries = Lists.newLinkedList();
for (BaseContentEntry entry : baseEntries) {
BaseContentEntry<?> adaptedEntry =
(BaseContentEntry<?>) entry.getAdaptedEntry();
if (adaptedEntry == null) {
adaptedEntries.add(entry);
} else {
adaptedEntries.add(adaptedEntry);
}
}
return adaptedEntries;
}
示例8: getEntries
import com.google.gdata.client.Query; //导入依赖的package包/类
public List<BaseContentEntry<?>> getEntries(Query query, SitesService sitesService)
throws ServiceException, IOException {
int fromIndex = query.getStartIndex() - 1;
int max = Math.min(maxResultsPerRequest, query.getMaxResults());
int toIndex = Math.min(fromIndex + max, entries.size());
if (fromIndex > toIndex) {
return new ArrayList<BaseContentEntry<?>>();
}
List<BaseContentEntry<?>> response = entries.subList(fromIndex, toIndex);
if (response.contains(serviceExceptionEntry)) {
throw new ServiceException("Error");
}
if (response.contains(ioExceptionEntry)) {
throw new IOException("Error");
}
return response;
}
示例9: retrieveVideos
import com.google.gdata.client.Query; //导入依赖的package包/类
public List<YouTubeVideo> retrieveVideos(String textQuery, int maxResults, boolean filter, int timeout, int startIndex) throws Exception {
YouTubeService service = new YouTubeService(clientID);
service.setConnectTimeout(timeout); // millis
YouTubeQuery query = new YouTubeQuery(new URL(YOUTUBE_URL));
query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);
query.setFullTextQuery(textQuery);
query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
query.setMaxResults(maxResults);
query.setStartIndex(startIndex);
query.addCustomParameter(new Query.CustomParameter("hd", "true"));
VideoFeed videoFeed = service.query(query, VideoFeed.class);
List<VideoEntry> videos = videoFeed.getEntries();
return convertVideos(videos);
}
示例10: fullTextQuery
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Prints the titles of all events matching a full-text query.
*
* @param service An authenticated CalendarService object.
* @param query The text for which to query.
* @throws ServiceException If the service is unable to handle the request.
* @throws IOException Error communicating with the server.
*/
private static void fullTextQuery(CalendarService service, String query)
throws ServiceException, IOException {
Query myQuery = new Query(eventFeedUrl);
myQuery.setFullTextQuery("Tennis");
CalendarEventFeed resultFeed = service.query(myQuery,
CalendarEventFeed.class);
System.out.println("Events matching " + query + ":");
System.out.println();
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEventEntry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}
System.out.println();
}
示例11: execute
import com.google.gdata.client.Query; //导入依赖的package包/类
public void execute(GttService service, String[] args)
throws IOException, ServiceException {
Query query = createQueryFromArgs(args);
System.out.print("Fetching glossaries....");
System.out.flush();
GlossaryFeed resultFeed
= service.getFeed(query, GlossaryFeed.class);
printResults(resultFeed);
}
示例12: createQueryFromArgs
import com.google.gdata.client.Query; //导入依赖的package包/类
private Query createQueryFromArgs(String[] args)
throws IOException {
SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
URL feedUrl = FeedUris.getGlossariesFeedUrl();
Query query = new Query(feedUrl);
return query;
}
示例13: getTotalResults
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Gets the total number of results associated with this feed. The value may
* be larger than the number of contained entries for paged feeds. A value of
* {@link Query#UNDEFINED} indicates the total size is undefined.
*/
public int getTotalResults() {
Integer v = getElementValue(TOTAL_RESULTS);
if (v == null) {
return Query.UNDEFINED;
}
return v;
}
示例14: setTotalResults
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Sets the total number of results associated with this feed. The value may
* be larger than the number of contained entries for paged feeds. A value of
* {@link Query#UNDEFINED} indicates the total size is undefined.
*/
public void setTotalResults(int v) {
if (v != Query.UNDEFINED) {
setElement(TOTAL_RESULTS, new Element(TOTAL_RESULTS).setTextValue(v));
} else {
removeElement(TOTAL_RESULTS);
}
}
示例15: getStartIndex
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Gets the starting index of the contained entries for paged feeds. A value
* of {@link Query#UNDEFINED} indicates the start index is undefined.
*/
public int getStartIndex() {
Integer v = getElementValue(START_INDEX);
if (v == null) {
return Query.UNDEFINED;
}
return v;
}