# Google Data APIs Client Library (1.43.0)

## com.google.gdata.data
Class AbstractExtension

    java.lang.Object
      com.google.gdata.data.AbstractExtension

All Implemented Interfaces:
  Extension

Direct Known Subclasses:
  AbstractFreeTextExtension, AbstractTextElement, AclScope, AdditionalName, ClosedDate, ContainsSampledData, Country, CrawlIssueCrawlType, CrawlIssueDateDetected, CrawlIssueIssueType, CustomProperty, Deleted, Duration, EntriesNumber, ExportStatus, ExtensionPoint, FamilyName, FeatureRate, Field, FullName, GivenName, GmItemType, GphotoBytesUsed, GphotoCommentCount, GphotoCommentsEnabled, GphotoCrowdedLength, GphotoFeaturedDate, GphotoHeight, GphotoImageVersion, GphotoMaxPhotos, GphotoPhotosLeft, GphotoPhotosUsed, GphotoPosition, GphotoQuotaLimit, GphotoQuotaUsed, GphotoRotation, GphotoShowLink, GphotoSize, GphotoStarred, GphotoSubscribed, GphotoTimestamp, GphotoVersion, GphotoViewCount, GphotoWeight, GphotoWidth, GwoAutoPruneMode, GwoComboActive, GwoExperimentType, GwoStatus, Id, Jot, Keyword, LastViewed, MaxUploadSize, MediaCategory, MediaCopyright, MediaCredit, MediaHash, MediaKeywords, MediaRating, MediaRestriction, NumberOfSourceWords, ObjectNumber, OrgName, PercentComplete, QuotaBytesTotal, QuotaBytesUsed, QuotaBytesUsedInTrash, Relation, ResourceProperty, Review, Revision, ScopeEntry, Size, Source, Stars, State, Total, TranslationComplete, Usefulness, ValueConstruct, VerificationMethod, YtAge, YtAspectRatio, YtCommentRating, YtCountHint, YtDuration, YtFormatInfo, YtGender, YtIncomplete, YtNoEmbed, YtPlaylistId, YtPosition, YtPrivate, YtPublicationState, YtRacy, YtRating, YtRecorded, YtRelationship, YtSpam, YtStatistics, YtStatus, YtUploaded, YtUserProfileStatistics, YtVideoId

    public abstract class AbstractExtension

extends java.lang.Object
implements Extension

Common extension implementation for sharing code among implementers of `Extension`. The information contained in this class is:

1. XML namespace of the extension
2. XML local name of the extension
3. if the extension is mutable

Nested Class Summary
`protected class` `AbstractExtension.AttributesHandler` Base class for custom element handlers that uses `AttributeHelper` to consume the attributes and the element's text content.

Field Summary
`protected java.lang.String` `localName` XML local name for this extension or `null` if not defined
`protected com.google.gdata.util.common.xml.XmlNamespace` `namespace` XML namespace for this extension or `null` if not defined

Constructor Summary
`protected` `AbstractExtension()` Constructs an extension bound to a specific XML representation.
`protected` `AbstractExtension(com.google.gdata.util.common.xml.XmlNamespace namespace, java.lang.String localName)` Constructs an extension bound to a specific XML representation.

Method Summary
`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(com.google.gdata.util.common.xml.XmlWriter w, ExtensionProfile p)` Generates an XML representation for the extension.
`protected void` `generate(com.google.gdata.util.common.xml.XmlWriter w, ExtensionProfile p, com.google.gdata.util.common.xml.XmlNamespace namespace, java.lang.String localName, java.util.List<com.google.gdata.util.common.xml.XmlWriter.Attribute> attrs, AttributeGenerator generator)` Generates the XML into the XML writer.
`protected void` `generateAttributes(java.util.List<com.google.gdata.util.common.xml.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.
`com.google.gdata.util.common.xml.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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### namespace

    protected final com.google.gdata.util.common.xml.XmlNamespace namespace

  XML namespace for this extension or `null` if not defined

### localName

    protected final java.lang.String localName

  XML local name for this extension or `null` if not defined

Constructor Detail

### AbstractExtension

    protected AbstractExtension()

  Constructs an extension bound to a specific XML representation. The concrete subclass must have an `ExtensionDescription.Default` attribute defined to use this constructor.

