Package org.codehaus.modello.plugin.xdoc
Class XdocGenerator
- java.lang.Object
-
- org.codehaus.plexus.logging.AbstractLogEnabled
-
- org.codehaus.modello.plugin.AbstractModelloGenerator
-
- org.codehaus.modello.plugins.xml.AbstractXmlGenerator
-
- org.codehaus.modello.plugin.xdoc.XdocGenerator
-
- All Implemented Interfaces:
ModelloGenerator
,org.codehaus.plexus.logging.LogEnabled
,org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
public class XdocGenerator extends AbstractXmlGenerator
-
-
Field Summary
Fields Modifier and Type Field Description private static VersionRange
DEFAULT_VERSION_RANGE
private Version
firstVersion
private Version
version
-
Constructor Summary
Constructors Constructor Description XdocGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
appendSpacer(java.lang.StringBuilder sb, int depth)
Appends the required spacers to the given StringBuilder.void
generate(Model model, java.util.Properties parameters)
private void
generateXdoc(java.util.Properties parameters)
private java.lang.String
getAnchorName(java.lang.String tagName)
Get the anchor name by which model classes can be accessed in the generated xdoc/html file.private static java.lang.String
getDescription(BaseElement element)
private java.lang.String
getElementXmlDescriptor(ModelClass modelClass, ModelAssociation association, java.util.Stack<java.lang.String> stack)
Build the pretty tree describing the XML representation of an element of the model.private java.lang.String
getId(java.lang.String tagName, ModelClass modelClass)
private java.lang.String
getModelXmlDescriptor(ModelClass rootModelClass)
Build the pretty tree describing the XML representation of the model.private java.lang.String
resolveTagName(ModelClass modelClass, ModelAssociation association)
Compute the tagName of a given class, living inside an association.private static java.lang.String
rewrite(java.lang.String text)
Ensures that text will have balanced tagsprivate void
writeElementDescriptor(org.codehaus.plexus.util.xml.XMLWriter w, ModelClass modelClass, ModelAssociation association, java.util.Set<java.lang.String> written)
Write description of an element of the XML representation of the model.private void
writeFieldsTable(org.codehaus.plexus.util.xml.XMLWriter w, java.util.List<ModelField> fields, boolean elementFields)
Write a table containing model fields description.private static void
writeMarkupElement(org.codehaus.plexus.util.xml.XMLWriter w, java.lang.String name, java.lang.String markup)
private void
writeModelDescriptor(org.codehaus.plexus.util.xml.XMLWriter w, ModelClass rootModelClass)
Write description of the whole model.private static void
writeTextElement(org.codehaus.plexus.util.xml.XMLWriter w, java.lang.String name, java.lang.String text)
-
Methods inherited from class org.codehaus.modello.plugins.xml.AbstractXmlGenerator
getContentField, getFieldsForXml, getXmlAttributeFields, hasContentField, initHeader, resolveTagName, resolveTagName, resolveTagName
-
Methods inherited from class org.codehaus.modello.plugin.AbstractModelloGenerator
capitalise, contextualize, getBuildContext, getEncoding, getFieldsForClass, getGeneratedVersion, getHeader, getModel, getOutputDirectory, getParameter, getParameter, getParameter, initialize, isClassInModel, isCollection, isEmpty, isInnerAssociation, isMap, isPackageWithVersion, singular, uncapitalise
-
-
-
-
Field Detail
-
DEFAULT_VERSION_RANGE
private static final VersionRange DEFAULT_VERSION_RANGE
-
firstVersion
private Version firstVersion
-
version
private Version version
-
-
Method Detail
-
generate
public void generate(Model model, java.util.Properties parameters) throws ModelloException
- Throws:
ModelloException
-
generateXdoc
private void generateXdoc(java.util.Properties parameters) throws java.io.IOException
- Throws:
java.io.IOException
-
getAnchorName
private java.lang.String getAnchorName(java.lang.String tagName)
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- 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 writerrootModelClass
- the root class of the model
-
writeElementDescriptor
private void writeElementDescriptor(org.codehaus.plexus.util.xml.XMLWriter w, ModelClass modelClass, ModelAssociation association, java.util.Set<java.lang.String> written)
Write description of an element of the XML representation of the model. This method is recursive.- Parameters:
w
- the output writermodelClass
- the mode class to describeassociation
- the association we are coming from (can benull
)written
- set of data already written
-
getId
private java.lang.String getId(java.lang.String tagName, ModelClass modelClass)
-
writeFieldsTable
private void writeFieldsTable(org.codehaus.plexus.util.xml.XMLWriter w, java.util.List<ModelField> fields, boolean elementFields)
Write a table containing model fields description.- Parameters:
w
- the output writerfields
- the fields to add in the tableelementFields
-true
if fields are elements,false
if fields are attributes
-
getModelXmlDescriptor
private java.lang.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 java.lang.String getElementXmlDescriptor(ModelClass modelClass, ModelAssociation association, java.util.Stack<java.lang.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 modelassociation
- the association we are coming from (can benull
)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 java.lang.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 nameassociation
- the association where this class is used- Returns:
- the tag name to use
-
appendSpacer
private static void appendSpacer(java.lang.StringBuilder sb, int depth)
Appends the required spacers to the given StringBuilder.- Parameters:
sb
- where to append the spacersdepth
- the depth of spacers to generate
-
getDescription
private static java.lang.String getDescription(BaseElement element)
-
writeTextElement
private static void writeTextElement(org.codehaus.plexus.util.xml.XMLWriter w, java.lang.String name, java.lang.String text)
-
writeMarkupElement
private static void writeMarkupElement(org.codehaus.plexus.util.xml.XMLWriter w, java.lang.String name, java.lang.String markup)
-
rewrite
private static java.lang.String rewrite(java.lang.String text)
Ensures that text will have balanced tags- Parameters:
text
- xml or html based content- Returns:
- valid XML string
-
-