Package adams.doc.latex.generator
Class AbstractCodeGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.doc.latex.generator.AbstractCodeGenerator
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.QuickInfoSupporter
,adams.core.SizeOfHandler
,CodeGenerator
,adams.flow.core.FlowContextHandler
,Serializable
- Direct Known Subclasses:
AbstractEnvironmentWithNoTrailingSpace
,AbstractFileReferencingCodeGenerator
,AbstractMetaCodeGenerator
,ClearPage
,CustomStatements
,Dummy
,ImportContent
,ListOfFigures
,ListOfTables
,MultiGenerator
,NewPage
,NewSection
,Table
,TableOfContents
public abstract class AbstractCodeGenerator extends adams.core.option.AbstractOptionHandler implements CodeGenerator
Ancestor for LaTeX code generators.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.flow.core.Actor
m_FlowContext
the flow context.protected boolean
m_NoVariableExpansion
whether to not expand variables.protected boolean
m_Skip
whether to skip the transformation and just forward the token.
-
Constructor Summary
Constructors Constructor Description AbstractCodeGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
check()
Hook method for performing checks.void
defineOptions()
Adds options to the internal list of options.protected abstract String
doGenerate()
Generates the actual code.protected String
ensureTrailingNewLine(String s)
Ensures that a trailing newline is present.protected void
ensureTrailingNewLine(StringBuilder s)
Ensures that a trailing newline is present.protected String
escape(String s)
Escapes all characters.protected String
expand(String s)
Expands the variables in the string, unless it is skipped.protected String
expandEscape(String s)
Expands and then escapes the string.String
generate()
Generates the code.String
getAdditionalInformation()
Returns the additional information.adams.flow.core.Actor
getFlowContext()
Returns the flow context, if any.boolean
getNoVariableExpansion()
Returns whether to skip variable expansion.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.abstract String[]
getRequiredPackages()
Returns the list of required LaTeX packages for this code generator.boolean
getSkip()
Returns whether the generator is skipped.String
noVariableExpansionTipText()
Returns the tip text for this property.void
setFlowContext(adams.flow.core.Actor value)
Sets the flow context.void
setNoVariableExpansion(boolean value)
Sets whether to skip variable expansion.void
setSkip(boolean value)
Sets whether the generator is skipped.String
skipTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
setSkip
public void setSkip(boolean value)
Sets whether the generator is skipped.- Specified by:
setSkip
in interfaceCodeGenerator
- Parameters:
value
- true if generation is to be skipped
-
getSkip
public boolean getSkip()
Returns whether the generator is skipped.- Specified by:
getSkip
in interfaceCodeGenerator
- Returns:
- true if generation is skipped
-
skipTipText
public String skipTipText()
Returns the tip text for this property.- Specified by:
skipTipText
in interfaceCodeGenerator
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNoVariableExpansion
public void setNoVariableExpansion(boolean value)
Sets whether to skip variable expansion.- Specified by:
setNoVariableExpansion
in interfaceCodeGenerator
- Parameters:
value
- true if to skip
-
getNoVariableExpansion
public boolean getNoVariableExpansion()
Returns whether to skip variable expansion.- Specified by:
getNoVariableExpansion
in interfaceCodeGenerator
- Returns:
- true if to skip
-
noVariableExpansionTipText
public String noVariableExpansionTipText()
Returns the tip text for this property.- Specified by:
noVariableExpansionTipText
in interfaceCodeGenerator
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFlowContext
public void setFlowContext(adams.flow.core.Actor value)
Sets the flow context.- Specified by:
setFlowContext
in interfaceCodeGenerator
- Specified by:
setFlowContext
in interfaceadams.flow.core.FlowContextHandler
- Parameters:
value
- the actor
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContext
in interfaceCodeGenerator
- Specified by:
getFlowContext
in interfaceadams.flow.core.FlowContextHandler
- Returns:
- the actor, null if none available
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceCodeGenerator
- Specified by:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
getRequiredPackages
public abstract String[] getRequiredPackages()
Returns the list of required LaTeX packages for this code generator.- Specified by:
getRequiredPackages
in interfaceCodeGenerator
- Returns:
- the packages
-
getAdditionalInformation
public String getAdditionalInformation()
Returns the additional information.- Specified by:
getAdditionalInformation
in interfaceadams.core.AdditionalInformationHandler
- Specified by:
getAdditionalInformation
in interfaceCodeGenerator
- Returns:
- the additional information, null or 0-length string for no information
-
check
protected void check()
Hook method for performing checks.
Will raise anIllegalStateException
if check fails.
-
escape
protected String escape(String s)
Escapes all characters.- Parameters:
s
- the string to escape- Returns:
- the escaped string
-
expand
protected String expand(String s)
Expands the variables in the string, unless it is skipped.- Parameters:
s
- the string to expand- Returns:
- the (potentially) expanded string
- See Also:
getNoVariableExpansion()
-
expandEscape
protected String expandEscape(String s)
Expands and then escapes the string.- Parameters:
s
- the string to expand/escaped- Returns:
- the modified string
-
ensureTrailingNewLine
protected String ensureTrailingNewLine(String s)
Ensures that a trailing newline is present.- Parameters:
s
- the string to check/modify- Returns:
- the (potentially) appended string
-
ensureTrailingNewLine
protected void ensureTrailingNewLine(StringBuilder s)
Ensures that a trailing newline is present.- Parameters:
s
- the StringBuilder to check/modify
-
doGenerate
protected abstract String doGenerate()
Generates the actual code.- Returns:
- the generated code
-
generate
public String generate()
Generates the code.- Specified by:
generate
in interfaceCodeGenerator
- Returns:
- the generated code
-
-