本文整理汇总了Java中com.google.gdata.client.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于com.google.gdata.client包,在下文中一共展示了Query类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:google,项目名称:gdata-java-client,代码行数:39,代码来源:BloggerClient.java
示例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() + ")");
}
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:23,代码来源:PicasawebPartialDemo.java
示例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());
}
开发者ID:google,项目名称:gdata-java-client,代码行数:26,代码来源:PicasawebPartialDemo.java
示例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);
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:21,代码来源:BaseFeed.java
示例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() + ")");
}
}
}
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:21,代码来源:PicasawebClient.java
示例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());
}
开发者ID:Dotosoft,项目名称:dotoquiz-tools,代码行数:21,代码来源:PicasawebClient.java
示例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;
}
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:21,代码来源:EntryProviderImpl.java
示例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;
}
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:18,代码来源:ContinuousContentFeedTest.java
示例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);
}
开发者ID:hamdikavak,项目名称:youtube-search-tool,代码行数:20,代码来源:YouTubeManager.java
示例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();
}
开发者ID:google,项目名称:gdata-java-client,代码行数:25,代码来源:EventFeedDemo.java
示例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);
}
开发者ID:google,项目名称:gdata-java-client,代码行数:13,代码来源:ListGlossariesCommand.java
示例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;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:10,代码来源:ListGlossariesCommand.java
示例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;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:13,代码来源:Feed.java
示例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);
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:13,代码来源:Feed.java
示例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;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:12,代码来源:Feed.java
示例16: setStartIndex
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Sets the starting index of the contained entries for paged feeds. A value
* of {@link Query#UNDEFINED} indicates the start index is undefined.
*/
public void setStartIndex(int v) {
if (v != Query.UNDEFINED) {
setElement(START_INDEX, new Element(START_INDEX).setTextValue(v));
} else {
removeElement(START_INDEX);
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:12,代码来源:Feed.java
示例17: getItemsPerPage
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Gets the number of items that will be returned per page for paged feeds. A
* value of {@link Query#UNDEFINED} indicates the page item count is
* undefined.
*/
public int getItemsPerPage() {
Integer v = getElementValue(ITEMS_PER_PAGE);
if (v == null) {
return Query.UNDEFINED;
}
return v;
}
开发者ID:google,项目名称:gdata-java-client,代码行数:13,代码来源:Feed.java
示例18: setItemsPerPage
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Sets the number of items that will be returned per page for paged feeds. A
* value of {@link Query#UNDEFINED} indicates the page item count is
* undefined.
*/
public void setItemsPerPage(int v) {
if (v != Query.UNDEFINED) {
setElement(ITEMS_PER_PAGE, new Element(ITEMS_PER_PAGE).setTextValue(v));
} else {
removeElement(ITEMS_PER_PAGE);
}
}
开发者ID:google,项目名称:gdata-java-client,代码行数:13,代码来源:Feed.java
示例19: getSpreadsheetFields
import com.google.gdata.client.Query; //导入依赖的package包/类
private void getSpreadsheetFields() {
try {
GoogleSpreadsheetInputMeta meta = new GoogleSpreadsheetInputMeta();
setData(meta);
wFields.table.removeAll();
String accessToken = GoogleSpreadsheet.getAccessToken(meta.getServiceEmail(), meta.getPrivateKeyStore());
if (accessToken == null || accessToken.equals("")) {
throw new Exception("Unable to get access token.");
}
SpreadsheetService service = new SpreadsheetService("PentahoKettleTransformStep-v1");
service.setHeader("Authorization", String.format("Bearer %s", accessToken));
Query feedQuery = new Query(FeedURLFactory.getDefault().getListFeedUrl(meta.getSpreadsheetKey(), meta.getWorksheetId(), "private", "full"));
feedQuery.setMaxResults(1);
ListFeed feed = service.getFeed(feedQuery, ListFeed.class);
List<ListEntry> rows = feed.getEntries();
ListEntry row = rows.get(0);
for (String tag : row.getCustomElements().getTags()) {
TableItem item = new TableItem(wFields.table, SWT.NONE);
item.setText(1, Const.trim(tag));
item.setText(2, ValueMeta.getTypeDesc(ValueMetaInterface.TYPE_STRING));
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), "Error getting Fields", e);
}
}
开发者ID:GlobalTechnology,项目名称:pdi-google-spreadsheet-plugin,代码行数:34,代码来源:GoogleSpreadsheetInputDialog.java
示例20: updateAttendeeStatus
import com.google.gdata.client.Query; //导入依赖的package包/类
/**
* Updates user's response for a specific event using partial patch.
*
* @param uname username whose attendeeStatus need to be updated.
*/
private void updateAttendeeStatus(String uname)
throws IOException, ServiceException {
OUT.println("Enter the id of event to update: ");
String eventId = IN.readLine();
OUT.println("Enter event response (1:Yes, 2:No, 3:Maybe)");
String selection;
switch(readInt()) {
case 1:
selection = Who.AttendeeStatus.EVENT_ACCEPTED;
break;
case 2:
selection = Who.AttendeeStatus.EVENT_DECLINED;
break;
case 3:
selection = Who.AttendeeStatus.EVENT_TENTATIVE;
break;
default:
OUT.println("Invalid selection.");
return;
}
// URL of calendar entry to update.
String eventEntryUrl = CALENDAR_FEEDS_PREFIX + uname
+ "/private/full/" + eventId;
// Selection criteria to fetch only the attendee status of specified user.
String selectAttendee =
"@gd:etag,title,gd:who[@email='" + uname + "']";
Query partialQuery = new Query(new URL(eventEntryUrl));
partialQuery.setFields(selectAttendee);
CalendarEventEntry event = service.getEntry(partialQuery.getUrl(),
CalendarEventEntry.class);
// The participant list will contain exactly one attendee matching
// above partial query selection criteria.
event.getParticipants().get(0).setAttendeeStatus(selection);
// Field selection to update attendeeStatus only.
String toUpdateFields = "gd:who/gd:attendeeStatus";
// Make patch request which returns full representation for the event.
event = service.patch(
new URL(eventEntryUrl), toUpdateFields, event);
// Print the updated attendee status.
OUT.println(event.getTitle().getPlainText() + " updated to: "
+ event.getParticipants().get(0).getAttendeeStatus());
}
开发者ID:google,项目名称:gdata-java-client,代码行数:54,代码来源:EventFeedPartialDemo.java
注:本文中的com.google.gdata.client.Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论