Class Renderer

java.lang.Object
org.dlese.dpc.schemedit.autoform.Renderer
Direct Known Subclasses:
RendererImpl

public abstract class Renderer extends Object
Abstract class for rendering an editor for a SchemaNode (an Element or Attribute defined in an XML Schema). Editor pages are Rendered via recursive instantiations of Renderers starting with the base element for that page.

The product is a RenderTree is a Element structure that expresses a metadata editor interface. The RenderTree is almost leagal jsp but must still be slightly massaged before it can be processed as jsp (see AutoForm).

All concrete classes render JSP-based editors, but in the future we may want to support other editors. This class contains no JSP-specific methods, but it does enforce a particular style of rendering in which individual schema nodes are rendered and attached to a parent element. The Renderer is called recursively as it traverses the schemaStructure, starting at the root Element of the schema (a SchemaNode) and building the RenderTree as it traverses the schema structure.

Author:
ostwald
  • Field Details

    • sh

      public SchemaHelper sh
      A SchemaHelper instance that provides schema-related information and services to the Renderer.
    • xpath

      public String xpath
      JSP - encoded xpath to the element being rendered.
    • parent

      public org.dom4j.Element parent
      A Element representing the parent of the node being rendered.
    • schemaNode

      public SchemaNode schemaNode
      The SchemaNode which wraps the schema element (which may represent an Element Attribute) being rendered
    • typeDef

      public GlobalDef typeDef
      The XPath corresponding to the SchemaNode. This path contains no indexing or jsp-encoding since it points to a the schema's instanceDocument.
    • rhelper

      public RendererHelper rhelper
      Data structure containing global information required by individual Renderer instances.
    • normalizedXPath

      protected String normalizedXPath
    • typeName

      protected String typeName
      Name of the element-to-be-rendered's DataType. This field is required because in some cases the element is rendered as a different type from which it is defined.
    • df

      protected org.dom4j.DocumentFactory df
      The DataType of the element to be rendered.
    • root

      protected org.dom4j.Element root
      The root element to be Rendered. Stored in the RendererHelper instance.
    • repeatingComplexSingletonChildPath

      protected String repeatingComplexSingletonChildPath
      Place holder for a path to a repeating child. This field is null for elements that do not contain a repeating child.
    • formBeanName

      protected String formBeanName
      Description of the Field
  • Constructor Details

    • Renderer

      public Renderer()
      Constructor for the Renderer object
  • Method Details

    • doInit

      protected void doInit(String xpath, org.dom4j.Element parent, RendererHelper rhelper) throws Exception
      Constructor for the Renderer object
      Parameters:
      xpath - xpath to the Node to be rendered
      parent - The element to which the rendered Node is attached as a child
      rhelper - Pointer to the RendererHelper
      Throws:
      Exception - NOT YET DOCUMENTED
    • doInit

      protected void doInit(String xpath, org.dom4j.Element parent, GlobalDef typeDef, RendererHelper rhelper) throws Exception
      Constructor for the Renderer object in which the dataType to render is specified (rather than being determined by the schemaNode at xpath . This constructor is used to render schema nodes that have a derivedModel, which must be rendered using the dataType they extend.
      Parameters:
      xpath - xpath to the Node to be rendered
      parent - The element to which the rendered Node is attached as a child
      rhelper - Pointer to the RendererHelper
      dataTypeName - The name of the dataType as which the node is rendered
      Throws:
      Exception - NOT YET DOCUMENTED
    • init

      protected void init(String xpath, org.dom4j.Element parent, RendererHelper rhelper)
      Initialize Renderer attributes
      Parameters:
      xpath - The jsp-encoded xpath to the element to be rendered.
      parent - The SchemaNode which wraps the schema element (which may represent an Element Attribute) being rendered
      rhelper - Data structure containing global information required by individual Renderer instances
    • isDisplayMode

      public abstract boolean isDisplayMode()
    • isEditMode

      public abstract boolean isEditMode()
    • setRenderMode

      public abstract void setRenderMode(String mode)
    • getRenderMode

      public abstract String getRenderMode()
    • renderNode

      public void renderNode()
      Render an editor for the schemaNode (i.e., a Node of the schema's instanceDocument) specified by the xpath field.
    • renderSimpleType

      public void renderSimpleType()
      Render an editor for a schemaNode defined as
      invalid reference
      SimpleType
    • renderSimpleTypeConcrete

      public abstract void renderSimpleTypeConcrete()
      Implementation-specific method to render an editor for a schemaNode defined as
      invalid reference
      SimpleType
    • renderComplexType

      public void renderComplexType()
      Render an editor for a schemaNode defined as ComplexType
    • renderComplexTypeConcrete

      protected abstract void renderComplexTypeConcrete()
      Implementation-specific method to render an editor for a schemaNode defined as ComplexType
    • renderDerivedTextOnlyModel

      public abstract void renderDerivedTextOnlyModel()
      Render a derived Text-Only content model (ComplexType having SimpleContent element)

      An example text-only model definition:

        invalid input: '<'xsd:complexType>
          invalid input: '<'xsd:simpleContent>
            invalid input: '<'xsd:extension base="xsd:string">
              invalid input: '<'xsd:attribute name="URL" type="stringTextType" use="required"/>
            invalid input: '<'/xsd:extension> invalid input: '<'/xsd:simpleContent> invalid input: '<'/xsd:complexType> 
    • renderDerivedContentModel

      public abstract void renderDerivedContentModel()
      Render a Derived Content Model (ComplexType having ComplexContent element)
    • renderModelGroup

      public abstract void renderModelGroup(org.dom4j.Element group)
    • renderAttribute

      public abstract void renderAttribute()
      Render an Attribute Node
    • renderChoice

      public abstract void renderChoice(org.dom4j.Element choice)
      Render a choice node. Each of the possible choices is tested for existance, and finally a test for an empty choice is included to account for the situation in which a new parent element has been added but the choice has not yet been made.
      Parameters:
      choice - The choice element of the type definition (see ComplexType)
    • renderSequence

      public abstract void renderSequence(org.dom4j.Element sequence)
      Render the subelements of a sequence compositor
      Parameters:
      sequence - the sequence compositor Element
    • renderRepeatingElement

      public abstract void renderRepeatingElement()
      Render an element having an unbounded sequence of subelements
    • renderRepeatingSubstitutionGroup

      public abstract void renderRepeatingSubstitutionGroup()
    • renderSubElements

      public void renderSubElements(GlobalDef proxyTypeDef)
      NOT YET DOCUMENTED
      Parameters:
      proxyTypeDef - NOT YET DOCUMENTED
    • renderSubElements

      public abstract void renderSubElements()
      Render the subitems of the current ComplexType element by walking the children elements of the type definition.

      This method called by renderComplexTypeConcrete.

    • renderSubElements

      public abstract void renderSubElements(List subElements)
      Render the given subElements (or those of the current ComplexType if no subElements are provided). This method called by renderComplexTypeConcrete.
      Parameters:
      subElements - A list of elements to be rendered.
    • getXmlFormat

      public final String getXmlFormat()
      Gets the format (e.g., "adn") of the metadata framework for this Renderer.
    • getSchemaNSPrefix

      public final String getSchemaNSPrefix()
      Gets the prefix of the schemaNamespace as defined by the root schema for the metadata framework for this Renderer.
    • getSchemaNamespace

      public final org.dom4j.Namespace getSchemaNamespace()
      Gets the schema namespace (associated with "http://www.w3.org/2001/XMLSchema") for the root schema for the metadata framework for this Renderer.
    • getLevel

      public final int getLevel(String xpath)
    • getDiv

      protected org.dom4j.Element getDiv()
      Gets a DIV element styled for the current level.
      Returns:
      The div value
    • getDiv

      protected org.dom4j.Element getDiv(int level)
      Gets a DIV element styled for a particular level.
      Parameters:
      level - Description of the Parameter
      Returns:
      The div value
    • jspQuotedString

      public static String jspQuotedString(String s)
      returns the input string surrounded by a string that is replaced with a quotation mark when the rendered Element is writen to disk. This is necessary because dom4J turns quotation marks and appostrophies into entities, which then cause the JSP processer to barf when the jsp page is rendered
      Parameters:
      s - Description of the Parameter
      Returns:
      Description of the Return Value
    • bestPracticesLink

      public abstract org.dom4j.Element bestPracticesLink(String xpath)
    • getInputElement

      public abstract org.dom4j.Element getInputElement(String xpath, SchemaNode schemaNode, GlobalDef typeDef)
    • getSimpleTypeLabel

      public abstract SimpleTypeLabel getSimpleTypeLabel(String xpath)
    • getSimpleTypeLabel

      public abstract SimpleTypeLabel getSimpleTypeLabel(String xpath, String siblingPath, String indexId)
    • getComplexTypeLabel

      public abstract ComplexTypeLabel getComplexTypeLabel(String xpath)
    • getComplexTypeLabel

      public abstract ComplexTypeLabel getComplexTypeLabel(String xpath, String siblingPath, String indexId)
    • showXsdStringElement

      public abstract boolean showXsdStringElement(String xpath)
    • getRenderedField

      public abstract org.dom4j.Element getRenderedField(String xpath, org.dom4j.Element label, org.dom4j.Element inputField)
    • getDeleteController

      public abstract org.dom4j.Element getDeleteController(String itemPath, String elementName)
    • getOptionalItemControl

      public abstract org.dom4j.Element getOptionalItemControl(String xpath)
    • getMultiBoxInput

      protected abstract org.dom4j.Element getMultiBoxInput(String xpath)
    • report

      public String report()
      Description of the Method
      Returns:
      Description of the Return Value
    • setDebug

      public static void setDebug(boolean bool)
      Sets the debug attribute of the Renderer object
      Parameters:
      debug - The new debug value