public abstract class

ValueConstruct

extends AbstractExtension
java.lang.Object
   ↳ com.google.gdata.data.AbstractExtension
     ↳ com.google.gdata.data.ValueConstruct
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The ValueConstruct class is an abstract Extension class that can be used to subclassed to create a GData extension element with a single value, like: 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.

Summary

Fields
protected final String attrName The XML attribute name for the value construct.
private boolean required Indicates that the value is required (true by default).
private String value The value of the value construct.
[Expand]
Inherited Fields
From class com.google.gdata.data.AbstractExtension
Protected Constructors
ValueConstruct(String attrName)
Constructs a value construct bound to a specific XML representation.
ValueConstruct(XmlNamespace namespace, String localName, String attrName)
Constructs an ValueConstruct bound to a specific XML representation A concrete subclass should always use constants value for all three parameters.
ValueConstruct(XmlNamespace namespace, String localName, String attrName, String value)
Constructs a new ValueConstruct instance bound to a specific XML representation.
Public Methods
boolean equals(Object o)
void generate(XmlWriter w, ExtensionProfile p)
Generates an XML representation for the extension.
XmlParser.ElementHandler getHandler(ExtensionProfile p, String namespace, String localName, Attributes attrs)
The default implementation uses the AbstractExtension.AttributesHandler to handle parsing the extension.
String getValue()
Returns the value of the value construct.
boolean hasValue()
Returns whether it has the value.
int hashCode()
final boolean isRequired()
void putAttributes(AttributeGenerator generator)
Puts attributes into the attribute generator.
void setValue(String v)
Sets the value.
Protected Methods
void consumeAttributes(AttributeHelper helper)
Consumes attributes from the attribute helper.
final void setRequired(boolean isRequired)
[Expand]
Inherited Methods
From class com.google.gdata.data.AbstractExtension
From class java.lang.Object
From interface com.google.gdata.data.Extension

Fields

protected final String attrName

The XML attribute name for the value construct. When null, indicates that the value is contained within the XML element text content.

private boolean required

Indicates that the value is required (true by default).

private String value

The value of the value construct.

Protected Constructors

protected ValueConstruct (String attrName)

Constructs a value construct bound to a specific XML representation. The concrete subclass must have an ExtensionDescription.Default attribute defined, and should always use constant values for the attrName parameter.

Parameters
attrName The name of attribute that contains the value, or null if the value is contained within the element content.

protected ValueConstruct (XmlNamespace namespace, String localName, String attrName)

Constructs an ValueConstruct bound to a specific XML representation A concrete subclass should always use constants value for all three parameters.

Parameters
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, String localName, String attrName, String value)

Constructs a new ValueConstruct instance bound to a specific XML representation. A concrete subclass should always use constant values for the 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).

Parameters
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 Methods

public boolean equals (Object o)

Parameters
o

public void generate (XmlWriter w, ExtensionProfile p)

Generates an XML representation for the extension.

Parameters
w XML writer
p Extension profile
Throws
IOException

public XmlParser.ElementHandler getHandler (ExtensionProfile p, String namespace, String localName, Attributes attrs)

The default implementation uses the AbstractExtension.AttributesHandler to handle parsing the extension.

Parameters
p Extension profile
namespace Extension namespace
localName Tag name, without the namespace prefix
attrs Tag attributes
Returns
  • an element handler

public String getValue ()

Returns the value of the value construct.

Returns
  • the current value.

public boolean hasValue ()

Returns whether it has the value.

Returns
  • whether it has the value

public int hashCode ()

public final boolean isRequired ()

public void putAttributes (AttributeGenerator generator)

Puts attributes into the attribute generator. Called from generate(XmlWriter, ExtensionProfile). Default implementation does nothing, though generally this is discouraged unless there really are no attributes.

Parameters
generator Attribute generator

public void setValue (String v)

Sets the value. Subclasses can override this method to do additional validation of the value.

Parameters
v New value for the value construct or null to reset.
Throws
IllegalArgumentException if the value is invalid for the construct.
IllegalStateException if the value construct is read only

Protected Methods

protected void consumeAttributes (AttributeHelper helper)

Consumes attributes from the attribute helper. May also use consumeContent(boolean) to consume the element's text content. Called from getHandler(ExtensionProfile, String, String, Attributes). Default implementation does nothing, though generally this is discouraged unless there really are no attributes.

Parameters
helper Attribute helper

protected final void setRequired (boolean isRequired)

Parameters
isRequired