public abstract class AbstractExtension extends java.lang.Object implements Extension
Extension
. The information contained in this class is:
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractExtension.AttributesHandler
Base class for custom element handlers that uses
AttributeHelper
to consume the attributes and the element's text content. |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
localName
XML local name for this extension or
null if not defined |
protected XmlNamespace |
namespace
XML namespace for this extension or
null if not defined |
Modifier | Constructor and Description |
---|---|
protected |
AbstractExtension()
Constructs an extension bound to a specific XML representation.
|
protected |
AbstractExtension(XmlNamespace namespace,
java.lang.String localName)
Constructs an extension bound to a specific XML representation.
|
Modifier and Type | Method and Description |
---|---|
protected void |
consumeAttributes(AttributeHelper helper)
Consumes attributes from the attribute helper.
|
static void |
disableStrictValidation() |
static void |
enableStrictValidation() |
protected static boolean |
eq(java.lang.Object o1,
java.lang.Object o2) |
void |
generate(XmlWriter w,
ExtensionProfile p)
Generates an XML representation for the extension.
|
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.
|
protected void |
generateAttributes(java.util.List<XmlWriter.Attribute> attrs,
AttributeGenerator generator)
Generates the attributes in the generator into the list of attributes.
|
java.lang.String |
getExtensionLocalName()
Gets the extension's localname.
|
XmlNamespace |
getExtensionNamespace()
Gets the extension's namespace.
|
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. |
boolean |
isImmutable() |
static boolean |
isStrictValidation() |
protected void |
putAttributes(AttributeGenerator generator)
Puts attributes into the attribute generator.
|
protected boolean |
sameClassAs(java.lang.Object o) |
void |
setImmutable(boolean isImmutable) |
protected static void |
throwExceptionForMissingAttribute(java.lang.String attrName)
Throws an
IllegalStateException if the value is required
and it is missing. |
protected void |
throwExceptionIfImmutable()
Throws an
IllegalStateException if this instance is immutable. |
protected void |
validate()
Checks the attributes to see if there are any problems.
|
protected final XmlNamespace namespace
null
if not definedprotected final java.lang.String localName
null
if not definedprotected AbstractExtension()
ExtensionDescription.Default
attribute defined to use this constructor.protected AbstractExtension(XmlNamespace namespace, java.lang.String localName)
namespace
- the namespace of the value elementlocalName
- the local name of the value elementpublic static final boolean isStrictValidation()
public static final void enableStrictValidation()
public static final void disableStrictValidation()
public final boolean isImmutable()
public final void setImmutable(boolean isImmutable)
public final XmlNamespace getExtensionNamespace()
public final java.lang.String getExtensionLocalName()
protected void validate() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if any problems are found with the
attributesprotected void putAttributes(AttributeGenerator generator)
generate(XmlWriter,ExtensionProfile)
. Default implementation
does nothing, though generally this is discouraged unless there really are
no attributes.generator
- attribute generatorprotected void consumeAttributes(AttributeHelper helper) throws ParseException
AttributeHelper.consumeContent(boolean)
to consume the element's text
content. Called from getHandler(com.google.gdata.data.ExtensionProfile, java.lang.String, java.lang.String, org.xml.sax.Attributes)
. Default implementation does
nothing, though generally this is discouraged unless there really are no
attributes.helper
- attribute helperParseException
- any parsing exceptionprotected void generate(XmlWriter w, ExtensionProfile p, XmlNamespace namespace, java.lang.String localName, java.util.List<XmlWriter.Attribute> attrs, AttributeGenerator generator) throws java.io.IOException
w
- XML writerp
- extension profilenamespace
- XML namespace for this extensionlocalName
- XML local name for this extensionattrs
- list of XML attributesgenerator
- attribute generatorjava.io.IOException
- any I/O exceptionpublic void generate(XmlWriter w, ExtensionProfile p) throws java.io.IOException
Extension
protected void generateAttributes(java.util.List<XmlWriter.Attribute> attrs, AttributeGenerator generator)
public XmlParser.ElementHandler getHandler(ExtensionProfile p, java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs) throws ParseException
AbstractExtension.AttributesHandler
to handle
parsing the extension.getHandler
in interface Extension
p
- extension profilenamespace
- extension namespacelocalName
- tag name, without the namespace prefixattrs
- tag attributesParseException
- when an unexpected tag or badly-formatted
XML is detectedprotected final void throwExceptionIfImmutable()
IllegalStateException
if this instance is immutable.
Should only be used in a value-setter method.protected static final void throwExceptionForMissingAttribute(java.lang.String attrName)
IllegalStateException
if the value is required
and it is missing.attrName
- attribute namejava.lang.IllegalStateException
- to indicate that there are problems with the
attributesprotected boolean sameClassAs(java.lang.Object o)
o
- given objectprotected static boolean eq(java.lang.Object o1, java.lang.Object o2)
o1
- object 1 or null
o2
- object 2 or null