本文整理汇总了Java中com.google.gdata.client.Query.setFields方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setFields方法的具体用法?Java Query.setFields怎么用?Java Query.setFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gdata.client.Query
的用法示例。
在下文中一共展示了Query.setFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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() + ")");
}
}
}
示例2: 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());
}
示例3: 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() + ")");
}
}
}
示例4: 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());
}
示例5: 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());
}