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
@Component(role=ModelloGenerator.class,
hint="xdoc")
public class XdocGenerator
extends AbstractXmlGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final VersionRange
private Version
private Version
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
appendSpacer
(StringBuilder sb, int depth) Appends the required spacers to the given StringBuilder.void
generate
(Model model, Properties parameters) private void
generateXdoc
(Properties parameters) private String
getAnchorName
(String tagName, ModelClass modelClass) Get the anchor name by which model classes can be accessed in the generated xdoc/html file.private static String
getDescription
(BaseElement element) private String
getElementXmlDescriptor
(ModelClass modelClass, ModelAssociation association, Stack<String> stack) Build the pretty tree describing the XML representation of an element of the model.private String
getId
(String tagName, ModelClass modelClass) private String
getModelXmlDescriptor
(ModelClass rootModelClass) Build the pretty tree describing the XML representation of the model.private String
resolveTagName
(ModelClass modelClass, ModelAssociation association) Compute the tagName of a given class, living inside an association.private static String
Ensures that text will have balanced tagsprivate 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.private void
writeFieldsTable
(org.codehaus.plexus.util.xml.XMLWriter w, List<ModelField> fields, boolean elementFields) Write a table containing model fields description.private static void
writeMarkupElement
(org.codehaus.plexus.util.xml.XMLWriter w, String name, 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, String name, 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, newWriter, newWriter, singular, uncapitalise
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
DEFAULT_VERSION_RANGE
-
firstVersion
-
version
-
-
Constructor Details
-
XdocGenerator
public XdocGenerator()
-
-
Method Details
-
generate
- Throws:
ModelloException
-
generateXdoc
- Throws:
IOException
-
getAnchorName
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 classmodelClass
- 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 writerrootModelClass
- 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 writermodelClass
- the mode class to describeassociation
- the association we are coming from (can benull
)writtenIds
- set of data already written idswrittenAnchors
- map of already written anchors with corresponding ids
-
getId
-
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 writerfields
- the fields to add in the tableelementFields
-true
if fields are elements,false
if fields are attributes
-
getModelXmlDescriptor
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 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
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
Appends the required spacers to the given StringBuilder.- Parameters:
sb
- where to append the spacersdepth
- the depth of spacers to generate
-
getDescription
-
writeTextElement
-
writeMarkupElement
-
rewrite
Ensures that text will have balanced tags- Parameters:
text
- xml or html based content- Returns:
- valid XML string
-