Class HamletImpl
java.lang.Object
org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec
org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl
- Direct Known Subclasses:
Hamlet
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassHamletImpl.EImp<T extends HamletSpec.__>The base class for elementsstatic enumElement options.classHamletImpl.Generic<T extends HamletSpec.__>Nested classes/interfaces inherited from class org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec
HamletSpec.__, HamletSpec._Anchor, HamletSpec._Block, HamletSpec._Body, HamletSpec._Cell, HamletSpec._Child, HamletSpec._Content, HamletSpec._Dl, HamletSpec._FieldSet, HamletSpec._FontSize, HamletSpec._FontStyle, HamletSpec._Form, HamletSpec._FormCtrl, HamletSpec._Head, HamletSpec._Html, HamletSpec._ImgObject, HamletSpec._InsDel, HamletSpec._Label, HamletSpec._Legend, HamletSpec._Li, HamletSpec._Object, HamletSpec._Option, HamletSpec._Param, HamletSpec._RawContent, HamletSpec._Script, HamletSpec._Special, HamletSpec._SubSup, HamletSpec._Table, HamletSpec._TableCol, HamletSpec._TableRow, HamletSpec._Tr, HamletSpec.A, HamletSpec.ABBR, HamletSpec.ACRONYM, HamletSpec.ADDRESS, HamletSpec.AREA, HamletSpec.Attrs, HamletSpec.B, HamletSpec.BASE, HamletSpec.BDO, HamletSpec.Block, HamletSpec.BLOCKQUOTE, HamletSpec.BODY, HamletSpec.BR, HamletSpec.BUTTON, HamletSpec.ButtonType, HamletSpec.CAPTION, HamletSpec.CITE, HamletSpec.CODE, HamletSpec.COL, HamletSpec.COLGROUP, HamletSpec.CoreAttrs, HamletSpec.DD, HamletSpec.DEL, HamletSpec.DFN, HamletSpec.Dir, HamletSpec.DIV, HamletSpec.DL, HamletSpec.DT, HamletSpec.Element, HamletSpec.EM, HamletSpec.EventsAttrs, HamletSpec.FIELDSET, HamletSpec.Flow, HamletSpec.FontStyle, HamletSpec.FORM, HamletSpec.FormCtrl, HamletSpec.H1, HamletSpec.H2, HamletSpec.H3, HamletSpec.H4, HamletSpec.H5, HamletSpec.H6, HamletSpec.HEAD, HamletSpec.Heading, HamletSpec.HeadMisc, HamletSpec.HR, HamletSpec.HTML, HamletSpec.I, HamletSpec.I18nAttrs, HamletSpec.IMG, HamletSpec.Inline, HamletSpec.INPUT, HamletSpec.InputType, HamletSpec.INS, HamletSpec.KBD, HamletSpec.LABEL, HamletSpec.LEGEND, HamletSpec.LI, HamletSpec.LINK, HamletSpec.LinkType, HamletSpec.Listing, HamletSpec.MAP, HamletSpec.Media, HamletSpec.META, HamletSpec.Method, HamletSpec.OBJECT, HamletSpec.OL, HamletSpec.OPTGROUP, HamletSpec.OPTION, HamletSpec.P, HamletSpec.PARAM, HamletSpec.PCData, HamletSpec.Phrase, HamletSpec.PRE, HamletSpec.Preformatted, HamletSpec.Q, HamletSpec.SAMP, HamletSpec.Scope, HamletSpec.SCRIPT, HamletSpec.SELECT, HamletSpec.Shape, HamletSpec.SMALL, HamletSpec.SPAN, HamletSpec.Special, HamletSpec.STRONG, HamletSpec.STYLE, HamletSpec.SUB, HamletSpec.SUP, HamletSpec.TABLE, HamletSpec.TBODY, HamletSpec.TD, HamletSpec.TEXTAREA, HamletSpec.TFOOT, HamletSpec.TH, HamletSpec.THEAD, HamletSpec.TITLE, HamletSpec.TR, HamletSpec.UL, HamletSpec.VAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidindent(EnumSet<HamletImpl.EOpt> opts) intstatic String[]parseSelector(String selector) Parse selector into id and classesprotected voidprotected voidprintEndTag(String name, EnumSet<HamletImpl.EOpt> opts) protected voidprintStartTag(String name, EnumSet<HamletImpl.EOpt> opts) <T extends HamletSpec.__>
HamletImpl.Generic<T><T extends HamletSpec.__>
HamletImpl.Generic<T>root(String name, EnumSet<HamletImpl.EOpt> opts) Create a root-level generic element.static <E extends HamletSpec.LINK>
EsetLinkHref(E e, String href) static <E extends HamletSpec.SCRIPT>
EsetScriptSrc(E e, String src) static <E extends HamletSpec.CoreAttrs>
EsetSelector(E e, String selector) Set id and/or class attributes for an element.voidsetWasInline(boolean state) protected voidSub-classes should override this to do something interesting.boolean
-
Constructor Details
-
HamletImpl
-
-
Method Details
-
nestLevel
public int nestLevel() -
wasInline
public boolean wasInline() -
setWasInline
public void setWasInline(boolean state) -
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 elementopts-element options- Returns:
- the element
-
root
-
printStartTag
-
indent
-
printEndTag
-
printAttr
-
subView
Sub-classes should override this to do something interesting.- Parameters:
cls- the sub-view class
-
parseSelector
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
Set id and/or class attributes for an element.- Type Parameters:
E- type of the element- Parameters:
e- the elementselector- Haml form of "(#id)?(.class)*"- Returns:
- the element
-
setLinkHref
-
setScriptSrc
-