Package adams.doc.javadoc
Class Javadoc
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.doc.javadoc.Javadoc
-
- All Implemented Interfaces:
Destroyable
,LoggingSupporter
,OptionHandler
,UserModeSupporter
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
AllJavadoc
,FlowJavadoc
,GlobalInfoJavadoc
,GrammarJavadoc
,OptionHandlerJavadoc
,ScriptletJavadoc
,TechnicalInformationHandlerJavadoc
public abstract class Javadoc extends LoggingObject implements OptionHandler, UserModeSupporter
Abstract superclass for classes that generate Javadoc comments and replace the content between certain comment tags.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
Javadoc
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Classname
the classname.protected String
m_Dir
the directory above the class to update.protected String[]
m_EndTag
the end tag.protected String
m_Environment
the environment class (dummy option, happens all in runJavadoc method).protected boolean[]
m_IsBlock
whether to use identation.protected OptionManager
m_OptionManager
for managing the available options.protected boolean
m_Silent
whether to suppress error messages (no printout in the console).protected String[]
m_StartTag
the start tag.protected UserMode
m_UserMode
the user mode to generate the javadoc for.protected boolean
m_UseStars
whether to include the stars in the Javadoc.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description Javadoc()
Initializes the object, sets default options.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
canInstantiateClass()
returns true if the class can be instantiated, i.e., has a default constructor.String
classnameTipText()
Returns the tip text for this property.void
cleanUpOptions()
Cleans up the options.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.String
dirTipText()
Returns the tip text for this property.String
environmentTipText()
Returns the tip text for this property.static Javadoc
forCommandLine(String cmdline)
Instantiates the javadoc generator from the given commandline (i.e., classname and optional options).static Javadoc
forName(String classname, String[] options)
Instantiates the javadoc generator with the given options.String
generate()
generates either the plain Javadoc (if no filename specified) or the updated file (if a filename is specified).protected String
generateJavadoc()
generates and returns the Javadoc.protected abstract String
generateJavadoc(int index)
generates and returns the Javadoc for the specified start/end tag pair.String
getClassname()
returns the current classname.String
getDir()
returns the current dir containing the class to update.String
getEnvironment()
returns the current classname of the environment class to use.protected int
getIndentionLength(String str)
determines the number of indention strings that have to be inserted to generated the given indention string.protected String
getIndentionString(String str)
determines the base string of the given indention string, whether it's either only spaces (one space will be retured) or mixed mode (tabs and spaces, in that case the same string will be returned).protected Object
getInstance()
Returns a new instance of the class.static String[]
getJavadocs()
Returns a list with classnames of Javadoc generators.OptionManager
getOptionManager()
Returns the option manager.boolean
getSilent()
whether output in the console is suppressed.UserMode
getUserMode()
Returns the user mode to pass on to the producer if that supports it.boolean
getUseStars()
whether the Javadoc is prefixed with "*".protected String
indent(String content, int count, String indentStr)
indents the given string by a given number of indention strings.protected void
initialize()
Initializes the members.protected OptionManager
newOptionManager()
Returns a new instance of the option manager.protected void
println(Object o)
prints the given object to System.err.static void
runJavadoc(Class javadoc, String[] options)
runs the javadoc producer with the given commandline options.void
setClassname(String value)
sets the classname of the class to generate the Javadoc for.void
setDir(String value)
sets the dir containing the file that is to be updated.void
setEnvironment(String value)
sets the classname of the environment class to use.void
setSilent(boolean value)
sets whether to suppress output in the console.void
setUserMode(UserMode value)
Sets the user mode to pass on to the producer if that supports it.void
setUseStars(boolean value)
sets whether to prefix the Javadoc with "*".String
silentTipText()
Returns the tip text for this property.String
toCommandLine()
Returns the commandline string.protected String
toHTML(String s)
converts the given String into HTML, i.e., replacing some char entities with HTML entities.String
toString()
Returns the commandline of this object.String
updateJavadoc()
generates the Javadoc and returns it applied to the source file if one was provided, otherwise an empty string.protected String
updateJavadoc(String content)
updates the Javadoc in the given source code.protected String
updateJavadoc(String content, int index)
generates and returns the Javadoc for the specified start/end tag pair.String
userModeTipText()
Returns the tip text for this property.String
useStarsTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_StartTag
protected String[] m_StartTag
the start tag.
-
m_EndTag
protected String[] m_EndTag
the end tag.
-
m_IsBlock
protected boolean[] m_IsBlock
whether to use identation.
-
m_Classname
protected String m_Classname
the classname.
-
m_UseStars
protected boolean m_UseStars
whether to include the stars in the Javadoc.
-
m_Dir
protected String m_Dir
the directory above the class to update.
-
m_Silent
protected boolean m_Silent
whether to suppress error messages (no printout in the console).
-
m_Environment
protected String m_Environment
the environment class (dummy option, happens all in runJavadoc method).
-
m_UserMode
protected UserMode m_UserMode
the user mode to generate the javadoc for.
-
m_OptionManager
protected OptionManager m_OptionManager
for managing the available options.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
newOptionManager
protected OptionManager newOptionManager()
Returns a new instance of the option manager.- Returns:
- the manager to use
-
defineOptions
public void defineOptions()
Adds options to the internal list of options. Derived classes must override this method to add additional options.- Specified by:
defineOptions
in interfaceOptionHandler
-
getOptionManager
public OptionManager getOptionManager()
Returns the option manager.- Specified by:
getOptionManager
in interfaceOptionHandler
- Returns:
- the manager
-
cleanUpOptions
public void cleanUpOptions()
Cleans up the options.- Specified by:
cleanUpOptions
in interfaceOptionHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Cleans up the options.- Specified by:
destroy
in interfaceDestroyable
- See Also:
cleanUpOptions()
-
setEnvironment
public void setEnvironment(String value)
sets the classname of the environment class to use.- Parameters:
value
- the environment class name
-
getEnvironment
public String getEnvironment()
returns the current classname of the environment class to use.- Returns:
- the current classname of the environment class
-
environmentTipText
public String environmentTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setClassname
public void setClassname(String value)
sets the classname of the class to generate the Javadoc for.- Parameters:
value
- the new classname
-
getClassname
public String getClassname()
returns the current classname.- Returns:
- the current classname
-
classnameTipText
public String classnameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseStars
public void setUseStars(boolean value)
sets whether to prefix the Javadoc with "*".- Parameters:
value
- true if stars are used
-
getUseStars
public boolean getUseStars()
whether the Javadoc is prefixed with "*".- Returns:
- whether stars are used
-
useStarsTipText
public String useStarsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setDir
public void setDir(String value)
sets the dir containing the file that is to be updated. It is the dir above the package hierarchy of the class.- Parameters:
value
- the directory containing the classes
-
getDir
public String getDir()
returns the current dir containing the class to update. It is the dir above the package name of the class.- Returns:
- the current directory
-
dirTipText
public String dirTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSilent
public void setSilent(boolean value)
sets whether to suppress output in the console.- Parameters:
value
- true if output is to be suppressed
-
getSilent
public boolean getSilent()
whether output in the console is suppressed.- Returns:
- true if output is suppressed
-
silentTipText
public String silentTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUserMode
public void setUserMode(UserMode value)
Sets the user mode to pass on to the producer if that supports it.- Specified by:
setUserMode
in interfaceUserModeSupporter
- Parameters:
value
- the user mode
-
getUserMode
public UserMode getUserMode()
Returns the user mode to pass on to the producer if that supports it.- Specified by:
getUserMode
in interfaceUserModeSupporter
- Returns:
- the user mode
-
userModeTipText
public String userModeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
println
protected void println(Object o)
prints the given object to System.err.- Parameters:
o
- the object to print
-
canInstantiateClass
protected boolean canInstantiateClass()
returns true if the class can be instantiated, i.e., has a default constructor.- Returns:
- true if the class can be instantiated
-
getInstance
protected Object getInstance()
Returns a new instance of the class.- Returns:
- a new instance of the class
-
toHTML
protected String toHTML(String s)
converts the given String into HTML, i.e., replacing some char entities with HTML entities.- Parameters:
s
- the string to convert- Returns:
- the HTML conform string
-
indent
protected String indent(String content, int count, String indentStr)
indents the given string by a given number of indention strings.- Parameters:
content
- the string to indentcount
- the number of times to indent one lineindentStr
- the indention string- Returns:
- the indented content
-
generateJavadoc
protected abstract String generateJavadoc(int index) throws Exception
generates and returns the Javadoc for the specified start/end tag pair.- Parameters:
index
- the index in the start/end tag array- Returns:
- the generated Javadoc
- Throws:
Exception
- in case the generation fails
-
generateJavadoc
protected String generateJavadoc() throws Exception
generates and returns the Javadoc.- Returns:
- the generated Javadoc
- Throws:
Exception
- in case the generation fails
-
getIndentionString
protected String getIndentionString(String str)
determines the base string of the given indention string, whether it's either only spaces (one space will be retured) or mixed mode (tabs and spaces, in that case the same string will be returned).- Parameters:
str
- the string to analyze- Returns:
- the indention string
-
getIndentionLength
protected int getIndentionLength(String str)
determines the number of indention strings that have to be inserted to generated the given indention string.- Parameters:
str
- the string to analyze- Returns:
- the number of base indention strings to insert
-
updateJavadoc
protected String updateJavadoc(String content, int index) throws Exception
generates and returns the Javadoc for the specified start/end tag pair.- Parameters:
content
- the current source codeindex
- the index in the start/end tag array- Returns:
- the generated Javadoc
- Throws:
Exception
- in case the generation fails
-
updateJavadoc
protected String updateJavadoc(String content) throws Exception
updates the Javadoc in the given source code.- Parameters:
content
- the source code- Returns:
- the updated source code
- Throws:
Exception
- in case the generation fails
-
updateJavadoc
public String updateJavadoc() throws Exception
generates the Javadoc and returns it applied to the source file if one was provided, otherwise an empty string.- Returns:
- the generated Javadoc
- Throws:
Exception
- in case the generation fails
-
generate
public String generate() throws Exception
generates either the plain Javadoc (if no filename specified) or the updated file (if a filename is specified). The start and end tag for the global info have to be specified in the file in the latter case.- Returns:
- either the plain Javadoc or the modified file
- Throws:
Exception
- in case the generation fails
-
toString
public String toString()
Returns the commandline of this object.
-
toCommandLine
public String toCommandLine()
Returns the commandline string.- Specified by:
toCommandLine
in interfaceOptionHandler
- Returns:
- the commandline
-
forName
public static Javadoc forName(String classname, String[] options)
Instantiates the javadoc generator with the given options.- Parameters:
classname
- the classname of the javadoc generator to instantiateoptions
- the options for the javadoc generator- Returns:
- the instantiated javadoc generator or null if an error occurred
-
forCommandLine
public static Javadoc forCommandLine(String cmdline)
Instantiates the javadoc generator from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the javadoc generator to instantiate- Returns:
- the instantiated javadoc generator or null if an error occurred
-
runJavadoc
public static void runJavadoc(Class javadoc, String[] options)
runs the javadoc producer with the given commandline options.- Parameters:
javadoc
- the javadoc producer to executeoptions
- the commandline options
-
getJavadocs
public static String[] getJavadocs()
Returns a list with classnames of Javadoc generators.- Returns:
- the classnames
-
-