public class

Entry

extends Element
implements IEntry
java.lang.Object
   ↳ com.google.gdata.model.Element
     ↳ com.google.gdata.model.atom.Entry
Known Direct Subclasses

Class Overview

The Entry class is a base class that defines the in-memory object model for GData entries.

Entry subclasses should expose convenience APIs to retrieve and set attributes or subelements, with implementations that delegate to Element methods to store/retrieve the appropriate data.

Here is the Relax-NG schema that represents an Atom 1.0 entry:

 atomEntry =
   element atom:entry {
     atomCommonAttributes,
     (atomAuthor*
     & atomCategory*
     & atomContent?
     & atomContributor*
     & atomId
     & atomLink*
     & atomPublished?
     & atomRights?
     & atomSource?
     & atomSummary?
     & atomTitle
     & atomUpdated
     & extensionElement*)
 

Summary

Nested Classes
class Entry.EntryState The EntryState class provides a simple structure that encapsulates the attributes of an Atom entry that should be shared with a shallow copy if the entry is adapted to a more specific Entry subtype. 
Fields
public static final ElementKey<String, Element> ID The atom:id child element
public static final ElementKey<Void, Entry> KEY The key for this element.
public static final ElementKey<DateTimeElement> PUBLISHED The atom:published child element
public static final ElementKey<String, TextContent> RIGHTS The atom:rights child element
public static final ElementKey<String, TextContent> SUMMARY The atom:summary child element.
public static final ElementKey<String, TextContent> TITLE The atom:title child element
public static final ElementKey<DateTimeElement> UPDATED The atom:updated child element
protected Entry.EntryState state Basic state for this entry.
[Expand]
Inherited Fields
From class com.google.gdata.model.Element
Public Constructors
Entry()
Constructs a new Entry instance, using default metadata.
Protected Constructors
Entry(ElementKey<?, ? extends Entry> key)
Constructs a new Entry instance, using the given key.
Entry(ElementKey<?, ? extends Entry> key, Entry source)
Copy constructor that initializes a new Entry instance to have identical contents to another instance, using a shared reference to the same Entry.EntryState.
Public Methods
void addAuthor(Person v)
void addCategory(Category v)
void addContributor(Person v)
void addHtmlLink(String htmlUri, String lang, String title)
Adds a link pointing to an HTML representation.
void addLink(Link v)
Link addLink(String rel, String type, String href)
Adds a link with the given rel, type, and href.
void clearAuthors()
void clearCategories()
void clearContributors()
void delete()
Deletes this entry by sending a request to the associated GData service.
List<Person> getAuthors()
Returns the list of all authors on this resource.
boolean getCanEdit()
Returns true if the entry can be modified by a client.
Set<Category> getCategories()
Returns a set of categories on this resource.
Content getContent()
Gets the content of this entry.
List<Person> getContributors()
Control getControl()
Gets the app:control tag.
Link getEditLink()
Retrieves the resource edit link.
DateTime getEdited()
Get a DateTime instance representing the last time this entry was edited.
String getEtag()
Returns the ETAG value for this feed.
Link getHtmlLink()
Retrieves the first HTML link.
String getId()
Get the unique id for this resource.
String getKind()
Returns the KIND value for this entry.
Link getLink(String rel, String type)
Retrieves the first link with the supplied rel and/or type value.
List<Link> getLinks()
Returns a list of atom:link elements on this resource.
List<Link> getLinks(String relToMatch, String typeToMatch)
Return the links that match the given rel and type values.
Link getMediaEditLink()
Retrieves the media resource edit link.
String getPlainTextContent()
Assumes the element's contents are plain-text and returns its value as a string
DateTime getPublished()
Get a DateTime instance representing the time that this entry was created.
Link getResumableEditMediaLink()
Retrieves the media resource resumable edit link.
TextContent getRights()
String getSelectedFields()
Returns the FIELDS value for this entry.
Entry getSelf()
Retrieves the current version of this Entry by requesting it from the associated GData service.
Link getSelfLink()
Retrieves the resource access link.
Service getService()
Source getSource()
TextContent getSummary()
Returns the atom:summary element of this entry.
TextContent getTextContent()
Assumes the content element's contents are text and returns them as a TextContent.
TextContent getTitle()
Returns the atom:title element of this resource.
DateTime getUpdated()
Get a DateTime instance representing the last time this resource was updated.
String getVersionId()
Version ID.
boolean hasControl()
Returns whether it has the Atom publication control status.
boolean isDraft()
Draft status.
static void registerMetadata(MetadataRegistry registry)
Registers the metadata for this element.
boolean removeAuthor(Person v)
void removeContent()
Removes any content element.
boolean removeContributor(Person v)
boolean removeLink(Link link)
void removeLinks()
Removes all links from the this resource.
void removeLinks(String relToMatch, String typeToMatch)
Remove all links that match the given rel and type values.
void setCanEdit(boolean v)
Sets whether the server allows this entry to be modified by the client.
void setContent(Content v)
Entry setControl(Control value)
Sets the app:control tag, which usually contains app:draft.
void setDraft(Boolean v)
Set draft status.
void setEdited(DateTime v)
Set the last time this entry was edited using the app:edited element.
void setEtag(String v)
Sets the ETAG value for this entry.
void setId(String v)
Sets the unique id for this resource.
void setKind(String v)
Sets the KIND value for this entry.
void setPublished(DateTime v)
Sets the date of publishing for this entry.
void setRights(TextContent v)
void setSelectedFields(String v)
Sets theFIELDS value for this entry.
void setService(Service s)
Sets the service that this resource is being used with.
void setSource(Source v)
void setSummary(TextContent v)
void setTitle(TextContent v)
void setUpdated(DateTime v)
Sets the last time this resource was updated.
void setVersionId(String v)
Sets the versionId.
Entry update()
Updates this entry by sending the current representation to the associated GData service.
Protected Methods
Element narrow(ElementMetadata<?, ?> metadata, ValidationContext vc)
Narrows this entry using categories with an appropriate kind value.
[Expand]
Inherited Methods
From class com.google.gdata.model.Element
From class java.lang.Object
From interface com.google.gdata.data.IAtom
From interface com.google.gdata.data.IEntry

Fields

public static final ElementKey<String, Element> ID

The atom:id child element

public static final ElementKey<Void, Entry> KEY

The key for this element.

public static final ElementKey<DateTimeElement> PUBLISHED

The atom:published child element

public static final ElementKey<String, TextContent> RIGHTS

The atom:rights child element

public static final ElementKey<String, TextContent> SUMMARY

The atom:summary child element.

public static final ElementKey<String, TextContent> TITLE

The atom:title child element

public static final ElementKey<DateTimeElement> UPDATED

The atom:updated child element

protected Entry.EntryState state

Basic state for this entry. May be shared across multiple adapted instances associated with the same logical entry.

Public Constructors

public Entry ()

Constructs a new Entry instance, using default metadata.

Protected Constructors

protected Entry (ElementKey<?, ? extends Entry> key)

Constructs a new Entry instance, using the given key.

Parameters
key

protected Entry (ElementKey<?, ? extends Entry> key, Entry source)

Copy constructor that initializes a new Entry instance to have identical contents to another instance, using a shared reference to the same Entry.EntryState. Subclasses of Entry can use this constructor to create adaptor instances of an entry that share state with the original.

Parameters
key The element key to use for this entry.
source To copy data from

Public Methods

public void addAuthor (Person v)

Parameters
v

public void addCategory (Category v)

Parameters
v

public void addContributor (Person v)

Parameters
v

public void addHtmlLink (String htmlUri, String lang, String title)

Adds a link pointing to an HTML representation.

Parameters
htmlUri Link URI.
lang Optional language code.
title Optional title.

public void addLink (Link v)

Parameters
v

public Link addLink (String rel, String type, String href)

Adds a link with the given rel, type, and href.

Parameters
rel
type
href

public void clearAuthors ()

public void clearCategories ()

public void clearContributors ()

public void delete ()

Deletes this entry by sending a request to the associated GData service.

Throws
ServiceException If there is no associated GData service or the service is unable to perform the deletion.
UnsupportedOperationException If deletion is not supported for the target entry.
IOException If there is an error communicating with the GData service.

public List<Person> getAuthors ()

Returns the list of all authors on this resource.

public boolean getCanEdit ()

Returns true if the entry can be modified by a client.

public Set<Category> getCategories ()

Returns a set of categories on this resource.

public Content getContent ()

Gets the content of this entry. Represents the atom:content element.

public List<Person> getContributors ()

public Control getControl ()

Gets the app:control tag.

Returns
  • pub control tag or null if unset

public Link getEditLink ()

Retrieves the resource edit link.

public DateTime getEdited ()

Get a DateTime instance representing the last time this entry was edited. Represents the app:edited element.

public String getEtag ()

Returns the ETAG value for this feed. A value of null indicates the value is unknown.

public Link getHtmlLink ()

Retrieves the first HTML link.

public String getId ()

Get the unique id for this resource. Represents the atom:id element.

public String getKind ()

Returns the KIND value for this entry. The kind attribute may be null if this feed does not have a kind.

public Link getLink (String rel, String type)

Retrieves the first link with the supplied rel and/or type value.

If either parameter is null, doesn't return matches for that parameter.

Parameters
rel Link relation
type Link type
Returns
  • link

public List<Link> getLinks ()

Returns a list of atom:link elements on this resource. If there are no links, an empty list will be returned.

public List<Link> getLinks (String relToMatch, String typeToMatch)

Return the links that match the given rel and type values.

Parameters
relToMatch rel value to match or null to match any rel value.
typeToMatch type value to match or null to match any type value.
Returns
  • matching links.

public Link getMediaEditLink ()

Retrieves the media resource edit link.

public String getPlainTextContent ()

Assumes the element's contents are plain-text and returns its value as a string

Returns
  • A string containing the plain-text value of the content tag.
Throws
IllegalStateException If the content element is not a text type.

public DateTime getPublished ()

Get a DateTime instance representing the time that this entry was created. Represents the atom:published element.

public Link getResumableEditMediaLink ()

Retrieves the media resource resumable edit link.

public TextContent getRights ()

public String getSelectedFields ()

Returns the FIELDS value for this entry. The fields attribute may be null if this entry contains a full representation.

public Entry getSelf ()

Retrieves the current version of this Entry by requesting it from the associated GData service.

Returns
  • the current version of the entry.
Throws
IOException on IO error during retrieval from the service.
ServiceException if there is a problem retrieving the element.

public Link getSelfLink ()

Retrieves the resource access link.

public Service getService ()

public Source getSource ()

public TextContent getSummary ()

Returns the atom:summary element of this entry.

public TextContent getTextContent ()

Assumes the content element's contents are text and returns them as a TextContent.

Returns
  • A TextContent containing the value of the content tag.
Throws
IllegalStateException If the content element is not a text type.

public TextContent getTitle ()

Returns the atom:title element of this resource.

public DateTime getUpdated ()

Get a DateTime instance representing the last time this resource was updated. Represents the atom:updated element.

public String getVersionId ()

Version ID. This is a unique number representing this particular resource. Every update changes the version ID (unless the update doesn't modify anything, in which case it's permissible for version ID to stay the same). Services are free to interpret this string in the most convenient way. Some services may choose to use a monotonically increasing sequence of version IDs. Other services may compute a hash of entry properties or feed content and use that.

This property is only used for services to communicate the current version ID back to the servlet. It is NOT set when resources are parsed (either from requests or from arbitrary XML).

public boolean hasControl ()

Returns whether it has the Atom publication control status.

Returns
  • whether it has the Atom publication control status

public boolean isDraft ()

Draft status.

Returns
  • True if draft status is set and equals true.

public static void registerMetadata (MetadataRegistry registry)

Registers the metadata for this element.

Parameters
registry

public boolean removeAuthor (Person v)

Parameters
v

public void removeContent ()

Removes any content element. This method is equivalent to: setContent((Content) null); , but without the ugly cast.

public boolean removeContributor (Person v)

Parameters
v

public boolean removeLink (Link link)

Parameters
link

public void removeLinks ()

Removes all links from the this resource.

public void removeLinks (String relToMatch, String typeToMatch)

Remove all links that match the given rel and type values.

Parameters
relToMatch rel value to match or null to match any rel value.
typeToMatch type value to match or null to match any type value.

public void setCanEdit (boolean v)

Sets whether the server allows this entry to be modified by the client.

Parameters
v

public void setContent (Content v)

Parameters
v

public Entry setControl (Control value)

Sets the app:control tag, which usually contains app:draft.

Parameters
value Control the new object or null

public void setDraft (Boolean v)

Set draft status. Passing a null value means clearing the draft status.

Parameters
v Draft status, or null to clear.

public void setEdited (DateTime v)

Set the last time this entry was edited using the app:edited element.

Parameters
v

public void setEtag (String v)

Sets the ETAG value for this entry. A value of null indicates the value is unknown.

Parameters
v

public void setId (String v)

Sets the unique id for this resource.

Parameters
v

public void setKind (String v)

Sets the KIND value for this entry. The kind may be set to null to remove the attribute value.

Parameters
v

public void setPublished (DateTime v)

Sets the date of publishing for this entry. Used on the server to specify when the entry was created.

Parameters
v

public void setRights (TextContent v)

Parameters
v

public void setSelectedFields (String v)

Sets theFIELDS value for this entry. The fields attribute may be set to null to remove the attribute value.

Parameters
v

public void setService (Service s)

Sets the service that this resource is being used with.

Parameters
s

public void setSource (Source v)

Parameters
v

public void setSummary (TextContent v)

Parameters
v

public void setTitle (TextContent v)

Parameters
v

public void setUpdated (DateTime v)

Sets the last time this resource was updated.

Parameters
v

public void setVersionId (String v)

Sets the versionId. See getVersionId() for a description of what the versionId is used for.

Parameters
v

public Entry update ()

Updates this entry by sending the current representation to the associated GData service.

Returns
  • the updated entry returned by the Service.
Throws
ServiceException If there is no associated GData service or the service is unable to perform the update.
UnsupportedOperationException If update is not supported for the target entry.
IOException If there is an error communicating with the GData service.

Protected Methods

protected Element narrow (ElementMetadata<?, ?> metadata, ValidationContext vc)

Narrows this entry using categories with an appropriate kind value. This will loop through the categories, checking if they represent kinds, and adapting the entry to that kind of an appropriate adaptation was found. This will return the most specific subtype of the narrowed type that could be found.

Parameters
metadata The element metadata to narrow to.
vc Validation context
Returns
  • element narrowed down to the most specific type