|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.model.Element
com.google.gdata.model.atom.Source
com.google.gdata.model.atom.Feed
public class Feed
The Feed class is a 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 other gdata
standard elements.
The Feed Class contains all the necessary parsing and generation code for feed data, but can be subclassed to create subtypes that contain convenience APIs for accessing additional elements and entries.
An instance can be initialized by directly initializing its component elements.
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
from the Source
class.
Nested Class Summary | |
---|---|
protected static class |
Feed.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 Feed subtypes. |
Nested classes/interfaces inherited from class com.google.gdata.model.atom.Source |
---|
Source.Generator |
Field Summary | |
---|---|
protected Feed.FeedState |
feedState
Basic state for this feed. |
static ElementKey<java.lang.Integer,Element> |
ITEMS_PER_PAGE
The opensearch:itemsPerPage element. |
static ElementKey<java.lang.Void,Feed> |
KEY
The key for this element. |
static ElementKey<java.lang.Integer,Element> |
START_INDEX
The opensearch:startIndex element. |
static ElementKey<java.lang.Integer,Element> |
TOTAL_RESULTS
The opensearch:totalResults element. |
static AttributeKey<java.net.URI> |
XML_BASE
The xml:base attribute. |
Fields inherited from class com.google.gdata.model.atom.Source |
---|
CONSTRUCT, ICON, ID, LOGO, RIGHTS, SUBTITLE, TITLE, UPDATED |
Constructor Summary | |
---|---|
|
Feed()
Constructs a new Feed instance, using default metadata. |
protected |
Feed(ElementKey<?,? extends Feed> key)
Creates a new feed instance using the specified metadata. |
protected |
Feed(ElementKey<?,? extends Feed> key,
Feed source)
Copy constructor that initializes a new Feed instance to have identical contents to another instance, using a shared reference to the same Feed.FeedState . |
Method Summary | ||
---|---|---|
void |
addEntry(Entry entry)
Adds an entry to this feed. |
|
void |
clearEntries()
Clears the list of entries on this feed. |
|
Entry |
createEntry()
Creates a new entry for the feed. |
|
|
createEntry(ElementKey<?,E> entryKey)
Creates a new entry for the feed. |
|
boolean |
getCanPost()
Gets the property that indicates if it is possible to post new entries to the feed. |
|
java.util.List<? extends Entry> |
getEntries()
Returns the list of entries in this feed |
|
|
getEntries(java.lang.Class<T> returnClass)
Gets a list of entries of a particular kind. |
|
protected
|
getEntries(ElementKey<?,T> key)
Returns a list of entries matching the given entry key. |
|
Link |
getEntryPostLink()
Returns the entry post link for the feed. |
|
java.lang.String |
getEtag()
Returns the GdAttributes.ETAG 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. |
|
int |
getItemsPerPage()
Gets the number of items that will be returned per page for paged feeds. |
|
java.lang.String |
getKind()
Returns the GdAttributes.KIND 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. |
|
java.lang.String |
getSelectedFields()
Returns the GdAttributes.FIELDS value for this feed. |
|
Feed |
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 tassociated 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 resource version id for this feed. |
|
java.net.URI |
getXmlBase()
Returns the current xml:base attribute for this feed. |
|
|
insert(T newEntry)
Inserts a new Entry into the feed, if the feed is currently associated with a Service. |
|
protected Element |
narrow(ElementMetadata<?,?> meta,
ValidationContext vc)
Narrows this feed using categories with an appropriate kind value. |
|
static void |
registerMetadata(MetadataRegistry registry)
Registers the metadata for this element. |
|
boolean |
removeEntry(Entry entry)
Removes a single entry from this feed. |
|
void |
removeLinks()
Removes all links. |
|
Element |
resolve(ElementMetadata<?,?> metadata,
ValidationContext vc)
Resolve this element's state against the metadata. |
|
void |
setCanPost(boolean v)
Sets the property that indicates if it is possible to post new entries to the feed. |
|
void |
setEntries(java.util.Collection<? extends Entry> entries)
Sets the entries in this feed to the given entries. |
|
void |
setEtag(java.lang.String v)
Sets the GdAttributes.ETAG 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 GdAttributes.KIND value for this feed. |
|
void |
setSelectedFields(java.lang.String v)
Sets the GdAttributes.FIELDS 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)
Set the resource version id for this feed. |
|
void |
setXmlBase(java.net.URI v)
Sets the current xml:base attribute for this feed. |
Methods inherited from class com.google.gdata.model.atom.Source |
---|
addAuthor, addAuthors, addCategory, addContributor, addContributors, addHtmlLink, addLink, addLink, clearAuthors, clearCategories, clearContributors, clearLinks, getAuthors, getCategories, getContributors, getGenerator, getHtmlLink, getIcon, getIconUri, getId, getLink, getLinks, getLinks, getLogo, getLogoUri, getRights, getSubtitle, getTitle, getUpdated, removeAuthor, removeContributor, removeLink, removeLinks, setGenerator, setGenerator, setIcon, setIcon, setId, setLogo, setLogo, setRights, setSubtitle, setTitle, setUpdated |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, 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, setId, setUpdated |
Field Detail |
---|
public static final ElementKey<java.lang.Void,Feed> KEY
public static final AttributeKey<java.net.URI> XML_BASE
public static final ElementKey<java.lang.Integer,Element> ITEMS_PER_PAGE
public static final ElementKey<java.lang.Integer,Element> START_INDEX
public static final ElementKey<java.lang.Integer,Element> TOTAL_RESULTS
protected final Feed.FeedState feedState
Constructor Detail |
---|
public Feed()
protected Feed(ElementKey<?,? extends Feed> key)
key
- the feed key.protected Feed(ElementKey<?,? extends Feed> key, Feed source)
Feed.FeedState
. Subclasses of Feed
can use this constructor to
create adaptor instances of a feed that share state with the original but
use a different set of metadata.
Method Detail |
---|
public static void registerMetadata(MetadataRegistry registry)
public Service getService()
Service
instance tassociated with this feed.
public void setService(Service v)
Service
instance associated with this feed.
setService
in interface IAtom
public boolean getCanPost()
getCanPost
in interface IFeed
public void setCanPost(boolean v)
setCanPost
in interface IFeed
public java.lang.String getVersionId()
getVersionId
in interface IAtom
public void setVersionId(java.lang.String v)
null
,
the updated time will be used instead to generate an etag.
setVersionId
in interface IAtom
public java.lang.String getEtag()
GdAttributes.ETAG
value for this feed. A value of
null
indicates the value is unknown.
getEtag
in interface IAtom
public void setEtag(java.lang.String v)
GdAttributes.ETAG
value for this feed. A value of
null
indicates the value is unknown.
setEtag
in interface IAtom
public java.lang.String getKind()
GdAttributes.KIND
value for this feed. The kind
attribute may be null if this feed does not have a kind.
getKind
in interface IAtom
public void setKind(java.lang.String v)
GdAttributes.KIND
value for this feed. The kind may be set
to null to remove the attribute value.
setKind
in interface IAtom
public java.lang.String getSelectedFields()
GdAttributes.FIELDS
value for this feed. The
fields attribute may be null if this feed contains a full representation.
public void setSelectedFields(java.lang.String v)
GdAttributes.FIELDS
value for this feed. The fields
attribute may be set to null to remove the attribute value.
public java.net.URI getXmlBase()
null
if this feed does not have an xml:base.
public void setXmlBase(java.net.URI v)
null
to remove the attribute value.
public int getTotalResults()
Query.UNDEFINED
indicates the total size is undefined.
getTotalResults
in interface IFeed
public void setTotalResults(int v)
Query.UNDEFINED
indicates the total size is undefined.
setTotalResults
in interface IFeed
public int getStartIndex()
Query.UNDEFINED
indicates the start index is undefined.
getStartIndex
in interface IFeed
public void setStartIndex(int v)
Query.UNDEFINED
indicates the start index is undefined.
setStartIndex
in interface IFeed
public int getItemsPerPage()
Query.UNDEFINED
indicates the page item count is
undefined.
getItemsPerPage
in interface IFeed
public void setItemsPerPage(int v)
Query.UNDEFINED
indicates the page item count is
undefined.
setItemsPerPage
in interface IFeed
public java.util.List<? extends Entry> getEntries()
getEntries
in interface IFeed
protected <T extends Entry> java.util.List<T> getEntries(ElementKey<?,T> key)
public void setEntries(java.util.Collection<? extends Entry> entries)
public void clearEntries()
public void addEntry(Entry entry)
public boolean removeEntry(Entry entry)
public Entry createEntry()
createEntry
in interface IFeed
public <E extends Entry> E createEntry(ElementKey<?,E> entryKey)
public Link getEntryPostLink()
getEntryPostLink
in interface IFeed
public Link getSelfLink()
getSelfLink
in interface IAtom
public Link getNextLink()
getNextLink
in interface IFeed
null
for none.public Link getPreviousLink()
getPreviousLink
in interface IFeed
null
for none.public Link getFeedBatchLink()
getFeedBatchLink
in interface IFeed
null
for none.public Feed getSelf() throws java.io.IOException, ServiceException
java.io.IOException
ServiceException
public void removeLinks()
removeLinks
in interface IAtom
public <T extends Entry> 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 Element narrow(ElementMetadata<?,?> meta, ValidationContext vc)
narrow
in class Element
meta
- the element metadata to narrow to.vc
- validation context
public Element resolve(ElementMetadata<?,?> metadata, ValidationContext vc)
Element
resolve
in class Element
vc
- validation context
public <T extends Entry> 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 |