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.Actorm_FlowContextthe flow context.protected booleanm_NoVariableExpansionwhether to not expand variables.protected booleanm_Skipwhether 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 voidcheck()Hook method for performing checks.voiddefineOptions()Adds options to the internal list of options.protected abstract StringdoGenerate()Generates the actual code.protected StringensureTrailingNewLine(String s)Ensures that a trailing newline is present.protected voidensureTrailingNewLine(StringBuilder s)Ensures that a trailing newline is present.protected Stringescape(String s)Escapes all characters.protected Stringexpand(String s)Expands the variables in the string, unless it is skipped.protected StringexpandEscape(String s)Expands and then escapes the string.Stringgenerate()Generates the code.StringgetAdditionalInformation()Returns the additional information.adams.flow.core.ActorgetFlowContext()Returns the flow context, if any.booleangetNoVariableExpansion()Returns whether to skip variable expansion.StringgetQuickInfo()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.booleangetSkip()Returns whether the generator is skipped.StringnoVariableExpansionTipText()Returns the tip text for this property.voidsetFlowContext(adams.flow.core.Actor value)Sets the flow context.voidsetNoVariableExpansion(boolean value)Sets whether to skip variable expansion.voidsetSkip(boolean value)Sets whether the generator is skipped.StringskipTipText()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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
setSkip
public void setSkip(boolean value)
Sets whether the generator is skipped.- Specified by:
setSkipin interfaceCodeGenerator- Parameters:
value- true if generation is to be skipped
-
getSkip
public boolean getSkip()
Returns whether the generator is skipped.- Specified by:
getSkipin interfaceCodeGenerator- Returns:
- true if generation is skipped
-
skipTipText
public String skipTipText()
Returns the tip text for this property.- Specified by:
skipTipTextin 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:
setNoVariableExpansionin interfaceCodeGenerator- Parameters:
value- true if to skip
-
getNoVariableExpansion
public boolean getNoVariableExpansion()
Returns whether to skip variable expansion.- Specified by:
getNoVariableExpansionin interfaceCodeGenerator- Returns:
- true if to skip
-
noVariableExpansionTipText
public String noVariableExpansionTipText()
Returns the tip text for this property.- Specified by:
noVariableExpansionTipTextin 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:
setFlowContextin interfaceCodeGenerator- Specified by:
setFlowContextin interfaceadams.flow.core.FlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin interfaceCodeGenerator- Specified by:
getFlowContextin 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:
getQuickInfoin interfaceCodeGenerator- Specified by:
getQuickInfoin 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:
getRequiredPackagesin interfaceCodeGenerator- Returns:
- the packages
-
getAdditionalInformation
public String getAdditionalInformation()
Returns the additional information.- Specified by:
getAdditionalInformationin interfaceadams.core.AdditionalInformationHandler- Specified by:
getAdditionalInformationin interfaceCodeGenerator- Returns:
- the additional information, null or 0-length string for no information
-
check
protected void check()
Hook method for performing checks.
Will raise anIllegalStateExceptionif 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:
generatein interfaceCodeGenerator- Returns:
- the generated code
-
-