com.google.gdata.data
Class ExtensionPoint

java.lang.Object
  extended by com.google.gdata.data.AbstractExtension
      extended by com.google.gdata.data.ExtensionPoint
All Implemented Interfaces:
Extension
Direct Known Subclasses:
AbstractMediaResource, AclWithKey, Aggregates, AnyoneCanAddSelfProperty, ArchiveConversion, BaseEntry, BatchInterrupted, BatchOperation, BatchStatus, BlockedOn, Blocking, CalendarLink, Categories, Cc, Changestamp, Collection, Column, Comments, Commission, ContinuityOfCareRecord, CostBasis, CustomVariable, Data, DataSource, DaysGain, Destination, Dimension, DocumentSource, Email, Email, EmailList, Engagement, Event, ExifTags, ExportFormat, ExtendedProperty, ExtensionDescription, ExternalId, Feature, File, Gain, Gender, GeoPt, GeoRssWhere, GlossariesElement, GmlEnvelope, GmlPoint, Goal, GphotoOriginalVideo, GroupMembershipInfo, GuestsCanInviteOthersProperty, GuestsCanModifyProperty, GuestsCanSeeGuestsProperty, Header, Im, Image, ImportFormat, InReplyTo, Label, Language, Link, Login, MarketValue, Match, MediaGroup, MergedInto, Metric, Money, Name, Name, Nickname, OpenSearchDescriptionDocument, Organization, OriginalEvent, Owner, Package, Person, PortfolioData, PositionData, Price, Priority, PrivateCopyProperty, ProfileMetaData, Property, Property, PubControl, Publish, PublishAuto, PublishOutsideDomain, QueryParameter, Quota, Rating, RecurrenceException, Reminder, Removed, Repository, Segment, SendAclNotificationsProperty, Sensitivity, ServiceDocument, SitemapMobile, SitemapNews, Source, Step, StructuredPostalAddress, Symbol, TimesCleanedProperty, TmsElement, TransactionData, Updates, UserDefinedField, W3CPoint, Website, When, Where, Who, Workspace, WritersCanInvite

public class ExtensionPoint
extends AbstractExtension

Base class for GData data types that support hosting extensions.

For example, a calendar <atom:entry> supports hosting <gd:when>.

The set of accepted extensions is defined within ExtensionManifest.


Nested Class Summary
 class ExtensionPoint.CumulativeBlobHandler
          Parser class for cumulative XML blobs.
 class ExtensionPoint.ExtensionHandler
          ElementHandler implementation for handlers associated with an ExtensionPoint class.
 
Constructor Summary
ExtensionPoint()
          Simple constructor to create a new (empty) ExtensionPoint.
 
Method Summary
 void addExtension(Extension ext)
          Adds an extension object.
 void addRepeatingExtension(Extension ext)
          Adds a repeating extension object.
 void declareExtensions(ExtensionProfile extProfile)
          Declares the set of expected Extension types for an ExtensionPoint within the target extension profile.
 XmlBlob generateCumulativeXmlBlob(ExtensionProfile extProfile)
          Generates an XML blob containing all recognized and unrecognized extensions.
<T extends Extension>
T
getExtension(java.lang.Class<T> extensionClass)
          Retrieves a non-repeating extension or null if not present.
 java.util.Collection<Extension> getExtensions()
          Returns an unmodifiable collection of non-repeating extensions in this ExtensionPoint.
 XmlParser.ElementHandler getHandler(ExtensionProfile p, java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs)
          The default implementation uses the AttributesHandler to handle parsing the extension.
<T extends Extension>
java.util.List<T>
getRepeatingExtension(java.lang.Class<T> extensionClass)
          Retrieves a repeating extension list (an empty list if not present).
 java.util.Collection<java.util.List<Extension>> getRepeatingExtensions()
          Returns an unmodifiable collection of lists of repeating extensions in this ExtensionPoint.
 XmlBlob getXmlBlob()
          Retrieves the XML blob containing arbitrary (unrecognized) extensions.
<T extends Extension>
boolean
hasExtension(java.lang.Class<T> extensionClass)
          Returns whether the non-repeating extension is present.
<T extends Extension>
boolean
hasRepeatingExtension(java.lang.Class<T> extensionClass)
          Returns whether the repeating extension is present.
 void parseCumulativeXmlBlob(XmlBlob blob, ExtensionProfile extProfile, java.lang.Class<? extends ExtensionPoint> extendedClass)
          Reverses generateCumulativeXmlBlob(ExtensionProfile).
 void removeExtension(java.lang.Class<? extends Extension> extensionClass)
          Removes an extension object based on its class.
 void removeExtension(Extension ext)
          Removes an extension object.
 void removeRepeatingExtension(Extension ext)
          Removes a repeating extension object.
 void setExtension(Extension ext)
          Sets an extension object.
 void setXmlBlob(XmlBlob xmlBlob)
          Sets the XML blob containing arbitrary (unrecognized) extensions.
 void visit(ExtensionVisitor ev, ExtensionPoint parent)
          Visits the tree of extension data associated with this extension point instance using the specified ExtensionVisitor, starting at this extension point.
 
