Package org.pkl.core.stdlib
Class AbstractRenderer
- java.lang.Object
-
- org.pkl.core.stdlib.AbstractRenderer
-
- All Implemented Interfaces:
VmValueVisitor
- Direct Known Subclasses:
PcfRenderer,RendererNodes.Renderer
public abstract class AbstractRenderer extends java.lang.Object implements VmValueVisitor
Base class for renderers that are part of the standard library.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBuilderbuilderprotected PklConverterconverterprotected java.lang.StringBuildercurrIndentThe current indent.protected java.util.Deque<java.lang.Object>currPathprotected @Nullable com.oracle.truffle.api.source.SourceSectioncurrSourceSectionThe (closest)SourceSectionof the value being visited, for better error messages.protected @Nullable VmValueenclosingValueThe value directly enclosing the currently visited value, if any.protected java.lang.StringindentThe indent to be used.protected static charLINE_BREAKprotected java.lang.StringnameThe name of this renderer.
-
Constructor Summary
Constructors Constructor Description AbstractRenderer(java.lang.String name, java.lang.StringBuilder builder, java.lang.String indent, PklConverter converter, boolean skipNullProperties, boolean skipNullEntries)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcannotRenderNonStringKey(java.lang.Object key)protected voidcannotRenderTypeAddConverter(VmValue value)protected booleancanRenderPropertyOrEntryOf(VmDynamic object)protected voiddecreaseIndent()protected abstract voidendDynamic(VmDynamic value, boolean isEmpty)protected abstract voidendList(VmList value)protected abstract voidendListing(VmListing value, boolean isEmpty)protected abstract voidendMap(VmMap value)protected abstract voidendMapping(VmMapping value, boolean isEmpty)protected abstract voidendSet(VmSet value)protected abstract voidendTyped(VmTyped value, boolean isEmpty)protected voidincreaseIndent()voidrenderDocument(java.lang.Object value)voidrenderValue(java.lang.Object value)protected abstract voidstartDynamic(VmDynamic value)protected abstract voidstartList(VmList value)protected abstract voidstartListing(VmListing value)protected abstract voidstartMap(VmMap value)protected abstract voidstartMapping(VmMapping value)protected abstract voidstartSet(VmSet value)protected abstract voidstartTyped(VmTyped value)voidvisit(java.lang.Object value)voidvisitClass(VmClass value)protected abstract voidvisitDocument(java.lang.Object value)voidvisitDynamic(VmDynamic value)protected abstract voidvisitElement(long index, java.lang.Object value, boolean isFirst)protected abstract voidvisitEntryKey(java.lang.Object key, boolean isFirst)protected abstract voidvisitEntryValue(java.lang.Object value)voidvisitFunction(VmFunction value)voidvisitList(VmList value)voidvisitListing(VmListing value)voidvisitMap(VmMap value)voidvisitMapping(VmMapping value)protected abstract voidvisitProperty(Identifier name, java.lang.Object value, boolean isFirst)protected abstract voidvisitRenderDirective(VmTyped value)Perform logic for rendering a render directive.voidvisitSet(VmSet value)protected abstract voidvisitTopLevelValue(java.lang.Object value)voidvisitTypeAlias(VmTypeAlias value)voidvisitTyped(VmTyped value)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pkl.core.runtime.VmValueVisitor
visitBoolean, visitDataSize, visitDuration, visitFloat, visitInt, visitIntSeq, visitNull, visitPair, visitRegex, visitString
-
-
-
-
Field Detail
-
LINE_BREAK
protected static final char LINE_BREAK
- See Also:
- Constant Field Values
-
name
protected final java.lang.String name
The name of this renderer.
-
builder
protected final java.lang.StringBuilder builder
-
indent
protected final java.lang.String indent
The indent to be used.
-
converter
protected final PklConverter converter
-
currPath
protected java.util.Deque<java.lang.Object> currPath
-
enclosingValue
protected @Nullable VmValue enclosingValue
The value directly enclosing the currently visited value, if any.
-
currIndent
protected java.lang.StringBuilder currIndent
The current indent. Modified byincreaseIndent()anddecreaseIndent().
-
currSourceSection
protected @Nullable com.oracle.truffle.api.source.SourceSection currSourceSection
The (closest)SourceSectionof the value being visited, for better error messages.
-
-
Constructor Detail
-
AbstractRenderer
public AbstractRenderer(java.lang.String name, java.lang.StringBuilder builder, java.lang.String indent, PklConverter converter, boolean skipNullProperties, boolean skipNullEntries)
-
-
Method Detail
-
renderDocument
public final void renderDocument(java.lang.Object value)
-
renderValue
public final void renderValue(java.lang.Object value)
-
visit
public void visit(java.lang.Object value)
- Specified by:
visitin interfaceVmValueVisitor
-
visitDocument
protected abstract void visitDocument(java.lang.Object value)
-
visitTopLevelValue
protected abstract void visitTopLevelValue(java.lang.Object value)
-
visitRenderDirective
protected abstract void visitRenderDirective(VmTyped value)
Perform logic for rendering a render directive. Render directives should be rendered verbatim.
-
startDynamic
protected abstract void startDynamic(VmDynamic value)
-
startTyped
protected abstract void startTyped(VmTyped value)
-
startListing
protected abstract void startListing(VmListing value)
-
startMapping
protected abstract void startMapping(VmMapping value)
-
startList
protected abstract void startList(VmList value)
-
startSet
protected abstract void startSet(VmSet value)
-
startMap
protected abstract void startMap(VmMap value)
-
visitElement
protected abstract void visitElement(long index, java.lang.Object value, boolean isFirst)
-
visitEntryKey
protected abstract void visitEntryKey(java.lang.Object key, boolean isFirst)
-
visitEntryValue
protected abstract void visitEntryValue(java.lang.Object value)
-
visitProperty
protected abstract void visitProperty(Identifier name, java.lang.Object value, boolean isFirst)
-
endDynamic
protected abstract void endDynamic(VmDynamic value, boolean isEmpty)
-
endTyped
protected abstract void endTyped(VmTyped value, boolean isEmpty)
-
endListing
protected abstract void endListing(VmListing value, boolean isEmpty)
-
endMapping
protected abstract void endMapping(VmMapping value, boolean isEmpty)
-
endList
protected abstract void endList(VmList value)
-
endSet
protected abstract void endSet(VmSet value)
-
endMap
protected abstract void endMap(VmMap value)
-
visitTyped
public void visitTyped(VmTyped value)
- Specified by:
visitTypedin interfaceVmValueVisitor
-
visitDynamic
public final void visitDynamic(VmDynamic value)
- Specified by:
visitDynamicin interfaceVmValueVisitor
-
canRenderPropertyOrEntryOf
protected boolean canRenderPropertyOrEntryOf(VmDynamic object)
-
visitListing
public final void visitListing(VmListing value)
- Specified by:
visitListingin interfaceVmValueVisitor
-
visitMapping
public final void visitMapping(VmMapping value)
- Specified by:
visitMappingin interfaceVmValueVisitor
-
visitList
public final void visitList(VmList value)
- Specified by:
visitListin interfaceVmValueVisitor
-
visitSet
public final void visitSet(VmSet value)
- Specified by:
visitSetin interfaceVmValueVisitor
-
visitMap
public final void visitMap(VmMap value)
- Specified by:
visitMapin interfaceVmValueVisitor
-
visitTypeAlias
public final void visitTypeAlias(VmTypeAlias value)
- Specified by:
visitTypeAliasin interfaceVmValueVisitor
-
visitClass
public final void visitClass(VmClass value)
- Specified by:
visitClassin interfaceVmValueVisitor
-
visitFunction
public final void visitFunction(VmFunction value)
- Specified by:
visitFunctionin interfaceVmValueVisitor
-
cannotRenderTypeAddConverter
protected void cannotRenderTypeAddConverter(VmValue value)
-
cannotRenderNonStringKey
protected void cannotRenderNonStringKey(java.lang.Object key)
-
increaseIndent
protected void increaseIndent()
-
decreaseIndent
protected void decreaseIndent()
-
-