Package adams.core
Class PropertiesToCode
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.PropertiesToCode
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
public class PropertiesToCode extends AbstractOptionHandler
Turns a Properties object into Java code.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Comment
the comment to use in the class javadoc.protected String
m_Copyright
the copyright string.protected int
m_Indentation
the indentation level.protected String
m_Package
the package of the class.protected String
m_SimpleName
the simple name of the class.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description PropertiesToCode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addClassEnd(StringBuilder output)
Adds the end of the enclosing "class" statement.protected void
addClassJavadoc(StringBuilder output)
Adds the Javadoc for the class.protected void
addClassStart(StringBuilder output, Properties props, List<String> keys)
Adds the start of the enclosing "class" statement, including constants and member variables.protected void
addCopyright(StringBuilder output)
Adds the copyright notice.protected void
addImports(StringBuilder output)
Adds the imports.protected void
addLicensePreamble(StringBuilder output)
Adds the license preamble.protected void
addMethod(StringBuilder output, Properties props, List<String> keys)
Adds the method that returns the properties (and instantiates if necessary).protected void
addPackage(StringBuilder output)
Adds the package for the generated code.String
commentTipText()
Returns the tip text for this property.String
copyrightTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected String
escapeDoubleQuotes(String s)
Properly escapes double quotes.String
generate(Properties props)
Turns the properties object into Java code.String
getComment()
Returns the comment to use for the class javadoc.String
getCopyright()
Returns the copyright entity.int
getIndentation()
Returns the indentation.protected String
getIndentation(int level)
Returns the indentation for code at the specified level.String
getPackage()
Returns the package name to use.protected List<String>
getRequiredImports()
Returns the classnames that are required for the code to work.String
getSimpleName()
Returns the simple name to use.String
globalInfo()
Returns a string describing the object.String
indentationTipText()
Returns the tip text for this property.String
packageTipText()
Returns the tip text for this property.void
setComment(String value)
Sets the comment to use for the class javadoc.void
setCopyright(String value)
Sets the copyright entity.void
setIndentation(int value)
Sets the indentation.void
setPackage(String value)
Sets the package name of the class to generate.void
setSimpleName(String value)
Sets the simple name (without package) of the class to generate.String
simpleNameTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Copyright
protected String m_Copyright
the copyright string.
-
m_Package
protected String m_Package
the package of the class.
-
m_SimpleName
protected String m_SimpleName
the simple name of the class.
-
m_Comment
protected String m_Comment
the comment to use in the class javadoc.
-
m_Indentation
protected int m_Indentation
the indentation level.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
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
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setCopyright
public void setCopyright(String value)
Sets the copyright entity.- Parameters:
value
- the entity owning the copyright
-
getCopyright
public String getCopyright()
Returns the copyright entity.- Returns:
- the entity owning the copyright
-
copyrightTipText
public String copyrightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSimpleName
public void setSimpleName(String value)
Sets the simple name (without package) of the class to generate.- Parameters:
value
- the simple name
-
getSimpleName
public String getSimpleName()
Returns the simple name to use.- Returns:
- the simple name
-
simpleNameTipText
public String simpleNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPackage
public void setPackage(String value)
Sets the package name of the class to generate.- Parameters:
value
- the package name
-
getPackage
public String getPackage()
Returns the package name to use.- Returns:
- the package name
-
packageTipText
public String packageTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setComment
public void setComment(String value)
Sets the comment to use for the class javadoc. If left empty, an auto-generated comment is used.- Parameters:
value
- the comment
-
getComment
public String getComment()
Returns the comment to use for the class javadoc. If left empty, an auto-generated comment is used.- Returns:
- the comment
-
commentTipText
public String commentTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setIndentation
public void setIndentation(int value)
Sets the indentation.- Parameters:
value
- the number of spaces
-
getIndentation
public int getIndentation()
Returns the indentation.- Returns:
- the number of spaces
-
indentationTipText
public String indentationTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getIndentation
protected String getIndentation(int level)
Returns the indentation for code at the specified level.- Parameters:
level
- the indentation level- Returns:
- the indentation string
-
addLicensePreamble
protected void addLicensePreamble(StringBuilder output)
Adds the license preamble.- Parameters:
output
- the buffer to add to
-
addCopyright
protected void addCopyright(StringBuilder output)
Adds the copyright notice.- Parameters:
output
- the buffer to add to
-
addPackage
protected void addPackage(StringBuilder output)
Adds the package for the generated code.- Parameters:
output
- the buffer to add to
-
getRequiredImports
protected List<String> getRequiredImports()
Returns the classnames that are required for the code to work.- Returns:
- the classes
-
addImports
protected void addImports(StringBuilder output)
Adds the imports.- Parameters:
output
- the buffer to add to
-
addClassJavadoc
protected void addClassJavadoc(StringBuilder output)
Adds the Javadoc for the class.- Parameters:
output
- the buffer to add to
-
escapeDoubleQuotes
protected String escapeDoubleQuotes(String s)
Properly escapes double quotes.- Parameters:
s
- the string to process- Returns:
- the processed string
-
addClassStart
protected void addClassStart(StringBuilder output, Properties props, List<String> keys)
Adds the start of the enclosing "class" statement, including constants and member variables.- Parameters:
output
- the buffer to add toprops
- the properties to usekeys
- the ordered keys
-
addMethod
protected void addMethod(StringBuilder output, Properties props, List<String> keys)
Adds the method that returns the properties (and instantiates if necessary).- Parameters:
output
- the buffer to add toprops
- the properties to usekeys
- the ordered keys
-
addClassEnd
protected void addClassEnd(StringBuilder output)
Adds the end of the enclosing "class" statement.- Parameters:
output
- the buffer to add to
-
generate
public String generate(Properties props)
Turns the properties object into Java code.- Parameters:
props
- the properties to convert- Returns:
- the generated code
-
-