Methods inherited from class com.google.gdata.data.AbstractExtension
disableStrictValidation, enableStrictValidation, generate, getExtensionLocalName, getExtensionNamespace, isImmutable, isStrictValidation, setImmutable
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionPoint

public ExtensionPoint()
Simple constructor to create a new (empty) ExtensionPoint.

Method Detail

declareExtensions

public void declareExtensions(ExtensionProfile extProfile)
Declares the set of expected Extension types for an ExtensionPoint within the target extension profile. The base implementation does not declare any extensions, but can be overridden by specific types of ExtensionPoints that always contain a well-defined set of extensions.

Parameters:
extProfile - the ExtensionProfile to initialize.

hasExtension

public final <T extends Extension> boolean hasExtension(java.lang.Class<T> extensionClass)
Returns whether the non-repeating extension is present.


hasRepeatingExtension

public final <T extends Extension> boolean hasRepeatingExtension(java.lang.Class<T> extensionClass)
Returns whether the repeating extension is present.


getExtension

public <T extends Extension> T getExtension(java.lang.Class<T> extensionClass)
Retrieves a non-repeating extension or null if not present.


getExtensions

public java.util.Collection<Extension> getExtensions()
Returns an unmodifiable collection of non-repeating extensions in this ExtensionPoint.

Returns:
Collection of non-repeating extensions.

getRepeatingExtension

public <T extends Extension> java.util.List<T> getRepeatingExtension(java.lang.Class<T> extensionClass)
Retrieves a repeating extension list (an empty list if not present).


getRepeatingExtensions

public java.util.Collection<java.util.List<Extension>> getRepeatingExtensions()
Returns an unmodifiable collection of lists of repeating extensions in this ExtensionPoint. The Extensions that are of the same type are grouped together in lists within the collection.

Returns:
Collection of lists of repeating extensions.

addExtension

public void addExtension(Extension ext)
Adds an extension object.


setExtension

public void setExtension(Extension ext)
Sets an extension object. If one exists of this type, it's replaced.


addRepeatingExtension

public void addRepeatingExtension(Extension ext)
Adds a repeating extension object.


removeExtension

public void removeExtension(Extension ext)
Removes an extension object.


removeExtension

public void removeExtension(java.lang.Class<? extends Extension> extensionClass)
Removes an extension object based on its class.


removeRepeatingExtension

public void removeRepeatingExtension(Extension ext)
Removes a repeating extension object.


visit

public void visit(ExtensionVisitor ev,
                  ExtensionPoint parent)
           throws ExtensionVisitor.StoppedException
Visits the tree of extension data associated with this extension point instance using the specified ExtensionVisitor, starting at this extension point.

Parameters:
ev - the extension visitor instance to use.
parent - the parent of this extension point (or null if no parent or unspecified.
Throws:
ExtensionVisitor.StoppedException

getXmlBlob

public XmlBlob getXmlBlob()
Retrieves the XML blob containing arbitrary (unrecognized) extensions.


setXmlBlob

public void setXmlBlob(XmlBlob xmlBlob)
Sets the XML blob containing arbitrary (unrecognized) extensions.


generateCumulativeXmlBlob

public XmlBlob generateCumulativeXmlBlob(ExtensionProfile extProfile)
                                  throws java.io.IOException
Generates an XML blob containing all recognized and unrecognized extensions. This can be used by applications that persist data in a store that might be accessed by other applications--ones that don't necessarily recognize the same set of extensions.

Throws:
java.io.IOException

parseCumulativeXmlBlob

public void parseCumulativeXmlBlob(XmlBlob blob,
                                   ExtensionProfile extProfile,
                                   java.lang.Class<? extends ExtensionPoint> extendedClass)
                            throws java.io.IOException,
                                   ParseException
Reverses generateCumulativeXmlBlob(ExtensionProfile). This operation overwrites the current contents of this extension point.

Throws:
java.io.IOException
ParseException

getHandler

public XmlParser.ElementHandler getHandler(ExtensionProfile p,
                                           java.lang.String namespace,
                                           java.lang.String localName,
                                           org.xml.sax.Attributes attrs)
                                    throws ParseException
Description copied from class: AbstractExtension
The default implementation uses the AttributesHandler to handle parsing the extension.

Specified by:
getHandler in interface Extension
Overrides:
getHandler in class AbstractExtension
Parameters:
p - extension profile
namespace - extension namespace
localName - tag name, without the namespace prefix
attrs - tag attributes
Returns:
an element handler
Throws:
ParseException - when an unexpected tag or badly-formatted XML is detected