Class BaseBlock
java.lang.Object
io.github.mmm.code.base.item.BaseItem
io.github.mmm.code.base.item.BaseMutableItem
io.github.mmm.code.base.node.BaseNodeItem
io.github.mmm.code.base.block.BaseBlock
- All Implemented Interfaces:
io.github.mmm.code.api.block.CodeBlock, io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithVariables, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.object.CodeMutable
- Direct Known Subclasses:
BaseBlockBody, BaseBlockInitializer, BaseBlockStatement
public abstract class BaseBlock
extends BaseNodeItem
implements io.github.mmm.code.api.block.CodeBlock
Base implementation of
CodeBlock.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
Field Summary
Fields inherited from interface io.github.mmm.code.api.item.CodeItem
DEFAULT_INDENT, DEFAULT_NEWLINE -
Constructor Summary
ConstructorsConstructorDescriptionBaseBlock(io.github.mmm.code.api.statement.CodeStatement... statements) The constructor.The copy-constructor.The constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(io.github.mmm.code.api.statement.CodeStatement... codeStatements) voidprotected voidCalled on the first call ofBaseMutableItem.setImmutable().protected voiddoWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) List<io.github.mmm.code.api.statement.CodeStatement> io.github.mmm.code.api.expression.CodeVariablegetVariable(String name) io.github.mmm.code.api.expression.CodeVariablegetVariable(String name, int statementIndex) protected abstract io.github.mmm.code.api.expression.CodeVariablegetVariableFromParent(String name) protected voidwritePrefix(Appendable sink, String newline, String defaultIndent, String currentIndent) Writes a prefix e.g. for loops.protected voidwriteSuffix(Appendable sink, String newline, String defaultIndent, String currentIndent) Writes a suffix e.g. for do-while loops.Methods inherited from class BaseNodeItem
doInitialize, getContainerItem, getContainerItemDeclared, getContext, getLanguage, getSource, toPathStringMethods inherited from class BaseMutableItem
doCopyNode, doCopyNodeUnsafe, doMapList, doneInitialize, getDefaultCopyMapper, getDefaultEncoding, getReflectiveObject, getSourceCodeObject, initialize, initialize, isImmutable, isInitialized, isInitializing, isSystemImmutable, isSystemImmutable, makeImmutable, makeImmutable, setImmutable, setImmutableIfNotSystemImmutable, verifyMutalbe, writeItemMethods inherited from class BaseItem
getOwningType, getSourceCode, getSpaces, toString, writeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.mmm.code.api.block.CodeBlock
copy, isEmptyMethods inherited from interface io.github.mmm.code.api.item.CodeItem
getLanguage, getSourceCode, write, write, write, write, write, writeMethods inherited from interface io.github.mmm.code.api.object.CodeMutable
isImmutable, isMutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItem
getReflectiveObject, setImmutableMethods inherited from interface io.github.mmm.code.api.node.CodeNode
getParentMethods inherited from interface io.github.mmm.code.api.node.CodeNodeItem
copyMethods inherited from interface io.github.mmm.code.api.CodeWithContext
getContext, getSource
-
Constructor Details
-
BaseBlock
public BaseBlock(io.github.mmm.code.api.statement.CodeStatement... statements) The constructor.- Parameters:
statements- thestatements.
-
BaseBlock
The constructor.- Parameters:
statements- thestatements.
-
BaseBlock
-
-
Method Details
-
getVariable
- Specified by:
getVariablein interfaceio.github.mmm.code.api.block.CodeBlock- Specified by:
getVariablein interfaceio.github.mmm.code.api.item.CodeItemWithVariables
-
getVariable
- Specified by:
getVariablein interfaceio.github.mmm.code.api.block.CodeBlock
-
getVariableFromParent
protected abstract io.github.mmm.code.api.expression.CodeVariable getVariableFromParent(String name) - Parameters:
name- thenameof the requestedCodeVariable.- Returns:
- the
CodeVariabledeclared by theparent nodewith the givennameornullif not found.
-
doSetImmutable
protected void doSetImmutable()Description copied from class:BaseMutableItemCalled on the first call ofBaseMutableItem.setImmutable(). Has to be overridden to updateCollections, make child items immutable, etc.- Overrides:
doSetImmutablein classBaseMutableItem
-
getStatements
- Specified by:
getStatementsin interfaceio.github.mmm.code.api.block.CodeBlock
-
add
public void add(io.github.mmm.code.api.statement.CodeStatement... codeStatements) - Specified by:
addin interfaceio.github.mmm.code.api.block.CodeBlock
-
addText
- Specified by:
addTextin interfaceio.github.mmm.code.api.block.CodeBlock
-
doWrite
protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException - Specified by:
doWritein classBaseItem- Parameters:
sink- theAppendablewhere toappendthe code from thisCodeItem.newline- the newlineString.defaultIndent- theStringused for indentation (e.g. a number of spaces to insert per indent level).currentIndent- the current indent (number of spaces). Initially the empty string (""). Before a recursion thedefaultIndentwill be appended.language- theCodeLanguageto use.- Throws:
IOException- if thrown byAppendable.- See Also:
-
writePrefix
protected void writePrefix(Appendable sink, String newline, String defaultIndent, String currentIndent) throws IOException Writes a prefix e.g. for loops.- Parameters:
sink- theAppendablewhere toappendthe code from thisCodeItem.newline- the newlineString.defaultIndent- theStringused for indentation (e.g. a number of spaces to insert per indent level).currentIndent- the current indent (number of spaces). Initially the empty string (""). Before a recursion theindentwill be appended.- Throws:
IOException- if thrown byAppendable.
-
writeSuffix
protected void writeSuffix(Appendable sink, String newline, String defaultIndent, String currentIndent) throws IOException Writes a suffix e.g. for do-while loops.- Parameters:
sink- theAppendablewhere toappendthe code from thisCodeItem.newline- the newlineString.defaultIndent- theStringused for indentation (e.g. a number of spaces to insert per indent level).currentIndent- the current indent (number of spaces). Initially the empty string (""). Before a recursion theindentwill be appended.- Throws:
IOException- if thrown byAppendable.
-