public abstract class ValueConstruct extends AbstractExtension
or
some value
Using constructor parameters, a customized subclass has full
control over the value construct element namespace and tag name,
as well whether the value is contained within an XML attribute
or the element text value.
A subclass can override the setValue(String)
method to do customized validation of any value set directly
by a client or as a result of XML parsing.
Two ValueConstruct instances are considered equal if they have the same concrete subclass and the value of the two instances are equal. The namespace, tagname, and attribute names are not taken into account by the equality comparison; they are assumed to be equivalent for all instances of a particular concrete subclass.
AbstractExtension.AttributesHandler| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
attrName
The XML attribute name for the value construct.
|
localName, namespace| Modifier | Constructor and Description |
|---|---|
protected |
ValueConstruct(java.lang.String attrName)
Constructs a value construct bound to a specific XML representation.
|
protected |
ValueConstruct(XmlNamespace namespace,
java.lang.String localName,
java.lang.String attrName)
Constructs an ValueConstruct bound to a specific XML representation
A concrete subclass should always use constants value for all three
parameters.
|
protected |
ValueConstruct(XmlNamespace namespace,
java.lang.String localName,
java.lang.String attrName,
java.lang.String value)
Constructs a new ValueConstruct instance bound to a specific XML
representation.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
consumeAttributes(AttributeHelper helper)
Consumes attributes from the attribute helper.
|
boolean |
equals(java.lang.Object o) |
void |
generate(XmlWriter w,
ExtensionProfile p)
Generates an XML representation for the extension.
|
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. |
java.lang.String |
getValue()
Returns the value of the value construct.
|
int |
hashCode() |
boolean |
hasValue()
Returns whether it has the value.
|
boolean |
isRequired() |
void |
putAttributes(AttributeGenerator generator)
Puts attributes into the attribute generator.
|
protected void |
setRequired(boolean isRequired) |
void |
setValue(java.lang.String v)
Sets the value.
|
disableStrictValidation, enableStrictValidation, eq, generate, generateAttributes, getExtensionLocalName, getExtensionNamespace, isImmutable, isStrictValidation, sameClassAs, setImmutable, throwExceptionForMissingAttribute, throwExceptionIfImmutable, validateprotected final java.lang.String attrName
null,
indicates that the value is contained within the XML element text
content.protected ValueConstruct(java.lang.String attrName)
ExtensionDescription.Default
attribute defined, and should always use constant values for the attrName parameter.attrName - the name of attribute that contains the value, or null if the value is contained within the element
content.protected ValueConstruct(XmlNamespace namespace, java.lang.String localName, java.lang.String attrName)
namespace - the namespace of the value element.localName - the local name of the value element.attrName - the name of attribute that contains the value, or
null if the value is contained within the element content.protected ValueConstruct(XmlNamespace namespace, java.lang.String localName, java.lang.String attrName, java.lang.String value)
namespace, localName, and attrName
parameters. If an initial value is provided and it is not null,
an immutable instance will be created that is initialized to this
value and may not be modified by setValue(String).namespace - the namespace of the value element.localName - the local name of the value element.attrName - the name of attribute that contains the value, or
null if the value is contained within the element content.value - the value that should be used to initialize the value
construct instance. After construction, the value will be
immutable.public final boolean isRequired()
protected final void setRequired(boolean isRequired)
public java.lang.String getValue()
public void setValue(java.lang.String v)
v - new value for the value construct or null to reset.java.lang.IllegalArgumentException - if the value is invalid for the construct.java.lang.IllegalStateException - if the value construct is read onlypublic boolean hasValue()
public void putAttributes(AttributeGenerator generator)
AbstractExtensionAbstractExtension.generate(XmlWriter,ExtensionProfile). Default implementation
does nothing, though generally this is discouraged unless there really are
no attributes.putAttributes in class AbstractExtensiongenerator - attribute generatorprotected void consumeAttributes(AttributeHelper helper) throws ParseException
AbstractExtensionAttributeHelper.consumeContent(boolean) to consume the element's text
content. Called from AbstractExtension.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.consumeAttributes in class AbstractExtensionhelper - attribute helperParseException - any parsing exceptionpublic void generate(XmlWriter w, ExtensionProfile p) throws java.io.IOException
Extensiongenerate in interface Extensiongenerate in class AbstractExtensionw - XML writerp - extension profilejava.io.IOExceptionpublic XmlParser.ElementHandler getHandler(ExtensionProfile p, java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs) throws ParseException
AbstractExtensionAbstractExtension.AttributesHandler to handle
parsing the extension.getHandler in interface ExtensiongetHandler in class AbstractExtensionp - extension profilenamespace - extension namespacelocalName - tag name, without the namespace prefixattrs - tag attributesParseException - when an unexpected tag or badly-formatted
XML is detectedpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object