Class BaseElement
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.element.BaseElement
- All Implemented Interfaces:
io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithComment, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.item.CodeMutableItemWithComment, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.object.CodeMutable
- Direct Known Subclasses:
BaseElementWithDeclaringType, BaseElementWithQualifiedName
public abstract class BaseElement
extends BaseNodeItem
implements io.github.mmm.code.api.element.CodeElement
Base implementation of
CodeElement.- 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
ConstructorsConstructorDescriptionThe constructor.BaseElement(BaseElement template, io.github.mmm.code.api.copy.CodeCopyMapper mapper) The copy-constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled fromBaseMutableItem.initialize()on first invocation.protected voiddoMerge(io.github.mmm.code.api.element.CodeElement other, io.github.mmm.code.api.merge.CodeMergeStrategy strategy) protected 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) protected voiddoWriteAnnotations(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) Writes theannotations.protected voiddoWriteComment(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) Writes thecomment.protected voiddoWriteDoc(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) Writes theJavaDoc.io.github.mmm.code.api.comment.CodeCommentgetDoc()io.github.mmm.code.api.element.CodeElementvoidvoidsetComment(io.github.mmm.code.api.comment.CodeComment comment) Methods inherited from class BaseNodeItem
getContainerItem, getContainerItemDeclared, getContext, getLanguage, getSource, toPathStringMethods inherited from class BaseMutableItem
doCopyNode, doCopyNodeUnsafe, doMapList, doneInitialize, getDefaultCopyMapper, getDefaultEncoding, getReflectiveObject, 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.element.CodeElement
copyMethods 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
-
BaseElement
public BaseElement()The constructor. -
BaseElement
The copy-constructor.- Parameters:
template- theBaseElementto copy.mapper- theCodeCopyMapper.
-
-
Method Details
-
doInitialize
protected void doInitialize()Description copied from class:BaseNodeItemCalled fromBaseMutableItem.initialize()on first invocation. May be overridden but never be called from anywhere else.- Overrides:
doInitializein classBaseNodeItem
-
removeFromParent
public void removeFromParent()- Specified by:
removeFromParentin interfaceio.github.mmm.code.api.element.CodeElement
-
getDoc
- Specified by:
getDocin interfaceio.github.mmm.code.api.element.CodeElement
-
getAnnotations
- Specified by:
getAnnotationsin interfaceio.github.mmm.code.api.element.CodeElement
-
getComment
public io.github.mmm.code.api.comment.CodeComment getComment()- Specified by:
getCommentin interfaceio.github.mmm.code.api.item.CodeItemWithComment
-
setComment
public void setComment(io.github.mmm.code.api.comment.CodeComment comment) - Specified by:
setCommentin interfaceio.github.mmm.code.api.item.CodeMutableItemWithComment
-
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
-
getSourceCodeObject
public io.github.mmm.code.api.element.CodeElement getSourceCodeObject()- Overrides:
getSourceCodeObjectin classBaseMutableItem- Returns:
- the optional internal
CodeItemrepresenting the source-code (to merge). Otherwisenull. This is an internal API. Do not use or rely on it from outside.
-
doMerge
protected void doMerge(io.github.mmm.code.api.element.CodeElement other, io.github.mmm.code.api.merge.CodeMergeStrategy strategy) - Parameters:
other- theCodeElementtomerge.strategy- theCodeMergeStrategy.
-
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:
-
doWriteComment
protected void doWriteComment(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException Writes thecomment.- Parameters:
sink- theAppendable.newline- the newlineString.defaultIndent- the default indent.currentIndent- the current indent.language- theCodeLanguage.- Throws:
IOException- if thrown byAppendable.
-
doWriteDoc
protected void doWriteDoc(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) Writes theJavaDoc.- Parameters:
sink- theAppendable.newline- the newlineString.defaultIndent- the default indent.currentIndent- the current indent.language- theCodeLanguage.
-
doWriteAnnotations
protected void doWriteAnnotations(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) Writes theannotations.- Parameters:
sink- theAppendable.newline- the newlineString.defaultIndent- the default indent.currentIndent- the current indent.language- theCodeLanguage.
-