com.google.gdata.model.atompub
Class Collection

java.lang.Object
  extended by com.google.gdata.model.Element
      extended by com.google.gdata.model.atompub.Collection
All Implemented Interfaces:
ICollection, Reference

public class Collection
extends Element
implements Reference, ICollection

The Collection class defines the basic Java object model representation and XML parsing/generation support for an APP collection.

The implementation is versioned to support the AtomPub draft version 9 introspection format (used for the GData v1 implementation) as well as the final RFC5023 format (used for all other versions). The key difference between the two is that draft used an attribute for the collection title and a comma-delimited list for accepted MIME types, where the final version uses atom:title and repeating app:accept elements.


Field Summary
static AttributeKey<java.lang.String> HREF
          The href attribute.
static ElementKey<java.lang.Void,Collection> KEY
          The key for this element.
static AttributeKey<java.lang.String> TITLE
          Qualified name of title attribute.
 
Constructor Summary
Collection()
          Default mutable constructor.
Collection(java.lang.String href)
          Construct a collection with the given href.
Collection(java.lang.String href, TextContent title, java.lang.String... accepts)
          Construct a collection with all fields.
 
Method Summary
 Collection addAccept(Accept accept)
          Adds a new accept element.
 Collection addAccept(java.lang.String accept)
          Adds a new accept string.
 Collection addCategories(Categories categories)
          Adds a new app categories document.
 java.util.List<java.lang.String> getAcceptList()
          Returns a list of accept strings.
 java.util.List<Accept> getAccepts()
          Returns the accept elements.
 java.util.List<Categories> getCategorieses()
          Returns the app categories documents.
 java.lang.String getHref()
          Returns the href.
 TextContent getTitle()
          Returns the title.
 boolean hasAccepts()
          Returns whether it has the accept elements.
 boolean hasCategorieses()
          Returns whether it has the app categories documents.
 boolean hasHref()
          Returns whether it has the href.
 boolean hasTitle()
          Returns whether it has the title.
static void registerMetadata(MetadataRegistry registry)
          Registers the metadata for this element.
 boolean removeAccept(Accept accept)
          Removes an accept element.
 boolean removeAccept(java.lang.String acceptStr)
          Removes an accept string.
 Element resolve(ElementMetadata<?,?> metadata, ValidationContext vc)
          Resolve this element's state against the metadata.
 void setHref(java.lang.String href)
          Sets the href.
 Collection setTitle(TextContent title)
          Sets the title.
 java.lang.String toString()
           
 
Methods inherited from class com.google.gdata.model.Element
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, visit
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY

public static final ElementKey<java.lang.Void,Collection> KEY
The key for this element.


HREF

public static final AttributeKey<java.lang.String> HREF
The href attribute.


TITLE

public static final AttributeKey<java.lang.String> TITLE
Qualified name of title attribute.

Constructor Detail

Collection

public Collection()
Default mutable constructor.


Collection

public Collection(java.lang.String href)
Construct a collection with the given href.

Parameters:
href - href.

Collection

public Collection(java.lang.String href,
                  TextContent title,
                  java.lang.String... accepts)
Construct a collection with all fields.

Method Detail

registerMetadata

public static void registerMetadata(MetadataRegistry registry)
Registers the metadata for this element.


getAccepts

public java.util.List<Accept> getAccepts()
Returns the accept elements.

Returns:
accept elements

getAcceptList

public java.util.List<java.lang.String> getAcceptList()
Returns a list of accept strings.

Specified by:
getAcceptList in interface ICollection

addAccept

public Collection addAccept(Accept accept)
Adds a new accept element.

Parameters:
accept - accept element

addAccept

public Collection addAccept(java.lang.String accept)
Adds a new accept string.

Parameters:
accept - accept string

removeAccept

public boolean removeAccept(Accept accept)
Removes an accept element.

Parameters:
accept - accept element
Returns:
true if the accept was removed

removeAccept

public boolean removeAccept(java.lang.String acceptStr)
Removes an accept string.

Parameters:
acceptStr - the string to remove
Returns:
true if the acceptStr was removed.

hasAccepts

public boolean hasAccepts()
Returns whether it has the accept elements.

Returns:
whether it has the accept elements

getCategorieses

public java.util.List<Categories> getCategorieses()
Returns the app categories documents.

Returns:
app categories documents

addCategories

public Collection addCategories(Categories categories)
Adds a new app categories document.

Parameters:
categories - app categories document

hasCategorieses

public boolean hasCategorieses()
Returns whether it has the app categories documents.

Returns:
whether it has the app categories documents

getHref

public java.lang.String getHref()
Returns the href.

Specified by:
getHref in interface Reference
Returns:
href

setHref

public void setHref(java.lang.String href)
Sets the href.

Specified by:
setHref in interface Reference
Parameters:
href - href or null to reset

hasHref

public boolean hasHref()
Returns whether it has the href.

Returns:
whether it has the href

getTitle

public TextContent getTitle()
Returns the title.

Specified by:
getTitle in interface ICollection
Returns:
title

setTitle

public Collection setTitle(TextContent title)
Sets the title.

Parameters:
title - title or null to reset

hasTitle

public boolean hasTitle()
Returns whether it has the title.

Returns:
whether it has the title

resolve

public Element resolve(ElementMetadata<?,?> metadata,
                       ValidationContext vc)
Description copied from class: Element
Resolve this element's state against the metadata. Accumulates errors in caller's validation context.

Overrides:
resolve in class Element
vc - validation context
Returns:
the narrowed element if narrowing took place.

toString

public java.lang.String toString()
Overrides:
toString in class Element