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.
Source.Generator
Modifier and Type | Field and Description |
---|---|
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.
|
Constructor and Description |
---|
Feed()
Constructs a new Feed instance, using default metadata.
|
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.
|
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.
|
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, setUpdated
addElement, addElement, addElement, clear, createElement, createElement, 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, setAttributeValue, setAttributeValue, setElement, setElement, setElement, setTextValue, toString, visit
getGenerator, getLogo, getSubtitle, setGenerator, setLogo
addLink, getAuthors, getCategories, getId, getLink, getLinks, getTitle, getUpdated, removeLinks, setId, setUpdated
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
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.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 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
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.public Element resolve(ElementMetadata<?,?> metadata, ValidationContext vc)
Element
public <T extends Entry> java.util.List<T> getEntries(java.lang.Class<T> returnClass)