Class AbstractRenderer

java.lang.Object
org.pkl.core.stdlib.AbstractRenderer
All Implemented Interfaces:
VmValueVisitor
Direct Known Subclasses:
AbstractStringRenderer, VmPklBinaryEncoder

public abstract class AbstractRenderer extends Object implements VmValueVisitor
  • Field Details

    • name

      protected final String name
      The name of this renderer.
    • converter

      protected final PklConverter converter
    • currPath

      protected Deque<Object> currPath
    • enclosingValue

      @Nullable protected @Nullable VmValue enclosingValue
      The value directly enclosing the currently visited value, if any.
    • currSourceSection

      @Nullable protected @Nullable com.oracle.truffle.api.source.SourceSection currSourceSection
      The (closest) SourceSection of the value being visited, for better error messages.
  • Constructor Details

    • AbstractRenderer

      protected AbstractRenderer(String name, PklConverter converter, boolean skipNullProperties, boolean skipNullEntries)
  • Method Details

    • isRenderDirective

      protected boolean isRenderDirective(VmValue value)
    • isRenderDirective

      protected boolean isRenderDirective(Object value)
    • renderDocument

      public final void renderDocument(Object value)
    • renderValue

      public final void renderValue(Object value)
    • visit

      public void visit(Object value)
      Specified by:
      visit in interface VmValueVisitor
    • visitDocument

      protected abstract void visitDocument(Object value)
    • visitTopLevelValue

      protected abstract void visitTopLevelValue(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, Object value, boolean isFirst)
      Visits an element of a VmDynamic, VmListing, VmList, or VmSet.
    • visitEntryKey

      protected abstract void visitEntryKey(Object key, boolean isFirst)
      Visits an entry key of a VmDynamic, VmMapping, or VmMap.
    • visitEntryValue

      protected abstract void visitEntryValue(Object value)
      Visits an entry value of a VmDynamic, VmMapping, or VmMap.
    • visitProperty

      protected abstract void visitProperty(Identifier name, Object value, boolean isFirst)
      Visits a property of a VmDynamic or VmTyped.
    • 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:
      visitTyped in interface VmValueVisitor
    • visitDynamic

      public final void visitDynamic(VmDynamic value)
      Specified by:
      visitDynamic in interface VmValueVisitor
    • canRenderPropertyOrEntryOf

      protected boolean canRenderPropertyOrEntryOf(VmDynamic object)
    • visitListing

      public final void visitListing(VmListing value)
      Specified by:
      visitListing in interface VmValueVisitor
    • visitMapping

      public final void visitMapping(VmMapping value)
      Specified by:
      visitMapping in interface VmValueVisitor
    • visitList

      public final void visitList(VmList value)
      Specified by:
      visitList in interface VmValueVisitor
    • visitSet

      public final void visitSet(VmSet value)
      Specified by:
      visitSet in interface VmValueVisitor
    • visitMap

      public final void visitMap(VmMap value)
      Specified by:
      visitMap in interface VmValueVisitor
    • visitEntryKeyValue

      protected void visitEntryKeyValue(Object key, boolean isFirst, Deque<Object> valuePath, Object value)
    • cannotRenderTypeAddConverter

      protected void cannotRenderTypeAddConverter(VmValue value)
    • visitTypeAlias

      public void visitTypeAlias(VmTypeAlias value)
      Specified by:
      visitTypeAlias in interface VmValueVisitor
    • visitClass

      public void visitClass(VmClass value)
      Specified by:
      visitClass in interface VmValueVisitor
    • visitFunction

      public void visitFunction(VmFunction value)
      Specified by:
      visitFunction in interface VmValueVisitor
    • cannotRenderNonStringKey

      protected void cannotRenderNonStringKey(Object key)
    • cannotRenderNonScalarKey

      protected void cannotRenderNonScalarKey(Object key)