Interface Mustache

  • All Superinterfaces:
    Code
    All Known Implementing Classes:
    DefaultMustache

    public interface Mustache
    extends Code
    The interface to Mustache objects
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void append​(java.lang.String text)
      Append text to the mustache output.
      java.lang.Object clone()
      Deep clone of the mustache object.
      default java.io.Writer execute​(java.io.Writer writer, java.lang.Object scope)
      Execute the mustache object with a given writer and a single scope context.
      default java.io.Writer execute​(java.io.Writer writer, java.lang.Object[] scopes)  
      java.io.Writer execute​(java.io.Writer writer, java.util.List<java.lang.Object> scopes)
      Execute the mustache with a given writer and an array of scope objects.
      Code[] getCodes()
      Get the underlying code objects.
      void identity​(java.io.Writer writer)
      Execute the mustache to output itself.
      void init()
      Initialize the mustache before executing.
      Node invert​(java.lang.String text)
      Invert this mustache given output text.
      java.io.Writer run​(java.io.Writer writer, java.util.List<java.lang.Object> scopes)
      Only executes the codes.
      void setCodes​(Code[] codes)
      Change the underlying codes of the mustache implementation.
    • Method Detail

      • append

        void append​(java.lang.String text)
        Append text to the mustache output.
        Specified by:
        append in interface Code
        Parameters:
        text - the text to append
      • clone

        java.lang.Object clone()
        Deep clone of the mustache object.
        Specified by:
        clone in interface Code
        Returns:
        the clone
      • execute

        default java.io.Writer execute​(java.io.Writer writer,
                                       java.lang.Object scope)
        Execute the mustache object with a given writer and a single scope context.
        Parameters:
        writer - write the output of the executed template here
        scope - the root object to use
        Returns:
        the new writer
      • execute

        default java.io.Writer execute​(java.io.Writer writer,
                                       java.lang.Object[] scopes)
      • execute

        java.io.Writer execute​(java.io.Writer writer,
                               java.util.List<java.lang.Object> scopes)
        Execute the mustache with a given writer and an array of scope objects. The scopes are searched right-to-left for references.
        Specified by:
        execute in interface Code
        Parameters:
        writer - write the output of the executed template here
        scopes - an ordered list of scopes for variable resolution
        Returns:
        the new writer
      • getCodes

        Code[] getCodes()
        Get the underlying code objects.
        Specified by:
        getCodes in interface Code
        Returns:
        the array of child codes
      • identity

        void identity​(java.io.Writer writer)
        Execute the mustache to output itself.
        Specified by:
        identity in interface Code
        Parameters:
        writer - write the output of the executed template here
      • init

        void init()
        Initialize the mustache before executing. This is must be called at least once and is normally called already by the time you have a mustache instance.
        Specified by:
        init in interface Code
      • setCodes

        void setCodes​(Code[] codes)
        Change the underlying codes of the mustache implementation.
        Specified by:
        setCodes in interface Code
        Parameters:
        codes - set the children of this code
      • run

        java.io.Writer run​(java.io.Writer writer,
                           java.util.List<java.lang.Object> scopes)
        Only executes the codes. Does not append the text.
        Parameters:
        writer - write the output of the executed template here
        scopes - the array of scopes to execute
        Returns:
        the replacement writer
      • invert

        Node invert​(java.lang.String text)
        Invert this mustache given output text.
        Parameters:
        text - the text to parse
        Returns:
        a tree of nodes representing the variables that when passed as a scope would reproduce the text