Class XdocGenerator

java.lang.Object
org.codehaus.plexus.logging.AbstractLogEnabled
All Implemented Interfaces:
ModelloGenerator, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable

@Component(role=ModelloGenerator.class, hint="xdoc") public class XdocGenerator extends AbstractXmlGenerator
  • Field Details

    • DEFAULT_VERSION_RANGE

      private static final VersionRange DEFAULT_VERSION_RANGE
    • firstVersion

      private Version firstVersion
    • version

      private Version version
  • Constructor Details

    • XdocGenerator

      public XdocGenerator()
  • Method Details

    • generate

      public void generate(Model model, Properties parameters) throws ModelloException
      Throws:
      ModelloException
    • generateXdoc

      private void generateXdoc(Properties parameters) throws IOException
      Throws:
      IOException
    • getAnchorName

      private String getAnchorName(String tagName, ModelClass modelClass)
      Get the anchor name by which model classes can be accessed in the generated xdoc/html file.
      Parameters:
      tagName - the name of the XML tag of the model class
      modelClass - the model class, that eventually can have customized anchor name
      Returns:
      the corresponding anchor name
    • writeModelDescriptor

      private void writeModelDescriptor(org.codehaus.plexus.util.xml.XMLWriter w, ModelClass rootModelClass)
      Write description of the whole model.
      Parameters:
      w - the output writer
      rootModelClass - the root class of the model
    • writeElementDescriptor

      private void writeElementDescriptor(org.codehaus.plexus.util.xml.XMLWriter w, ModelClass modelClass, ModelAssociation association, Set<String> writtenIds, Map<String,String> writtenAnchors)
      Write description of an element of the XML representation of the model. This method is recursive.
      Parameters:
      w - the output writer
      modelClass - the mode class to describe
      association - the association we are coming from (can be null)
      writtenIds - set of data already written ids
      writtenAnchors - map of already written anchors with corresponding ids
    • getId

      private String getId(String tagName, ModelClass modelClass)
    • writeFieldsTable

      private void writeFieldsTable(org.codehaus.plexus.util.xml.XMLWriter w, List<ModelField> fields, boolean elementFields)
      Write a table containing model fields description.
      Parameters:
      w - the output writer
      fields - the fields to add in the table
      elementFields - true if fields are elements, false if fields are attributes
    • getModelXmlDescriptor

      private String getModelXmlDescriptor(ModelClass rootModelClass)
      Build the pretty tree describing the XML representation of the model.
      Parameters:
      rootModelClass - the model root class
      Returns:
      the String representing the tree model
    • getElementXmlDescriptor

      private String getElementXmlDescriptor(ModelClass modelClass, ModelAssociation association, Stack<String> stack) throws ModelloRuntimeException
      Build the pretty tree describing the XML representation of an element of the model. This method is recursive.
      Parameters:
      modelClass - the class we are printing the model
      association - the association we are coming from (can be null)
      stack - the stack of elements that have been traversed to come to the current one
      Returns:
      the String representing the tree model
      Throws:
      ModelloRuntimeException
    • resolveTagName

      private String resolveTagName(ModelClass modelClass, ModelAssociation association)
      Compute the tagName of a given class, living inside an association.
      Parameters:
      modelClass - the class we are looking for the tag name
      association - the association where this class is used
      Returns:
      the tag name to use
    • appendSpacer

      private static void appendSpacer(StringBuilder sb, int depth)
      Appends the required spacers to the given StringBuilder.
      Parameters:
      sb - where to append the spacers
      depth - the depth of spacers to generate
    • getDescription

      private static String getDescription(BaseElement element)
    • writeTextElement

      private static void writeTextElement(org.codehaus.plexus.util.xml.XMLWriter w, String name, String text)
    • writeMarkupElement

      private static void writeMarkupElement(org.codehaus.plexus.util.xml.XMLWriter w, String name, String markup)
    • rewrite

      private static String rewrite(String text)
      Ensures that text will have balanced tags
      Parameters:
      text - xml or html based content
      Returns:
      valid XML string