|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.gdata.data.AbstractExtension
com.google.gdata.data.ExtensionPoint
com.google.gdata.data.Source
com.google.gdata.data.BaseFeed<F,E>
F - feed type associated with bound subtypeE - entry type associated with bound subtypepublic abstract class BaseFeed<F extends BaseFeed,E extends BaseEntry>
The BaseFeed class is an abstract base class that represents a
generic GData feed object, based primarily on the data model for
an <atom:feed> element. It is extended to represent
OpenSearch RSS channel elements, and also supports generalized
extensibility using a defined ExtensionProfile and/or by stored
extended data as an XmlBlob.
The BaseFeedClass is a generic class that is parameterized by the type of Entry that will be contained within the feed. The base class contains all the necessary parsing and generation code for feed extension data, but can be subclassed to create subtypes that contain convenience APIs for accessing extension elements and entries.
An instance can be initialized by parsing an Atom 1.0 feed from a Reader or by directly initializing its component elements. It can generate an XML representation of the feed to an XmlWriter in either Atom 1.0 or RSS 2.0 format.
Here is the Relax-NG schema that represents an Atom 1.0 feed:
AtomFeed =
element atom:feed {
atomCommonAttributes,
(atomAuthor*
atomCategory*
atomContributor*
atomGenerator?
atomIcon?
atomId
atomLink*
atomLogo?
atomRights?
atomSubtitle?
atomTitle
atomUpdated
extensionElement*),
atomEntry*
}
Because the Feed schema differs from the Source schema only by the
presence of the entries, the Feed class derives its base property
model and parsing/generation implementations from the Source class.
The BaseFeed class implements the Kind.Adaptable interface, meaning
it is possible to create new Kind.Adaptor subtypes that defines
a custom extension model (and associated convenience APIs) for a BaseFeed
subtypes that use Atom/RSS extensions to extend the content model for a
particular type of data.
An Kind.Adaptor subclass of BaseFeed should do the following:
Kind.Term annotation on the class declaration that
defines the Category term value for the GData kind handled by the
adaptor.Class and BaseFeed
parameter as an argument that is used when adapting a generic feed type to
a more specific one.Kind.Adaptor.declareExtensions(ExtensionProfile)
method and use it to declare the extension model for the adapted instance
within the profile passed as a parameter. This is used to auto-extend
an extension profile when kind Category tags are found during parsing of
content.ExtensionPoint methods to
store/retrieve the extension data.
| Nested Class Summary | |
|---|---|
class |
BaseFeed.FeedHandler
<atom:feed> parser. |
protected static class |
BaseFeed.FeedState
The FeedState class provides a simple structure that encapsulates the attributes of an Atom feed that should be shared with a shallow copy if the feed is adapted to a more specific BaseFeed Kind.Adaptor subtypes. |
| Nested classes/interfaces inherited from class com.google.gdata.data.Source |
|---|
Source.SourceHandler, Source.SourceState |
| Nested classes/interfaces inherited from class com.google.gdata.data.ExtensionPoint |
|---|
ExtensionPoint.CumulativeBlobHandler, ExtensionPoint.ExtensionHandler |
| Nested classes/interfaces inherited from class com.google.gdata.data.AbstractExtension |
|---|
AbstractExtension.AttributesHandler |
| Field Summary | |
|---|---|
protected java.util.List<E> |
entries
Feed entries. |
protected java.lang.Class<? extends E> |
entryClass
Class used to construct new entry instance, initialized at construction. |
protected BaseFeed.FeedState |
feedState
Basic state for this feed. |
| Fields inherited from class com.google.gdata.data.Source |
|---|
srcState |
| Fields inherited from class com.google.gdata.data.ExtensionPoint |
|---|
xmlBlob |
| Fields inherited from class com.google.gdata.data.AbstractExtension |
|---|
localName, namespace |
| Constructor Summary | |
|---|---|
protected |
BaseFeed(java.lang.Class<? extends E> entryClass)
Copy constructor that initializes a new BaseFeed instance to have identical contents to another instance, using a shared reference to the same BaseFeed.FeedState. |
protected |
BaseFeed(java.lang.Class<? extends E> entryClass,
BaseFeed<?,?> sourceFeed)
Copy constructor that initializes a new BaseFeed instance to have identical contents to another instance, using a shared reference to the same BaseFeed.FeedState. |
| Method Summary | ||
|---|---|---|
void |
addAdaptor(Kind.Adaptor adaptor)
Associates a new Kind.Adaptor with this Adaptable instance. |
|
E |
createEntry()
Creates a new entry for the feed. |
|
void |
declareExtensions(ExtensionProfile extProfile)
Declares the set of expected Extension types for an ExtensionPoint within the target extension profile. |
|
void |
generate(com.google.gdata.util.common.xml.XmlWriter w,
ExtensionProfile p)
Generates an XML representation for the extension. |
|
void |
generateAtom(com.google.gdata.util.common.xml.XmlWriter w,
ExtensionProfile extProfile)
Generates XML in the Atom format. |
|
void |
generateFeedEnd(com.google.gdata.util.common.xml.XmlWriter w)
Closes everything that was opened by generateFeedStart(com.google.gdata.data.ExtensionProfile, com.google.gdata.util.common.xml.XmlWriter, java.util.Collection. |
|
void |
generateFeedStart(ExtensionProfile extProfile,
com.google.gdata.util.common.xml.XmlWriter w,
java.util.Collection<com.google.gdata.util.common.xml.XmlNamespace> namespaces)
Generates everything that's in the feed up to and not including the entries. |
|
void |
generateRss(com.google.gdata.util.common.xml.XmlWriter w,
ExtensionProfile extProfile)
Generates XML in the RSS format. |
|
BaseFeed<?,?> |
getAdaptedFeed()
Locates and returns the most specific Kind.Adaptor feed
subtype for this feed. |
|
|
getAdaptor(java.lang.Class<A> adaptorClass)
Returns a Kind.Adaptor instance associated with this
Adaptable instance of the specified type, or {code null}
if none is available.. |
|
java.util.Collection<Kind.Adaptor> |
getAdaptors()
Returns the collection of Kind.Adaptor instances associated with the
this Adaptable instance. |
|
boolean |
getCanPost()
Gets the property that indicates if it is possible to post new entries to the feed. |
|
java.util.List<E> |
getEntries()
Returns the list of entries in this feed |
|
|
getEntries(java.lang.Class<T> returnClass)
Gets a list of entries of a particular kind. |
|
Link |
getEntryPostLink()
Returns the entry post link for the feed. |
|
java.lang.String |
getEtag()
Returns the current entity tag value for this feed. |
|
Link |
getFeedBatchLink()
Returns the link that provides the URI that can be used to batch operations to query, insert, update and delete entries on this feed. |
|
XmlParser.ElementHandler |
getHandler(ExtensionProfile p,
java.lang.String namespace,
java.lang.String localName,
org.xml.sax.Attributes attrs)
The default implementation uses the AbstractExtension.AttributesHandler to handle
parsing the extension. |
|
int |
getItemsPerPage()
Gets the number of items that will be returned per page for paged feeds. |
|
java.lang.String |
getKind()
Returns the current gd:kind attribute value for this feed. |
|
Link |
getNextLink()
Returns the link that provides the URI of next page in a paged feed. |
|
Link |
getPreviousLink()
Returns the link that provides the URI of previous page in a paged feed. |
|
F |
getSelf()
Returns the current representation of the feed by requesting it from the associated service using the feed's self link. |
|
Link |
getSelfLink()
Returns the self link for the feed. |
|
Service |
getService()
Returns that GData Service instance associated with this feed. |
|
int |
getStartIndex()
Gets the starting index of the contained entries for paged feeds. |
|
int |
getTotalResults()
Gets the total number of results associated with this feed. |
|
java.lang.String |
getVersionId()
Returns the entity version for this feed. |
|
|
insert(T newEntry)
Inserts a new Entry into the feed, if the feed is currently associated with a Service. |
|
void |
parseAtom(ExtensionProfile extProfile,
java.io.InputStream input)
Parses XML in the Atom format. |
|
void |
parseAtom(ExtensionProfile extProfile,
java.io.Reader reader)
Parses XML in the Atom format. |
|
void |
parseAtom(ExtensionProfile extProfile,
XmlEventSource source)
Parses XML in the Atom format from a parser-defined content source. |
|
static BaseFeed<?,?> |
readFeed(ParseSource source)
Reads a feed representation from the provided ParseSource. |
|
static
|
readFeed(ParseSource source,
java.lang.Class<F> feedClass,
ExtensionProfile extProfile)
This method provides the base implementation of feed reading using either static or dynamic typing. |
|
void |
setCanPost(boolean v)
Sets the property that indicates if it is possible to post new entries to the feed. |
|
void |
setEntries(java.util.List<E> entryList)
Sets the list to use for storing the entry list |
|
void |
setEtag(java.lang.String v)
Sets the current entity tag value for this feed. |
|
void |
setItemsPerPage(int v)
Sets the number of items that will be returned per page for paged feeds. |
|
void |
setKind(java.lang.String v)
Sets the current gd:kind attribute value for this feed. |
|
void |
setService(Service v)
Sets that GData Service instance associated with this feed. |
|
void |
setStartIndex(int v)
Sets the starting index of the contained entries for paged feeds. |
|
void |
setTotalResults(int v)
Sets the total number of results associated with this feed. |
|
void |
setVersionId(java.lang.String v)
Sets the entity version for this feed. |
|
protected void |
visitChildren(ExtensionVisitor ev)
Called to visit all children of this extension point. |
|
| Methods inherited from class com.google.gdata.data.Source |
|---|
addHtmlLink, addLink, addLink, generateInnerAtom, getAuthors, getCategories, getContributors, getGenerator, getHtmlLink, getIcon, getId, getLink, getLinks, getLinks, getLogo, getRights, getSubtitle, getTitle, getUpdated, removeLinks, removeLinks, setGenerator, setGenerator, setIcon, setId, setLogo, setRights, setSubtitle, setTitle, setUpdated |
| Methods inherited from class com.google.gdata.data.AbstractExtension |
|---|
consumeAttributes, eq, generateAttributes, getExtensionLocalName, getExtensionNamespace, isImmutable, putAttributes, sameClassAs, setImmutable, throwExceptionForMissingAttribute, throwExceptionIfImmutable, validate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.google.gdata.data.IFeed |
|---|
getGenerator, getLogo, getSubtitle, setGenerator, setLogo |
| Methods inherited from interface com.google.gdata.data.IAtom |
|---|
addLink, getAuthors, getCategories, getId, getLink, getLinks, getTitle, getUpdated, removeLinks, removeLinks, setId, setUpdated |
| Field Detail |
|---|
protected BaseFeed.FeedState feedState
protected java.lang.Class<? extends E extends BaseEntry> entryClass
protected java.util.List<E extends BaseEntry> entries
| Constructor Detail |
|---|
protected BaseFeed(java.lang.Class<? extends E> entryClass)
BaseFeed.FeedState. Kind.Adaptor subclasses
of BaseFeed can use this constructor to create adaptor
instances of an entry that share state with the original.
entryClass - Class used to construct new Entry instances for the Feed.
protected BaseFeed(java.lang.Class<? extends E> entryClass,
BaseFeed<?,?> sourceFeed)
BaseFeed.FeedState. Kind.Adaptor subclasses
of BaseFeed can use this constructor to create adaptor
instances of a feed that share state with the original.
| Method Detail |
|---|
public void declareExtensions(ExtensionProfile extProfile)
The implementation of this method for BaseFeed will declare any extensions associated with the contained entry type.
declareExtensions in interface Kind.AdaptordeclareExtensions in class ExtensionPointextProfile - the ExtensionProfile to initialize.ExtensionProfile.addDeclarations(Kind.Adaptor)public Service getService()
Service instance associated with this feed.
public void setService(Service v)
Service instance associated with this feed.
setService in interface IAtompublic boolean getCanPost()
getCanPost in interface IFeedpublic void setCanPost(boolean v)
setCanPost in interface IFeedpublic void setVersionId(java.lang.String v)
null
the last modified date is used to generate the etag.
setVersionId in interface IAtompublic java.lang.String getVersionId()
getVersionId in interface IAtompublic java.lang.String getEtag()
null indicates the value is unknown.
getEtag in interface IAtompublic void setEtag(java.lang.String v)
null indicates the value is unknown.
setEtag in interface IAtompublic java.lang.String getKind()
null indicates the value is unknown.
getKind in interface IAtompublic void setKind(java.lang.String v)
null indicates the value is unknown.
setKind in interface IAtompublic int getTotalResults()
Query.UNDEFINED indicates the total size is undefined.
getTotalResults in interface IFeedpublic void setTotalResults(int v)
Query.UNDEFINED indicates the total size is undefined.
setTotalResults in interface IFeedpublic int getStartIndex()
Query.UNDEFINED indicates the start index is undefined.
getStartIndex in interface IFeedpublic void setStartIndex(int v)
Query.UNDEFINED indicates the start index is undefined.
setStartIndex in interface IFeedpublic int getItemsPerPage()
Query.UNDEFINED indicates the page item count is
undefined.
getItemsPerPage in interface IFeedpublic void setItemsPerPage(int v)
Query.UNDEFINED indicates the page item count is
undefined.
setItemsPerPage in interface IFeedpublic java.util.List<E> getEntries()
getEntries in interface IFeedpublic void setEntries(java.util.List<E> entryList)
public void addAdaptor(Kind.Adaptor adaptor)
Kind.AdaptableKind.Adaptor with this Adaptable instance.
addAdaptor in interface Kind.Adaptablepublic java.util.Collection<Kind.Adaptor> getAdaptors()
Kind.AdaptableKind.Adaptor instances associated with the
this Adaptable instance.
getAdaptors in interface Kind.Adaptablepublic <A extends Kind.Adaptor> A getAdaptor(java.lang.Class<A> adaptorClass)
Kind.AdaptableKind.Adaptor instance associated with this
Adaptable instance of the specified type, or {code null}
if none is available..
getAdaptor in interface Kind.Adaptablepublic E createEntry()
createEntry in interface IFeedpublic Link getEntryPostLink()
getEntryPostLink in interface IFeedpublic Link getSelfLink()
getSelfLink in interface IAtompublic Link getNextLink()
getNextLink in interface IFeednull for none.public Link getPreviousLink()
getPreviousLink in interface IFeednull for none.public Link getFeedBatchLink()
getFeedBatchLink in interface IFeednull
for none.
public F getSelf()
throws java.io.IOException,
ServiceException
java.io.IOException
ServiceException
public <T extends E> T insert(T newEntry)
throws ServiceException,
java.io.IOException
ServiceException - If there is no associated GData service or the service is
unable to perform the insertion.
java.lang.UnsupportedOperationException - If insert is not supported for the target feed.
java.io.IOException - If there is an error communicating with the GData service.
protected void visitChildren(ExtensionVisitor ev)
throws ExtensionVisitor.StoppedException
ExtensionPoint
visitChildren in class ExtensionPointev - the extension visitor.
ExtensionVisitor.StoppedException
public void generate(com.google.gdata.util.common.xml.XmlWriter w,
ExtensionProfile p)
throws java.io.IOException
Extension
generate in interface Extensiongenerate in class AbstractExtensionw - XML writerp - extension profile
java.io.IOException
public void generateAtom(com.google.gdata.util.common.xml.XmlWriter w,
ExtensionProfile extProfile)
throws java.io.IOException
generateAtom in class Sourcew - Output writer.extProfile - Extension profile.
java.io.IOException
public void generateFeedEnd(com.google.gdata.util.common.xml.XmlWriter w)
throws java.io.IOException
generateFeedStart(com.google.gdata.data.ExtensionProfile, com.google.gdata.util.common.xml.XmlWriter, java.util.Collection) .
w -
java.io.IOException
public void generateFeedStart(ExtensionProfile extProfile,
com.google.gdata.util.common.xml.XmlWriter w,
java.util.Collection<com.google.gdata.util.common.xml.XmlNamespace> namespaces)
throws java.io.IOException
generateFeedStart(), write the
entries, and then call
generateFeedEnd(com.google.gdata.util.common.xml.XmlWriter)
to avoid having to add entries to a list and keep them in memory.
extProfile - w - namespaces - extra namespace declarations
java.io.IOException
public void generateRss(com.google.gdata.util.common.xml.XmlWriter w,
ExtensionProfile extProfile)
throws java.io.IOException
w - Output writer.extProfile - Extension profile.
java.io.IOException
public static BaseFeed<?,?> readFeed(ParseSource source)
throws java.io.IOException,
ParseException,
ServiceException
ParseSource.
The return type of the feed will be determined using dynamic adaptation
based upon any Kind category tag found in the input content. If
no kind tag is found a Feed instance will be returned.
java.io.IOException
ParseException
ServiceException
public static <F extends BaseFeed> F readFeed(ParseSource source,
java.lang.Class<F> feedClass,
ExtensionProfile extProfile)
throws java.io.IOException,
ParseException,
ServiceException
java.io.IOException
ParseException
ServiceException
public void parseAtom(ExtensionProfile extProfile,
java.io.InputStream input)
throws java.io.IOException,
ParseException
parseAtom in class SourceextProfile - Extension profile.input - XML input stream.
java.io.IOException
ParseException
public void parseAtom(ExtensionProfile extProfile,
java.io.Reader reader)
throws java.io.IOException,
ParseException
parseAtom in class SourceextProfile - Extension profile.reader - XML Reader. The caller is responsible for ensuring that
the character encoding is correct.
java.io.IOException
ParseException
public void parseAtom(ExtensionProfile extProfile,
XmlEventSource source)
throws java.io.IOException,
ParseException
extProfile - Extension profile.source - XML source.
java.io.IOException
ParseException
public XmlParser.ElementHandler getHandler(ExtensionProfile p,
java.lang.String namespace,
java.lang.String localName,
org.xml.sax.Attributes attrs)
throws ParseException
AbstractExtensionAbstractExtension.AttributesHandler to handle
parsing the extension.
getHandler in interface ExtensiongetHandler in class ExtensionPointp - extension profilenamespace - extension namespacelocalName - tag name, without the namespace prefixattrs - tag attributes
ParseException - when an unexpected tag or badly-formatted
XML is detected
public BaseFeed<?,?> getAdaptedFeed()
throws Kind.AdaptorException
Kind.Adaptor feed
subtype for this feed. If none can be found for the current class,
null will be returned.
Kind.AdaptorExceptionpublic <T extends BaseEntry> java.util.List<T> getEntries(java.lang.Class<T> returnClass)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||