### AbstractExtension

    protected AbstractExtension(com.google.gdata.util.common.xml.XmlNamespace namespace,
                                java.lang.String localName)

  Constructs an extension bound to a specific XML representation. Note: this is here for backwards compatibility and may be removed at some point in the future.

  Parameters:
    `namespace` - the namespace of the value element
    `localName` - the local name of the value element

Method Detail

### isStrictValidation

    public static final boolean isStrictValidation()

### enableStrictValidation

    public static final void enableStrictValidation()

### disableStrictValidation

    public static final void disableStrictValidation()

### isImmutable

    public final boolean isImmutable()

### setImmutable

    public final void setImmutable(boolean isImmutable)

### getExtensionNamespace

    public final com.google.gdata.util.common.xml.XmlNamespace getExtensionNamespace()

  Gets the extension's namespace.

### getExtensionLocalName

    public final java.lang.String getExtensionLocalName()

  Gets the extension's localname.

### validate

    protected void validate()
                     throws java.lang.IllegalStateException

  Checks the attributes to see if there are any problems. Default implementation does nothing, though generally this is discouraged unless there really are no restrictions.

  Throws:
    `java.lang.IllegalStateException` - if any problems are found with the attributes

### putAttributes

    protected 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

### consumeAttributes

    protected void consumeAttributes(AttributeHelper helper)
                              throws ParseException

  Consumes attributes from the attribute helper. May also use `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.

  Parameters:
    `helper` - attribute helper
  Throws:
    `ParseException` - any parsing exception

### generate

    protected void generate(com.google.gdata.util.common.xml.XmlWriter w,
                            ExtensionProfile p,
                            com.google.gdata.util.common.xml.XmlNamespace namespace,
                            java.lang.String localName,
                            java.util.List<com.google.gdata.util.common.xml.XmlWriter.Attribute> attrs,
                            AttributeGenerator generator)
                     throws java.io.IOException

  Generates the XML into the XML writer. Default implementation generates a "simple" element with the attributes and content found in the attribute generator.

  Parameters:
    `w` - XML writer
    `p` - extension profile
    `namespace` - XML namespace for this extension
    `localName` - XML local name for this extension
    `attrs` - list of XML attributes
    `generator` - attribute generator
  Throws:
    `java.io.IOException` - any I/O exception

### generate

    public void generate(com.google.gdata.util.common.xml.XmlWriter w,
                         ExtensionProfile p)
                  throws java.io.IOException

  Description copied from interface: `Extension`
  Generates an XML representation for the extension.

  Specified by:
    `generate` in interface `Extension`
  Parameters:
    `w` - XML writer
    `p` - extension profile
  Throws:
    `java.io.IOException`

### generateAttributes

    protected void generateAttributes(java.util.List<com.google.gdata.util.common.xml.XmlWriter.Attribute> attrs,
                                      AttributeGenerator generator)

  Generates the attributes in the generator into the list of attributes.

### getHandler

    public XmlParser.ElementHandler getHandler(ExtensionProfile p,
                                               java.lang.String namespace,
                                               java.lang.String localName,
                                               org.xml.sax.Attributes attrs)
                                        throws ParseException

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

  Specified by:
    `getHandler` in interface `Extension`
  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

### throwExceptionIfImmutable

    protected final void throwExceptionIfImmutable()

  Throws an `IllegalStateException` if this instance is immutable. Should only be used in a value-setter method.

### throwExceptionForMissingAttribute

    protected static final void throwExceptionForMissingAttribute(java.lang.String attrName)

  Throws an `IllegalStateException` if the value is required and it is missing.

  Parameters:
    `attrName` - attribute name
  Throws:
    `java.lang.IllegalStateException` - to indicate that there are problems with the attributes

### sameClassAs

    protected boolean sameClassAs(java.lang.Object o)

  Parameters:
    `o` - given object
  Returns:
    true if the given object is not null and is the same concrete class as this one

### eq

    protected static boolean eq(java.lang.Object o1,
                                java.lang.Object o2)

  Parameters:
    `o1` - object 1 or `null`
    `o2` - object 2 or `null`
  Returns:
    true if the specified arguments are equal, or both null