|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.data.AbstractExtension
com.google.gdata.data.ExtensionPoint
public class ExtensionPoint
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. |
Nested classes/interfaces inherited from class com.google.gdata.data.AbstractExtension |
---|
AbstractExtension.AttributesHandler |
Field Summary | |
---|---|
protected XmlBlob |
xmlBlob
Arbitrary XML (unrecognized extensions). |
Fields inherited from class com.google.gdata.data.AbstractExtension |
---|
localName, namespace |
Constructor Summary | |
---|---|
|
ExtensionPoint()
Simple constructor to create a new (empty) ExtensionPoint. |
protected |
ExtensionPoint(ExtensionPoint sourcePoint)
Simple copy constructor that does a shallow copy of extension and manifest data from an existing ExtensionPoint to the constructed instance. |
Method Summary | ||
---|---|---|
void |
addExtension(Extension ext)
Adds an extension object. |
|
protected boolean |
addExtension(Extension ext,
java.lang.Class<? extends Extension> extClass)
Internal helper method. |
|
void |
addRepeatingExtension(Extension ext)
Adds a repeating extension object. |
|
protected void |
addRepeatingExtension(Extension ext,
java.lang.Class<? extends Extension> extClass)
Internal helper method. |
|
protected void |
checkRequiredExtensions(ExtensionManifest profManifest)
Checks whether all required extensions are present. |
|
void |
declareExtensions(ExtensionProfile extProfile)
Declares the set of expected Extension types for an ExtensionPoint within the target extension profile. |
|
protected void |
generate(XmlWriter w,
ExtensionProfile p,
XmlNamespace namespace,
java.lang.String localName,
java.util.List<XmlWriter.Attribute> attrs,
AttributeGenerator generator)
Generates the XML into the XML writer. |
|
XmlBlob |
generateCumulativeXmlBlob(ExtensionProfile extProfile)
Generates an XML blob containing all recognized and unrecognized extensions. |
|
protected void |
generateExtensions(XmlWriter w,
ExtensionProfile extProfile)
Generates XML corresponding to extended properties. |
|
protected void |
generateStartElement(XmlWriter w,
XmlNamespace namespace,
java.lang.String elementName,
java.util.Collection<XmlWriter.Attribute> additionalAttrs,
java.util.Collection<XmlNamespace> additionalNs)
Generates XML corresponding to the type implementing ExtensionPoint . |
|
|
getExtension(java.lang.Class<T> extensionClass)
Retrieves a non-repeating extension or null if not present. |
|
protected XmlParser.ElementHandler |
getExtensionHandler(ExtensionProfile extProfile,
java.lang.Class<? extends ExtensionPoint> extPoint,
java.lang.String namespaceUri,
java.lang.String localName,
org.xml.sax.Attributes attrs)
XML parser callback for extended properties. |
|
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 AbstractExtension.AttributesHandler to handle
parsing the extension. |
|
protected ExtensionManifest |
getManifest(ExtensionProfile extProfile,
java.lang.Class<? extends ExtensionPoint> extendedClass)
Retrieves the manifest for the specified class. |
|
|
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. |
|
|
hasExtension(java.lang.Class<T> extensionClass)
Returns whether the non-repeating extension is present. |
|
|
hasRepeatingExtension(java.lang.Class<T> extensionClass)
Returns whether the repeating extension is present. |
|
protected void |
initializeArbitraryXml(ExtensionProfile profile,
java.lang.Class<? extends ExtensionPoint> extPoint,
XmlParser.ElementHandler handler)
Initializes parser handler's XML blob state. |
|
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. |
|
protected void |
visitChild(ExtensionVisitor ev,
Extension child)
Called to visit a child of this extension point. |
|
protected void |
visitChildren(ExtensionVisitor ev)
Called to visit all children of this extension point. |
Methods inherited from class com.google.gdata.data.AbstractExtension |
---|
consumeAttributes, eq, generate, generateAttributes, getExtensionLocalName, getExtensionNamespace, isImmutable, putAttributes, sameClassAs, setImmutable, throwExceptionForMissingAttribute, throwExceptionIfImmutable, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected XmlBlob xmlBlob
Constructor Detail |
---|
public ExtensionPoint()
protected ExtensionPoint(ExtensionPoint sourcePoint)
Method Detail |
---|
public void declareExtensions(ExtensionProfile extProfile)
extProfile
- the ExtensionProfile to initialize.public final <T extends Extension> boolean hasExtension(java.lang.Class<T> extensionClass)
public final <T extends Extension> boolean hasRepeatingExtension(java.lang.Class<T> extensionClass)
public <T extends Extension> T getExtension(java.lang.Class<T> extensionClass)
null
if not present.
public java.util.Collection<Extension> getExtensions()
public <T extends Extension> java.util.List<T> getRepeatingExtension(java.lang.Class<T> extensionClass)
public java.util.Collection<java.util.List<Extension>> getRepeatingExtensions()
protected boolean addExtension(Extension ext, java.lang.Class<? extends Extension> extClass)
public void addExtension(Extension ext)
public void setExtension(Extension ext)
protected void addRepeatingExtension(Extension ext, java.lang.Class<? extends Extension> extClass)
public void addRepeatingExtension(Extension ext)
public void removeExtension(Extension ext)
public void removeExtension(java.lang.Class<? extends Extension> extensionClass)
public void removeRepeatingExtension(Extension ext)
protected void visitChild(ExtensionVisitor ev, Extension child) throws ExtensionVisitor.StoppedException
ev
- the extension visitorchild
- the child extension
ExtensionVisitor.StoppedException
protected void visitChildren(ExtensionVisitor ev) throws ExtensionVisitor.StoppedException
ev
- the extension visitor.
ExtensionVisitor.StoppedException
public void visit(ExtensionVisitor ev, ExtensionPoint parent) throws ExtensionVisitor.StoppedException
ExtensionVisitor
, starting at this
extension point.
ev
- the extension visitor instance to use.parent
- the parent of this extension point (or null
if no
parent or unspecified.
ExtensionVisitor.StoppedException
public XmlBlob getXmlBlob()
public void setXmlBlob(XmlBlob xmlBlob)
public XmlBlob generateCumulativeXmlBlob(ExtensionProfile extProfile) throws java.io.IOException
java.io.IOException
public void parseCumulativeXmlBlob(XmlBlob blob, ExtensionProfile extProfile, java.lang.Class<? extends ExtensionPoint> extendedClass) throws java.io.IOException, ParseException
generateCumulativeXmlBlob(ExtensionProfile)
. This
operation overwrites the current contents of this extension point.
java.io.IOException
ParseException
protected ExtensionManifest getManifest(ExtensionProfile extProfile, java.lang.Class<? extends ExtensionPoint> extendedClass)
protected void generate(XmlWriter w, ExtensionProfile p, XmlNamespace namespace, java.lang.String localName, java.util.List<XmlWriter.Attribute> attrs, AttributeGenerator generator) throws java.io.IOException
AbstractExtension
generate
in class AbstractExtension
w
- XML writerp
- extension profilenamespace
- XML namespace for this extensionlocalName
- XML local name for this extensionattrs
- list of XML attributesgenerator
- attribute generator
java.io.IOException
- any I/O exceptionpublic XmlParser.ElementHandler getHandler(ExtensionProfile p, java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs) throws ParseException
AbstractExtension
AbstractExtension.AttributesHandler
to handle
parsing the extension.
getHandler
in interface Extension
getHandler
in class AbstractExtension
p
- extension profilenamespace
- extension namespacelocalName
- tag name, without the namespace prefixattrs
- tag attributes
ParseException
- when an unexpected tag or badly-formatted
XML is detectedprotected void generateStartElement(XmlWriter w, XmlNamespace namespace, java.lang.String elementName, java.util.Collection<XmlWriter.Attribute> additionalAttrs, java.util.Collection<XmlNamespace> additionalNs) throws java.io.IOException
ExtensionPoint
. The reason this routine is necessary is that the embedded
XML blob may contain namespace declarations.
java.io.IOException
protected void generateExtensions(XmlWriter w, ExtensionProfile extProfile) throws java.io.IOException
w
- Output writer.extProfile
- Extension profile for use by nested extensions.
java.io.IOException
protected void initializeArbitraryXml(ExtensionProfile profile, java.lang.Class<? extends ExtensionPoint> extPoint, XmlParser.ElementHandler handler)
ExtensionProfile.declareArbitraryXmlExtension(Class)
.
protected XmlParser.ElementHandler getExtensionHandler(ExtensionProfile extProfile, java.lang.Class<? extends ExtensionPoint> extPoint, java.lang.String namespaceUri, java.lang.String localName, org.xml.sax.Attributes attrs) throws ParseException, java.io.IOException
extProfile
- Extension profile for use by nested element handlers.extPoint
- Current active ExtensionPoint class within which you're
looking for a handler for a nested extension element.namespaceUri
- Namespace URI of the XML element.localName
- Name of the XML element.attrs
- Child element attributes. These attributes will be
communicated to the returned XmlParser.ElementHandler
through its
XmlParser.ElementHandler.processAttribute(String, String, String)
method. They are passed here because sometimes the value of some
attribute determines the element's content type, so different
element handlers may be needed.
null
if the tag is
not recognized. Unrecognized tags are stored in the XML blob.
ParseException
- XML schema error. Could be a result of having a
duplicate entry, illegal contents (such as unrecognized attributes
or nested elements), etc.
java.io.IOException
protected void checkRequiredExtensions(ExtensionManifest profManifest) throws ParseException
ParseException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |