SpreadsheetsClientpublic class SpreadsheetsClient extends com.google.wireless.gdata.client.GDataServiceClient GDataServiceClient for accessing Google Spreadsheets. This client can
access and parse all of the Spreadsheets feed types: Spreadsheets feed,
Worksheets feed, List feed, and Cells feed. Read operations are supported
on all feed types, but only the List and Cells feeds support write
operations. (This is a limitation of the protocol, not this API. Such write
access may be added to the protocol in the future, requiring changes to
this implementation.)
Only 'private' visibility and 'full' projections are currently supported. |
Fields Summary |
---|
private static final String | SERVICEThe name of the service, dictated to be 'wise' by the protocol. | public static final String | SPREADSHEETS_BASE_FEED_URLStandard base feed url for spreadsheets. | private final String | baseFeedUrlBase feed url for spreadsheets. |
Methods Summary |
---|
public com.google.wireless.gdata.data.Entry | createEntry(java.lang.String feedUri, java.lang.String authToken, com.google.wireless.gdata.data.Entry entry)
GDataParserFactory factory = getGDataParserFactory();
GDataSerializer serializer = factory.createSerializer(entry);
InputStream is = getGDataClient().createEntry(feedUri, authToken, serializer);
GDataParser parser = factory.createParser(entry.getClass(), is);
try {
return parser.parseStandaloneEntry();
} finally {
parser.close();
}
| public java.lang.String | getBaseFeedUrl()
return baseFeedUrl;
| public com.google.wireless.gdata.parser.GDataParser | getParserForCellsFeed(java.lang.String feedUri, java.lang.String authToken)Returns a parser for a Cells-based feed.
return getParserForTypedFeed(CellEntry.class, feedUri, authToken);
| public com.google.wireless.gdata.parser.GDataParser | getParserForFeed(java.lang.Class feedEntryClass, java.lang.String feedUri, java.lang.String authToken)Fetches a GDataParser for the indicated feed. The parser can be used to
access the contents of URI. WARNING: because we cannot reliably infer
the feed type from the URI alone, this method assumes the default feed
type! This is probably NOT what you want. Please use the
getParserFor[Type]Feed methods.
GDataClient gDataClient = getGDataClient();
GDataParserFactory gDataParserFactory = getGDataParserFactory();
InputStream is = gDataClient.getFeedAsStream(feedUri, authToken);
return gDataParserFactory.createParser(feedEntryClass, is);
| public com.google.wireless.gdata.parser.GDataParser | getParserForListFeed(java.lang.String feedUri, java.lang.String authToken)Returns a parser for a List (row-based) feed.
return getParserForTypedFeed(ListEntry.class, feedUri, authToken);
| public com.google.wireless.gdata.parser.GDataParser | getParserForSpreadsheetsFeed(java.lang.String feedUri, java.lang.String authToken)Returns a parser for a Spreadsheets meta-feed.
return getParserForTypedFeed(SpreadsheetEntry.class, feedUri, authToken);
| private com.google.wireless.gdata.parser.GDataParser | getParserForTypedFeed(java.lang.Class feedEntryClass, java.lang.String feedUri, java.lang.String authToken)Returns a parser for the specified feed type.
GDataClient gDataClient = getGDataClient();
GDataParserFactory gDataParserFactory = getGDataParserFactory();
InputStream is = gDataClient.getFeedAsStream(feedUri, authToken);
return gDataParserFactory.createParser(feedEntryClass, is);
| public com.google.wireless.gdata.parser.GDataParser | getParserForWorksheetsFeed(java.lang.String feedUri, java.lang.String authToken)Returns a parser for a Worksheets meta-feed.
return getParserForTypedFeed(WorksheetEntry.class, feedUri, authToken);
| public java.lang.String | getServiceName()
return SERVICE;
| public com.google.wireless.gdata.data.Entry | updateEntry(com.google.wireless.gdata.data.Entry entry, java.lang.String authToken)Updates an entry. The URI to be updated is taken from
entry . Note that only entries in List and Cells feeds
can be updated, so entry must be of the corresponding
type; other types will result in an exception.
GDataParserFactory factory = getGDataParserFactory();
GDataSerializer serializer = factory.createSerializer(entry);
String editUri = entry.getEditUri();
if (StringUtils.isEmpty(editUri)) {
throw new ParseException("No edit URI -- cannot update.");
}
InputStream is = getGDataClient().updateEntry(editUri, authToken, serializer);
GDataParser parser = factory.createParser(entry.getClass(), is);
try {
return parser.parseStandaloneEntry();
} finally {
parser.close();
}
|
|