Package htmlflow

Class HtmlVisitorCache

  • Direct Known Subclasses:
    HtmlVisitorPrintStream, HtmlVisitorStringBuilder

    public abstract class HtmlVisitorCache
    extends org.xmlet.htmlapifaster.ElementVisitor
    This is the base implementation of the ElementVisitor (from HtmlApiFaster library) which collects information about visited Html elements of a HtmlView. The HTML static content is collected into an internal cached cacheBlocksList. Static content is interleaved with dynamic content.
    Author:
    Miguel Gamboa, Luís Duare created on 17-01-2018
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void addAttribute​(String attributeName, String attributeValue)
      Writes "attributeName=attributeValue"
      protected abstract void addComment​(String s)
      Writes "<!--s-->"
      protected abstract void beginTag​(String elementName)
      Write "<elementName".
      protected abstract HtmlVisitorCache clone​(boolean isIndented)
      Since HtmlVisitorCache is immutable this is the preferred way to create a copy of the existing HtmlVisitorCache instance with a different isIndented state.
      protected abstract void endTag​(String elementName)
      Writes "</elementName>".
      boolean isWriting()
      This visitor may be writing to output or not, depending on the kind of HTML block that it is being visited.
      protected abstract HtmlVisitorCache newbie()
      Creates a new similar instance with all static bocks cleared.
      protected abstract String readAndReset()
      Returns the accumulated output and clear it.
      protected abstract int size()
      The number of characters written until this moment.
      protected abstract String substring​(int staticBlockIndex)
      Returns a substring with the HTML content from the index staticBlockIndex
      void visitAttribute​(String attributeName, String attributeValue)  
      void visitCloseDynamic()  
      <R> void visitComment​(org.xmlet.htmlapifaster.Text<? extends org.xmlet.htmlapifaster.Element,​R> text)  
      void visitElement​(org.xmlet.htmlapifaster.Element element)
      While the static blocks are not in cache then it appends elements to the main StringBuilder or PrintStream.
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitElementRoot​(org.xmlet.htmlapifaster.Root<Z> var1)  
      void visitOpenDynamic()
      Copies from or to cacheBlocksList depending on whether the content is in cache or not.
      void visitParent​(org.xmlet.htmlapifaster.Element element)
      Writes the end tag for elementName: "</elementName>.".
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentArea​(org.xmlet.htmlapifaster.Area<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentBase​(org.xmlet.htmlapifaster.Base<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentBr​(org.xmlet.htmlapifaster.Br<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentCol​(org.xmlet.htmlapifaster.Col<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentEmbed​(org.xmlet.htmlapifaster.Embed<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentHr​(org.xmlet.htmlapifaster.Hr<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentImg​(org.xmlet.htmlapifaster.Img<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentInput​(org.xmlet.htmlapifaster.Input<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentLink​(org.xmlet.htmlapifaster.Link<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentMeta​(org.xmlet.htmlapifaster.Meta<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentParam​(org.xmlet.htmlapifaster.Param<Z> element)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentRoot​(org.xmlet.htmlapifaster.Root<Z> var1)  
      <Z extends org.xmlet.htmlapifaster.Element>
      void
      visitParentSource​(org.xmlet.htmlapifaster.Source<Z> element)  
      <R> void visitText​(org.xmlet.htmlapifaster.Text<? extends org.xmlet.htmlapifaster.Element,​R> text)  
      protected abstract void write​(char c)
      Writes the char c directly to the output.
      protected abstract void write​(String text)
      Writes the string text directly to the output.
      • Methods inherited from class org.xmlet.htmlapifaster.ElementVisitor

        visitAttributeAbbr, visitAttributeAccept, visitAttributeAcceptCharset, visitAttributeAccesskey, visitAttributeAction, visitAttributeAllowfullscreen, visitAttributeAllowpaymentrequest, visitAttributeAlt, visitAttributeAltimg, visitAttributeAltimgHeigth, visitAttributeAltimgValign, visitAttributeAltimgWidth, visitAttributeAlttext, visitAttributeAsync, visitAttributeAutocomplete, visitAttributeAutoComplete, visitAttributeAutofocus, visitAttributeAutoplay, visitAttributeBorder, visitAttributeCdgroup, visitAttributeCell, visitAttributeCharset, visitAttributeChecked, visitAttributeCite, visitAttributeClass, visitAttributeCols, visitAttributeColspan, visitAttributeColumnheader, visitAttributeContent, visitAttributeContenteditable, visitAttributeControls, visitAttributeCoords, visitAttributeCrossorigin, visitAttributeData, visitAttributeDatetime, visitAttributeDefault, visitAttributeDefer, visitAttributeDir, visitAttributeDirname, visitAttributeDirName, visitAttributeDisabled, visitAttributeDisplay, visitAttributeDownload, visitAttributeDraggable, visitAttributeEnctype, visitAttributeFor, visitAttributeForm, visitAttributeFormaction, visitAttributeFormenctype, visitAttributeFormmethod, visitAttributeFormnovalidate, visitAttributeFormtarget, visitAttributeHeaders, visitAttributeHeight, visitAttributeHidden, visitAttributeHigh, visitAttributeHref, visitAttributeHreflang, visitAttributeHttpEquiv, visitAttributeId, visitAttributeIsmap, visitAttributeKind, visitAttributeLabel, visitAttributeLang, visitAttributeList, visitAttributeLongdesc, visitAttributeLoop, visitAttributeLow, visitAttributeManifest, visitAttributeMax, visitAttributeMaxlength, visitAttributeMaxwidth, visitAttributeMedia, visitAttributeMethod, visitAttributeMin, visitAttributeMinlength, visitAttributeMultiple, visitAttributeMuted, visitAttributeName, visitAttributeNonce, visitAttributeNovalidate, visitAttributeOnabort, visitAttributeOnafterprint, visitAttributeOnauxclick, visitAttributeOnbeforeprint, visitAttributeOnbeforeunload, visitAttributeOnblur, visitAttributeOncancel, visitAttributeOncanplay, visitAttributeOncanplaythrough, visitAttributeOnchange, visitAttributeOnclick, visitAttributeOnclose, visitAttributeOncuechange, visitAttributeOndblclick, visitAttributeOndrag, visitAttributeOndragend, visitAttributeOndragenter, visitAttributeOndragexit, visitAttributeOndragleave, visitAttributeOndragover, visitAttributeOndragstart, visitAttributeOndrop, visitAttributeOndurationchange, visitAttributeOnemptied, visitAttributeOnended, visitAttributeOnerror, visitAttributeOnfocus, visitAttributeOnhashchange, visitAttributeOninput, visitAttributeOninvalid, visitAttributeOnkeydown, visitAttributeOnkeypress, visitAttributeOnkeyup, visitAttributeOnlanguagechange, visitAttributeOnload, visitAttributeOnloadeddata, visitAttributeOnloadedmetadata, visitAttributeOnloadend, visitAttributeOnloadstart, visitAttributeOnmessage, visitAttributeOnmousedown, visitAttributeOnmouseenter, visitAttributeOnmouseleave, visitAttributeOnmousemove, visitAttributeOnmouseout, visitAttributeOnmouseover, visitAttributeOnmouseup, visitAttributeOnoffline, visitAttributeOnonline, visitAttributeOnpagehide, visitAttributeOnpageshow, visitAttributeOnpause, visitAttributeOnplay, visitAttributeOnplaying, visitAttributeOnpopstate, visitAttributeOnprogress, visitAttributeOnratechange, visitAttributeOnrejectionhandled, visitAttributeOnreset, visitAttributeOnresize, visitAttributeOnscroll, visitAttributeOnseeked, visitAttributeOnseeking, visitAttributeOnselect, visitAttributeOnshow, visitAttributeOnstalled, visitAttributeOnstorage, visitAttributeOnsubmit, visitAttributeOnsuspend, visitAttributeOntimeupdate, visitAttributeOntoogle, visitAttributeOnunhandledrejection, visitAttributeOnunload, visitAttributeOnvolumenchange, visitAttributeOnwaiting, visitAttributeOnwheel, visitAttributeOpen, visitAttributeOptimum, visitAttributeOverflow, visitAttributePattern, visitAttributePlaceholder, visitAttributePoster, visitAttributePreload, visitAttributeReadonly, visitAttributeReferrerpolicy, visitAttributeRel, visitAttributeRequired, visitAttributeRev, visitAttributeReversed, visitAttributeRow, visitAttributeRowgroup, visitAttributeRowheader, visitAttributeRows, visitAttributeRowspan, visitAttributeSandbox, visitAttributeScope, visitAttributeSelected, visitAttributeShape, visitAttributeSize, visitAttributeSizes, visitAttributeSpan, visitAttributeSpellcheck, visitAttributeSrc, visitAttributeSrcDoc, visitAttributeSrclang, visitAttributeSrcset, visitAttributeSrcSet, visitAttributeStart, visitAttributeStep, visitAttributeStyle, visitAttributeTabIndex, visitAttributeTarget, visitAttributeTitle, visitAttributeTranslate, visitAttributeType, visitAttributeTypemustmatch, visitAttributeUsemap, visitAttributeValue, visitAttributeWidth, visitAttributeWrap, visitAttributeX, visitAttributeY, visitCloseAsync, visitElementA, visitElementAbbr, visitElementAddress, visitElementArea, visitElementArticle, visitElementAside, visitElementAudio, visitElementB, visitElementBase, visitElementBdi, visitElementBdo, visitElementBlockquote, visitElementBody, visitElementBr, visitElementButton, visitElementCanvas, visitElementCaption, visitElementCite, visitElementCode, visitElementCol, visitElementColgroup, visitElementData, visitElementDatalist, visitElementDd, visitElementDel, visitElementDetails, visitElementDetailsComplete, visitElementDetailsSummary, visitElementDfn, visitElementDialog, visitElementDiv, visitElementDl, visitElementDt, visitElementEm, visitElementEmbed, visitElementFieldset, visitElementFigcaption, visitElementFigure, visitElementFooter, visitElementForm, visitElementH1, visitElementH2, visitElementH3, visitElementH4, visitElementH5, visitElementH6, visitElementHead, visitElementHeader, visitElementHr, visitElementHtml, visitElementI, visitElementIframe, visitElementImg, visitElementInput, visitElementIns, visitElementKbd, visitElementLabel, visitElementLegend, visitElementLi, visitElementLink, visitElementMain, visitElementMap, visitElementMark, visitElementMath, visitElementMeta, visitElementMeter, visitElementNav, visitElementNoscript, visitElementObject, visitElementOl, visitElementOptgroup, visitElementOption, visitElementOutput, visitElementP, visitElementParam, visitElementPicture, visitElementPre, visitElementProgress, visitElementQ, visitElementRb, visitElementRp, visitElementRt, visitElementRtc, visitElementRuby, visitElementS, visitElementSamp, visitElementScript, visitElementSection, visitElementSelect, visitElementSmall, visitElementSource, visitElementSpan, visitElementStrong, visitElementStyle, visitElementSub, visitElementSummary, visitElementSup, visitElementSvg, visitElementTable, visitElementTbody, visitElementTd, visitElementTemplate, visitElementTextarea, visitElementTfoot, visitElementTh, visitElementThead, visitElementTime, visitElementTitle, visitElementTr, visitElementTrack, visitElementU, visitElementUl, visitElementVar, visitElementVideo, visitElementWbr, visitOpenAsync, visitParentA, visitParentAbbr, visitParentAddress, visitParentArticle, visitParentAside, visitParentAudio, visitParentB, visitParentBdi, visitParentBdo, visitParentBlockquote, visitParentBody, visitParentButton, visitParentCanvas, visitParentCaption, visitParentCite, visitParentCode, visitParentColgroup, visitParentData, visitParentDatalist, visitParentDd, visitParentDel, visitParentDetails, visitParentDetailsComplete, visitParentDetailsSummary, visitParentDfn, visitParentDialog, visitParentDiv, visitParentDl, visitParentDt, visitParentEm, visitParentFieldset, visitParentFigcaption, visitParentFigure, visitParentFooter, visitParentForm, visitParentH1, visitParentH2, visitParentH3, visitParentH4, visitParentH5, visitParentH6, visitParentHead, visitParentHeader, visitParentHtml, visitParentI, visitParentIframe, visitParentIns, visitParentKbd, visitParentLabel, visitParentLegend, visitParentLi, visitParentMain, visitParentMap, visitParentMark, visitParentMath, visitParentMeter, visitParentNav, visitParentNoscript, visitParentObject, visitParentOl, visitParentOptgroup, visitParentOption, visitParentOutput, visitParentP, visitParentPicture, visitParentPre, visitParentProgress, visitParentQ, visitParentRb, visitParentRp, visitParentRt, visitParentRtc, visitParentRuby, visitParentS, visitParentSamp, visitParentScript, visitParentSection, visitParentSelect, visitParentSmall, visitParentSpan, visitParentStrong, visitParentStyle, visitParentSub, visitParentSummary, visitParentSup, visitParentSvg, visitParentTable, visitParentTbody, visitParentTd, visitParentTemplate, visitParentTextarea, visitParentTfoot, visitParentTh, visitParentThead, visitParentTime, visitParentTitle, visitParentTr, visitParentTrack, visitParentU, visitParentUl, visitParentVar, visitParentVideo, visitParentWbr
    • Method Detail

      • newbie

        protected abstract HtmlVisitorCache newbie()
        Creates a new similar instance with all static bocks cleared.
      • isWriting

        public final boolean isWriting()
        This visitor may be writing to output or not, depending on the kind of HTML block that it is being visited. So, it should just write to output immediately only when it is: 1. in a static block that is not already in cache, or 2 in a dynamic block that is never cached and thus must be always freshly written to the output.
      • visitElement

        public final void visitElement​(org.xmlet.htmlapifaster.Element element)
        While the static blocks are not in cache then it appends elements to the main StringBuilder or PrintStream. Once already cached then it does nothing. This method appends the String "<elementName" and it leaves the element open to include additional attributes. Before that it may close the parent begin tag with ">" if it is still opened (!isClosed). The newlineAndIndent() is responsible for this job to check whether the parent element is still opened or not.
        Specified by:
        visitElement in class org.xmlet.htmlapifaster.ElementVisitor
        Parameters:
        element -
      • visitParent

        public final void visitParent​(org.xmlet.htmlapifaster.Element element)
        Writes the end tag for elementName: "</elementName>.". This visit occurs when the º() is invoked.
        Specified by:
        visitParent in class org.xmlet.htmlapifaster.ElementVisitor
      • visitAttribute

        public final void visitAttribute​(String attributeName,
                                         String attributeValue)
        Specified by:
        visitAttribute in class org.xmlet.htmlapifaster.ElementVisitor
      • visitText

        public final <R> void visitText​(org.xmlet.htmlapifaster.Text<? extends org.xmlet.htmlapifaster.Element,​R> text)
        Specified by:
        visitText in class org.xmlet.htmlapifaster.ElementVisitor
      • visitComment

        public final <R> void visitComment​(org.xmlet.htmlapifaster.Text<? extends org.xmlet.htmlapifaster.Element,​R> text)
        Specified by:
        visitComment in class org.xmlet.htmlapifaster.ElementVisitor
      • visitOpenDynamic

        public final void visitOpenDynamic()
        Copies from or to cacheBlocksList depending on whether the content is in cache or not. Copying from cacheBlocksList will write through write() method. Copying to cacheBlocksList will read from substring().
        Overrides:
        visitOpenDynamic in class org.xmlet.htmlapifaster.ElementVisitor
      • visitCloseDynamic

        public final void visitCloseDynamic()
        Overrides:
        visitCloseDynamic in class org.xmlet.htmlapifaster.ElementVisitor
      • beginTag

        protected abstract void beginTag​(String elementName)
        Write "<elementName".
      • endTag

        protected abstract void endTag​(String elementName)
        Writes "</elementName>".
      • addAttribute

        protected abstract void addAttribute​(String attributeName,
                                             String attributeValue)
        Writes "attributeName=attributeValue"
      • addComment

        protected abstract void addComment​(String s)
        Writes "<!--s-->"
      • write

        protected abstract void write​(String text)
        Writes the string text directly to the output.
      • write

        protected abstract void write​(char c)
        Writes the char c directly to the output.
      • substring

        protected abstract String substring​(int staticBlockIndex)
        Returns a substring with the HTML content from the index staticBlockIndex
      • size

        protected abstract int size()
        The number of characters written until this moment.
      • readAndReset

        protected abstract String readAndReset()
        Returns the accumulated output and clear it.
      • clone

        protected abstract HtmlVisitorCache clone​(boolean isIndented)
        Since HtmlVisitorCache is immutable this is the preferred way to create a copy of the existing HtmlVisitorCache instance with a different isIndented state.
        Parameters:
        isIndented - If thenew visitor should indent HTML output or not.
      • visitElementRoot

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitElementRoot​(org.xmlet.htmlapifaster.Root<Z> var1)
        Overrides:
        visitElementRoot in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentRoot

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentRoot​(org.xmlet.htmlapifaster.Root<Z> var1)
        Overrides:
        visitParentRoot in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentHr

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentHr​(org.xmlet.htmlapifaster.Hr<Z> element)
        Overrides:
        visitParentHr in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentEmbed

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentEmbed​(org.xmlet.htmlapifaster.Embed<Z> element)
        Overrides:
        visitParentEmbed in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentInput

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentInput​(org.xmlet.htmlapifaster.Input<Z> element)
        Overrides:
        visitParentInput in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentMeta

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentMeta​(org.xmlet.htmlapifaster.Meta<Z> element)
        Overrides:
        visitParentMeta in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentBr

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentBr​(org.xmlet.htmlapifaster.Br<Z> element)
        Overrides:
        visitParentBr in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentCol

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentCol​(org.xmlet.htmlapifaster.Col<Z> element)
        Overrides:
        visitParentCol in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentSource

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentSource​(org.xmlet.htmlapifaster.Source<Z> element)
        Overrides:
        visitParentSource in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentImg

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentImg​(org.xmlet.htmlapifaster.Img<Z> element)
        Overrides:
        visitParentImg in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentArea

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentArea​(org.xmlet.htmlapifaster.Area<Z> element)
        Overrides:
        visitParentArea in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentLink

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentLink​(org.xmlet.htmlapifaster.Link<Z> element)
        Overrides:
        visitParentLink in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentParam

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentParam​(org.xmlet.htmlapifaster.Param<Z> element)
        Overrides:
        visitParentParam in class org.xmlet.htmlapifaster.ElementVisitor
      • visitParentBase

        public final <Z extends org.xmlet.htmlapifaster.Element> void visitParentBase​(org.xmlet.htmlapifaster.Base<Z> element)
        Overrides:
        visitParentBase in class org.xmlet.htmlapifaster.ElementVisitor