Class HamletImpl

java.lang.Object
org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec
org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl
Direct Known Subclasses:
Hamlet

@Private public class HamletImpl extends HamletSpec
A simple unbuffered generic hamlet implementation. Zero copy but allocation on every element, which could be optimized to use a thread-local element pool. Prints HTML as it builds. So the order is important.
  • Constructor Details

    • HamletImpl

      public HamletImpl(PrintWriter out, int nestLevel, boolean wasInline)
  • Method Details

    • nestLevel

      public int nestLevel()
    • wasInline

      public boolean wasInline()
    • setWasInline

      public void setWasInline(boolean state)
    • getWriter

      public PrintWriter getWriter()
    • root

      public <T extends HamletSpec.__> HamletImpl.Generic<T> root(String name, EnumSet<HamletImpl.EOpt> opts)
      Create a root-level generic element. Mostly for testing purpose.
      Type Parameters:
      T - type of the parent element
      Parameters:
      name - of the element
      opts - element options
      Returns:
      the element
    • root

      public <T extends HamletSpec.__> HamletImpl.Generic<T> root(String name)
    • printStartTag

      protected void printStartTag(String name, EnumSet<HamletImpl.EOpt> opts)
    • indent

      protected void indent(EnumSet<HamletImpl.EOpt> opts)
    • printEndTag

      protected void printEndTag(String name, EnumSet<HamletImpl.EOpt> opts)
    • printAttr

      protected void printAttr(String name, String value)
    • subView

      protected void subView(Class<? extends SubView> cls)
      Sub-classes should override this to do something interesting.
      Parameters:
      cls - the sub-view class
    • parseSelector

      public static String[] parseSelector(String selector)
      Parse selector into id and classes
      Parameters:
      selector - in the form of (#id)?(.class)*
      Returns:
      an two element array [id, "space-separated classes"]. Either element could be null.
      Throws:
      WebAppException - when both are null or syntax error.
    • setSelector

      public static <E extends HamletSpec.CoreAttrs> E setSelector(E e, String selector)
      Set id and/or class attributes for an element.
      Type Parameters:
      E - type of the element
      Parameters:
      e - the element
      selector - Haml form of "(#id)?(.class)*"
      Returns:
      the element
    • setLinkHref

      public static <E extends HamletSpec.LINK> E setLinkHref(E e, String href)
    • setScriptSrc

      public static <E extends HamletSpec.SCRIPT> E setScriptSrc(E e, String src)