Class BaseFile
- All Implemented Interfaces:
io.github.mmm.code.api.CodeFile, io.github.mmm.code.api.CodePathElement, io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodeFile>, 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.CodeItemWithQualifiedName, io.github.mmm.code.api.item.CodeItemWithQualifiedNameAndParentPackage, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.item.CodeMutableItemWithComment, io.github.mmm.code.api.item.CodeMutableItemWithQualifiedName, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.node.CodeNodeWithFileWriting, io.github.mmm.code.api.object.CodeMutable
Base implementation of
CodeFile.- 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 copy-constructor.BaseFile(BasePackage parentPackage, Class<?> reflectiveObject, Supplier<BaseFile> sourceSupplier) The constructor.BaseFile(BasePackage parentPackage, String simpleName) The constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper) 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) Class<?> getType()io.github.mmm.code.api.type.CodeTypeio.github.mmm.code.api.type.CodeTypeio.github.mmm.code.api.type.CodeTypegetTypes()booleanisFile()voidvoidMethods inherited from class BasePathElement
doSetParentPackage, removeFromParentMethods inherited from class BaseElementWithQualifiedName
getParentPackage, getQualifiedName, getSimpleName, setParentPackage, setSimpleNameMethods inherited from class BaseElement
doInitialize, doMerge, doWriteAnnotations, doWriteComment, doWriteDoc, getAnnotations, getComment, getDoc, setCommentMethods inherited from class BaseNodeItem
getContainerItem, getContainerItemDeclared, getContext, getLanguage, getSource, toPathStringMethods inherited from class BaseMutableItem
doCopyNode, doCopyNodeUnsafe, doMapList, doneInitialize, getDefaultCopyMapper, getDefaultEncoding, 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
getAnnotations, getDoc, removeFromParentMethods 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.item.CodeItemWithComment
getCommentMethods inherited from interface io.github.mmm.code.api.item.CodeItemWithQualifiedName
getSimpleNameMethods inherited from interface io.github.mmm.code.api.item.CodeItemWithQualifiedNameAndParentPackage
getParentPackage, getQualifiedNameMethods inherited from interface io.github.mmm.code.api.object.CodeMutable
isImmutable, isMutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItem
setImmutableMethods inherited from interface io.github.mmm.code.api.item.CodeMutableItemWithComment
setCommentMethods inherited from interface io.github.mmm.code.api.CodeWithContext
getContext, getSource
-
Constructor Details
-
BaseFile
The constructor.- Parameters:
parentPackage- theparent package.simpleName- thesimple name.
-
BaseFile
public BaseFile(BasePackage parentPackage, Class<?> reflectiveObject, Supplier<BaseFile> sourceSupplier) The constructor.- Parameters:
parentPackage- theparent package.reflectiveObject- thereflective object. May benull.sourceSupplier- theSupplierof the lazy-loadedsource code object.
-
BaseFile
-
-
Method Details
-
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 classBaseElement
-
getParent
- Specified by:
getParentin interfaceio.github.mmm.code.api.node.CodeNode- Specified by:
getParentin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodeFile>- Specified by:
getParentin interfaceio.github.mmm.code.api.CodePathElement
-
isFile
public boolean isFile()- Specified by:
isFilein interfaceio.github.mmm.code.api.CodePathElement
-
getExtension
- Specified by:
getExtensionin interfaceio.github.mmm.code.api.CodeFile
-
getTypes
-
getType
- Parameters:
simpleName- thesimple nameof the requestedBaseTyperecursivelycontained in thisBaseFile.- Returns:
- the requested
BaseTypeornullif not found.
-
getType
- Parameters:
simpleName- thesimple nameof the requestedBaseTyperecursivelycontained in thisBaseFile.init- -trueto ensure the child types are properly initialized and the result is adequate,falseotherwise (to avoid initialization e.g. for internal calls during initialization).- Returns:
- the requested
BaseTypeornullif not found.
-
getType
public io.github.mmm.code.api.type.CodeType getType(String simpleName, boolean init, boolean resolve) - Parameters:
simpleName- thesimple nameof the requestedBaseTypeto resolve in the context of thisBaseFile.init- -trueto ensure the child types are properly initialized and the result is adequate,falseotherwise (to avoid initialization e.g. for internal calls during initialization).resolve- -trueto resolve the requestedBaseTypein thecontextof this file,falseotherwise (to only search for files contained in this file likegetType(String, boolean)).- Returns:
- the requested
BaseTypeornullif not found.
-
getType
- Specified by:
getTypein interfaceio.github.mmm.code.api.CodeFile
-
getImports
- Specified by:
getImportsin interfaceio.github.mmm.code.api.CodeFile
-
getReflectiveObject
- Specified by:
getReflectiveObjectin interfaceio.github.mmm.code.api.CodeFile- Specified by:
getReflectiveObjectin interfaceio.github.mmm.code.api.item.CodeMutableItem- Overrides:
getReflectiveObjectin classBaseMutableItem
-
getSourceCodeObject
- Overrides:
getSourceCodeObjectin classBaseElement- 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.
-
copy
- Specified by:
copyin interfaceio.github.mmm.code.api.element.CodeElement- Specified by:
copyin interfaceio.github.mmm.code.api.CodeFile- Specified by:
copyin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItem- Specified by:
copyin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodeFile>
-
copy
- Specified by:
copyin interfaceio.github.mmm.code.api.CodeFile- Specified by:
copyin interfaceio.github.mmm.code.api.item.CodeMutableItem- Specified by:
copyin interfaceio.github.mmm.code.api.node.CodeNodeItem- Specified by:
copyin interfaceio.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodeFile>
-
doWrite
protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException - Overrides:
doWritein classBaseElement- 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:
-
write
- Specified by:
writein interfaceio.github.mmm.code.api.node.CodeNodeWithFileWriting
-
write
-