public class Feed extends Source implements IFeed
<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.
| Modifier and Type | Class and Description |
|---|---|
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.
|
Source.Generator| Modifier and Type | Field and Description |
|---|---|
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.
|
| Modifier | Constructor and Description |
|---|---|
|
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. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
<E extends Entry> |
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
|
<T extends Entry> |
getEntries(java.lang.Class<T> returnClass)
Gets a list of entries of a particular kind.
|
protected <T extends Entry> |
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.
|
<T extends Entry> |
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.
|
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, setUpdatedadapt, adapt, addElement, addElement, addElement, clear, createElement, createElement, eq, equals, getAttributeCount, getAttributeIterator, getAttributeIterator, getAttributeValue, getAttributeValue, getDefaultKey, getElement, getElement, getElementCount, getElementId, getElementIterator, getElementIterator, getElementKey, getElements, getElements, getElementSet, getElementSet, getElementValue, getElementValue, getTextValue, getTextValue, hasAttribute, hasAttribute, hasElement, hasElement, hashCode, hasTextValue, isLocked, lock, removeAttribute, removeAttribute, removeAttributeValue, removeAttributeValue, removeElement, removeElement, removeElement, removeElement, replaceElement, resolve, sameClassAs, setAttributeValue, setAttributeValue, setElement, setElement, setElement, setTextValue, toString, validate, visitclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetGenerator, getLogo, getSubtitle, setGenerator, setLogoaddLink, getAuthors, getCategories, getId, getLink, getLinks, getTitle, getUpdated, removeLinks, setId, setUpdatedpublic 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
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.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 IAtompublic boolean getCanPost()
getCanPost in interface IFeedpublic void setCanPost(boolean v)
setCanPost in interface IFeedpublic java.lang.String getVersionId()
getVersionId in interface IAtompublic void setVersionId(java.lang.String v)
null,
the updated time will be used instead to generate an etag.setVersionId in interface IAtompublic java.lang.String getEtag()
GdAttributes.ETAG value for this feed. A value of
null indicates the value is unknown.public void setEtag(java.lang.String v)
GdAttributes.ETAG value for this feed. A value of
null indicates the value is unknown.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.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.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 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<? extends Entry> getEntries()
getEntries in interface IFeedprotected <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 IFeedpublic <E extends Entry> E createEntry(ElementKey<?,E> entryKey)
public 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 Feed getSelf() throws java.io.IOException, ServiceException
java.io.IOExceptionServiceExceptionpublic void removeLinks()
removeLinks in interface IAtompublic <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)
public Element resolve(ElementMetadata<?,?> metadata, ValidationContext vc)
Elementpublic <T extends Entry> java.util.List<T> getEntries(java.lang.Class<T> returnClass)