Class AbstractXHTMLDepictContext

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, DepictContext, TextDepictContext, XHTMLDepictContext, XMLDepictContext
Direct Known Subclasses:
AbstractWebDepictContext

public abstract class AbstractXHTMLDepictContext extends AbstractXMLDepictContext implements XHTMLDepictContext
Abstract encapsulation of application/xhtml+xml information related to the current depiction.

This implementation maps the XHTML namespace HTML.XHTML_NAMESPACE_URI to the null prefix.

Author:
Garret Wilson
  • Constructor Details

    • AbstractXHTMLDepictContext

      public AbstractXHTMLDepictContext(GuiseSession session, Destination destination) throws IOException
      Guise session constructor.
      Parameters:
      session - The Guise user session of which this context is a part.
      destination - The destination with which this context is associated.
      Throws:
      NullPointerException - if the given session and/or destination is null.
      IOException - If there was an I/O error loading a needed resource.
  • Method Details

    • registerDataAttributeNamespaceURI

      public void registerDataAttributeNamespaceURI(URI namespaceURI)
      Description copied from interface: XHTMLDepictContext
      Registers a namespace URI to be represented as an HTML5 data attribute. Any attribute in this namespace will be converted to lowercase and presented as an HTML5 attribute. For example, an attribute in the form example:fooBar will be depicted as data-example-foobar.
      Specified by:
      registerDataAttributeNamespaceURI in interface XHTMLDepictContext
      Parameters:
      namespaceURI - The namespace URI to register.
    • isDataAttributeNamespaceURI

      public boolean isDataAttributeNamespaceURI(URI namespaceURI)
      Description copied from interface: XHTMLDepictContext
      Determines whether the given namespace URI should be represented as an HTML5 data attribute.
      Specified by:
      isDataAttributeNamespaceURI in interface XHTMLDepictContext
      Parameters:
      namespaceURI - The namespace URI to check.
      Returns:
      true if the given namespace URI should be represented as an HTML5 data attribute.
    • isAllDataAttributes

      public boolean isAllDataAttributes()
      Description copied from interface: XHTMLDepictContext
      Returns whether all non-default-namespace attributes are encoded at HTML5 data attributes. This setting overrides XHTMLDepictContext.isDataAttributeNamespaceURI(URI) .
      Specified by:
      isAllDataAttributes in interface XHTMLDepictContext
      Returns:
      Whether all non-default-namespace attributes are encoded at HTML5 data attributes.
    • setAllDataAttributes

      public void setAllDataAttributes(boolean dataAttributesEnabled)
      Description copied from interface: XHTMLDepictContext
      Sets whether all non-default-namespace attributes are encoded at HTML5 data attributes. If this setting is enabled, any non-default-namespace attribute will be converted to lowercase and presented as an HTML5 attribute. For example, an attribute in the form example:fooBar will be depicted as data-example-foobar.

      If set to true, the setting of XHTMLDepictContext.isDataAttributeNamespaceURI(URI) is ignored.

      Specified by:
      setAllDataAttributes in interface XHTMLDepictContext
      Parameters:
      dataAttributesEnabled - Whether non-XHTML-namespace attributes are encoded at HTML5 data attributes.
    • appendAttributeName

      protected <A extends Appendable> A appendAttributeName(A appendable, com.globalmentor.xml.spec.NsQualifiedName attributeQualifiedName) throws IOException
      Appends an attribute name to the given appendable.

      This implementation appends the attribute qname.

      If HTML5 data attributes are enabled for all attributes or for the given namespace, this implementation converts non-XHTML-namespace attributes into HTML data attribute form. For example, an attribute in the form example:fooBar will be depicted as data-example-foobar. "xmlns" namespace attribute will never be converted.

      Overrides:
      appendAttributeName in class AbstractXMLDepictContext
      Type Parameters:
      A - The type of the appendable.
      Parameters:
      appendable - The appendable to which the attribute should be appended.
      attributeQualifiedName - The qualified name of the attribute.
      Returns:
      The given appendable.
      Throws:
      IOException - if there is a problem appending the attribute information.
      See Also:
    • writeJavaScriptElement

      public XMLDepictContext.ElementState writeJavaScriptElement(URI javascriptURI) throws IOException
      Description copied from interface: XHTMLDepictContext
      Generates a JavaScript element that references the given URI. The given URI is resolved to the application path.
      Specified by:
      writeJavaScriptElement in interface XHTMLDepictContext
      Parameters:
      javascriptURI - The application-relative IRO to the JavaScript file.
      Returns:
      The state of the element written.
      Throws:
      IOException - if there is an error writing the information.
    • writeMetaElement

      public XMLDepictContext.ElementState writeMetaElement(String property, String content) throws IOException
      Description copied from interface: XHTMLDepictContext
      Generates a meta element suitable for the head of an XHTML document.
      Specified by:
      writeMetaElement in interface XHTMLDepictContext
      Parameters:
      property - The meta property name.
      content - The meta property content.
      Returns:
      The state of the element written.
      Throws:
      IOException - if there is an error writing the information.
    • writeMetaElement

      public XMLDepictContext.ElementState writeMetaElement(URI propertyNamespaceURI, String propertyLocalName, String content) throws IOException
      Description copied from interface: XHTMLDepictContext
      Generates a meta element suitable for the head of an XHTML document, creating a qualified name or the meta property based upon the given namespace URI and local name.
      Specified by:
      writeMetaElement in interface XHTMLDepictContext
      Parameters:
      propertyNamespaceURI - The URI of the XML namespace of the meta property name, or null if there is no namespace.
      propertyLocalName - The local name of the meta property name with no prefix.
      content - The meta property content.
      Returns:
      The state of the element being written.
      Throws:
      IOException - if there is an error writing the information.