Class AbstractHtml

All Implemented Interfaces:
TagBase, Serializable, Cloneable
Direct Known Subclasses:
A, Abbr, Address, Area, Article, Aside, Audio, B, Base, BaseFont, Bdi, Bdo, BlockQuote, Body, Br, Button, Canvas, Caption, Circle, Cite, Code, Col, ColGroup, CustomTag, Data, DataList, Dd, Del, Details, Dfn, Dialog, Div, Dl, DocType, Dt, Ellipse, Em, Embed, FieldSet, FigCaption, Figure, Footer, Form, H1, H2, H3, H4, H5, H6, Head, Header, HGroup, Hr, I, IFrame, Img, Input, Ins, Kbd, KeyGen, Label, Legend, Li, Line, Link, Main, MapTag, Mark, MathTag, Menu, MenuItem, Meta, Meter, Nav, NoScript, NoTag, ObjectTag, Ol, OptGroup, Option, Output, P, Param, Path, Picture, Polygon, Polyline, Pre, Progress, Q, Qfn, Rect, Rp, Rt, Ruby, S, Samp, Script, Section, Select, Small, Source, Span, Strong, StyleTag, Sub, Summary, Sup, Svg, Table, TBody, Td, Template, Text, TextArea, TFoot, Th, THead, Time, TitleTag, Tr, Track, U, Ul, Var, Video, Wbr

public abstract class AbstractHtml extends AbstractJsObject
Since:
1.0.0
See Also:
  • Field Details

    • noTagContentTypeHtml

      protected final boolean noTagContentTypeHtml
  • Constructor Details

    • AbstractHtml

      public AbstractHtml(AbstractHtml base, Collection<? extends AbstractHtml> children)
      Parameters:
      base - the parent tag of this object
      children - the tags which will be added as a children tag of this object.
    • AbstractHtml

      public AbstractHtml(AbstractHtml base, AbstractHtml... children)
      Parameters:
      base - the parent tag of this object
      children - the tags which will be added as a children tag of this object.
      Since:
      3.0.1
    • AbstractHtml

      protected AbstractHtml(AbstractHtml base, String childContent, boolean noTagContentTypeHtml)
      Parameters:
      base -
      childContent - any text, it can also be html text.
      Since:
      3.0.2
    • AbstractHtml

      public AbstractHtml(AbstractHtml base, String childContent)
      Parameters:
      base -
      childContent - any text, it can also be html text.
    • AbstractHtml

      public AbstractHtml(String tagName, AbstractHtml base, AbstractAttribute[] attributes)
      should be invoked to generate opening and closing tag base class containing the functionalities to generate html string.
      Parameters:
      tagName - TODO
      base - TODO
    • AbstractHtml

      protected AbstractHtml(PreIndexedTagName preIndexedTagName, AbstractHtml base, AbstractAttribute[] attributes)
      should be invoked to generate opening and closing tag base class containing the functionalities to generate html string.
      Parameters:
      preIndexedTagName - PreIndexedTagName constant
      base - TODO
      Since:
      3.0.3
    • AbstractHtml

      protected AbstractHtml(AbstractHtml.TagType tagType, String tagName, AbstractHtml base, AbstractAttribute[] attributes)
      should be invoked to generate opening and closing tag base class containing the functionalities to generate html string.
      Parameters:
      tagType -
      tagName - TODO
      base - TODO
    • AbstractHtml

      protected AbstractHtml(AbstractHtml.TagType tagType, PreIndexedTagName preIndexedTagName, AbstractHtml base, AbstractAttribute[] attributes)
      should be invoked to generate opening and closing tag base class containing the functionalities to generate html string.
      Parameters:
      tagType -
      preIndexedTagName - PreIndexedTagName constant
      base - TODO
      Since:
      3.0.3
  • Method Details

    • appendChild

      public boolean appendChild(AbstractHtml child)
      Appends the given child tag to its children.
      Parameters:
      child - the tag to append to its children.
      Returns:
      true if the given child tag is appended as child of this tag.
    • removeAllChildren

      public void removeAllChildren()
      Removes all children from this tag.
    • addInnerHtml

      public void addInnerHtml(AbstractHtml innerHtml)
      removes all children and adds the given tag
      Parameters:
      innerHtml - the inner html tag to add
    • addInnerHtmls

      public void addInnerHtmls(AbstractHtml... innerHtmls)
      Removes all children and adds the given tags as children.
      Parameters:
      innerHtmls - the inner html tags to add
      Since:
      2.1.3
    • addInnerHtmls

      protected void addInnerHtmls(boolean updateClient, AbstractHtml... innerHtmls)
      Removes all children and adds the given tags as children.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      innerHtmls - the inner html tags to add
      Since:
      2.1.15
    • addInnerHtml

      public <T> void addInnerHtml(SharedTagContent<T> sharedTagContent)
      Parameters:
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      Since:
      3.0.6
    • addInnerHtml

      public <T> void addInnerHtml(SharedTagContent<T> sharedTagContent, SharedTagContent.ContentFormatter<T> formatter)
      Parameters:
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      formatter - content to be formatted using this formatter before it is embedded in this tag.
      Since:
      3.0.6
    • addInnerHtml

      public <T> void addInnerHtml(boolean updateClient, SharedTagContent<T> sharedTagContent)
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page. false will skip updating client browser page only when this method call.
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      Since:
      3.0.6
    • addInnerHtml

      public <T> void addInnerHtml(boolean updateClient, SharedTagContent<T> sharedTagContent, SharedTagContent.ContentFormatter<T> formatter)
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page. false will skip updating client browser page only when this method call.
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      formatter - content to be formatted using this formatter before it is embedded in this tag.
      Since:
      3.0.6
    • subscribeTo

      public <T> void subscribeTo(SharedTagContent<T> sharedTagContent)
      Subscribes to the given SharedTagContent and listens to its content updates but pushes updates of this tag to client browser page only if there is an active WebSocket connection between server and client browser page and if there is no active WebSocket connection that changes will not be cached for later push. However, it will try to keep the change of this tag (server object) up to date with client browser page. The difference of this method with addInnerHtml(SharedTagContent) is that addInnerHtml(SharedTagContent) will push all changes of this tag (server side object) to client browser page and if push is failed it will be cached for retry. addInnerHtml(SharedTagContent) will reliably deliver each and every change to client browser page. There are cases where it is discouraged,

      Eg:- printing current time in realtime. Imagine, while printing the time in realtime the websocket communication between the client and server is lost and reconnected after few seconds. In that case we don't have to push the out dated data (time). In such cases subscribeTo(SharedTagContent) is more appropriate.
      Parameters:
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      Since:
      3.0.6
    • subscribeTo

      public <T> void subscribeTo(SharedTagContent<T> sharedTagContent, SharedTagContent.ContentFormatter<T> formatter)
      Subscribes to the given SharedTagContent and listens to its content updates but pushes updates of this tag to client browser page only if there is an active WebSocket connection between server and client browser page and if there is no active WebSocket connection that changes will not be cached for later push. However, it will try to keep the change of this tag (server object) up to date with client browser page. The difference of this method with addInnerHtml(SharedTagContent) is that addInnerHtml(SharedTagContent) will push all changes of this tag (server side object) to client browser page and if push is failed it will be cached for retry. addInnerHtml(SharedTagContent) will reliably deliver each and every change to client browser page. There are cases where it is discouraged,

      Eg:- printing current time in realtime. Imagine, while printing the time in realtime the websocket communication between the client and server is lost and reconnected after few seconds. In that case we don't have to push the out dated data (time). In such cases subscribeTo(SharedTagContent) is more appropriate.
      Parameters:
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      formatter - content to be formatted using this formatter before it is embedded in this tag.
      Since:
      3.0.6
    • subscribeTo

      public <T> void subscribeTo(boolean updateClient, SharedTagContent<T> sharedTagContent, SharedTagContent.ContentFormatter<T> formatter)
      Subscribes to the given SharedTagContent and listens to its content updates but pushes updates of this tag to client browser page only if there is an active WebSocket connection between server and client browser page and if there is no active WebSocket connection that changes will not be cached for later push. However, it will try to keep the change of this tag (server object) up to date with client browser page. The difference of this method with addInnerHtml(SharedTagContent) is that addInnerHtml(SharedTagContent) will push all changes of this tag (server side object) to client browser page and if push is failed it will be cached for retry. addInnerHtml(SharedTagContent) will reliably deliver each and every change to client browser page. There are cases where it is discouraged,

      Eg:- printing current time in realtime. Imagine, while printing the time in realtime the websocket communication between the client and server is lost and reconnected after few seconds. In that case we don't have to push the out dated data (time). In such cases subscribeTo(SharedTagContent) is more appropriate.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page. false will skip updating client browser page only when this method call.
      sharedTagContent - the shared content to be inserted as inner content. Any changes of content in the sharedTagContent will be reflected in this tag and all other consuming tags of this sharedTagContent object.
      formatter - content to be formatted using this formatter before it is embedded in this tag.
      Since:
      3.0.6
    • getSharedTagContent

      public <T> SharedTagContent<T> getSharedTagContent()
      Returns:
      the object of SharedTagContent which created the NoTag in the child or null if the child NoTag is not created by any SharedTagContent object.
      Since:
      3.0.6
    • isSubscribedToSharedTagContent

      public boolean isSubscribedToSharedTagContent()
      Returns:
      true if this tag is subscribed to any SharedTagContent object otherwise false.
      Since:
      3.0.6
    • removeSharedTagContent

      public boolean removeSharedTagContent(boolean removeContent)
      Parameters:
      removeContent - true to remove the inner content of this tag otherwise false. The inner content will be removed only if it contains a ShareTagContent object.
      Returns:
      true if any SharedTagContent object is removed from this tag otherwise false.
      Since:
      3.0.6
    • removeChildren

      public boolean removeChildren(Collection<AbstractHtml> children)
      Removes the given tags from its children tags.
      Parameters:
      children - the tags to remove from its children.
      Returns:
      true given given children tags have been removed.
    • removeChildren

      public boolean removeChildren(AbstractHtml... children)
      Removes the given tags from its children tags.
      Parameters:
      children - the tags to remove from its children.
      Returns:
      true given given children tags have been removed.
      Since:
      3.0.1
    • removeChild

      public boolean removeChild(AbstractHtml child)
      Removes the given tag from its children only if the given tag is a child of this tag.
      Parameters:
      child - the tag to remove from its children
      Returns:
      true if removed
    • addChild

      public final boolean addChild(Object accessObject, AbstractHtml child, boolean invokeListener)
      NB: This method is for internal use
      Parameters:
      accessObject -
      child -
      invokeListener -
      Returns:
      Since:
      2.0.0
    • appendChildren

      public void appendChildren(Collection<AbstractHtml> children)
      adds the given children to the last position of the current children of this object.
      Parameters:
      children - children to append in this object's existing children.
    • appendChildren

      public void appendChildren(AbstractHtml... children)
      adds the given children to the last position of the current children of this object.
      Parameters:
      children - children to append in this object's existing children.
      Since:
      2.1.6
    • prependChildren

      public void prependChildren(AbstractHtml... children)
      prepends the given children to the first position of the current children of this object.
      Eg:-
       Div div = new Div(null, new Id("one")) {
           {
               new Div(this, new Id("child1"));
           }
       };
      
       Span span = new Span(null);
      
       P p = new P(null);
      
       Br br = new Br(null);
      
       div.prependChildren(span, p, br);
      
       System.out.println(div.toHtmlString());
      
       

      This prints

       <div id="one">
           <span></span>
           <p></p>
           <br/>
           <div id="child1"></div>
       </div>
       
      Parameters:
      children - children to prepend in this object's existing children.
      Since:
      3.0.1
    • addAttributes

      public void addAttributes(AbstractAttribute... attributes)
      adds the given attributes to this tag.
      Parameters:
      attributes - attributes to add
      Since:
      2.0.0
    • addAttributes

      public void addAttributes(boolean updateClient, AbstractAttribute... attributes)
      adds the given attributes to this tag.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      attributes - attributes to add
      Since:
      2.0.0 initial implementation, 2.0.15 changed to public scope
    • addAttributes

      public void addAttributes(boolean updateClient, Collection<AbstractAttribute> attributes)
      adds the given attributes to this tag.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      attributes - attributes to add
      Since:
      3.0.15 initial implementation
    • getAttributes

      public Collection<AbstractAttribute> getAttributes()
      Returns:
      the collection of attributes
      Since:
      2.0.0
    • getAttributeByName

      public AbstractAttribute getAttributeByName(String attributeName)
      gets the attribute by attribute name
      Returns:
      the attribute object for the given attribute name if exists otherwise returns null.
      Since:
      2.0.0
    • removeAttributes

      public boolean removeAttributes(AbstractAttribute... attributes)
      removes the given attributes from this tag.
      Parameters:
      attributes - attributes to remove
      Returns:
      true if any of the attributes are removed.
      Since:
      2.0.0
    • removeAttributes

      public final boolean removeAttributes(Object accessObject, boolean invokeListener, AbstractAttribute... attributes)
      removes the given attributes from this tag.
      Parameters:
      invokeListener - true to invoke listener
      attributes - attributes to remove
      Returns:
      true if any of the attributes are removed.
      Since:
      2.0.0
    • removeAttributes

      public boolean removeAttributes(boolean updateClient, AbstractAttribute... attributes)
      removes the given attributes from this tag.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      attributes - attributes to remove
      Returns:
      true if any of the attributes are removed.
      Since:
      2.0.0 initial implementation, 2.0.15 changed to public scope
    • removeAttributes

      public boolean removeAttributes(String... attributeNames)
      removes the given attributes from this tag.
      Parameters:
      attributeNames - to remove the attributes having in the given names.
      Returns:
      true if any of the attributes are removed.
      Since:
      2.0.0
    • removeAttributes

      public final boolean removeAttributes(Object accessObject, boolean invokeListener, String... attributeNames)
      removes the given attributes from this tag.
      Parameters:
      invokeListener - true to invoke listener
      attributeNames - to remove the attributes having in the given names.
      Returns:
      true if any of the attributes are removed.
      Since:
      2.0.0
    • removeAttributes

      public boolean removeAttributes(boolean updateClient, String... attributeNames)
      removes the given attributes from this tag.
      Parameters:
      updateClient - true to update client browser page if it is available. The default value is true but it will be ignored if there is no client browser page.
      attributeNames - to remove the attributes having in the given names.
      Returns:
      true if any of the attributes are removed.
      Since:
      2.0.0 initial implementation, 2.0.15 changed to public scope
    • getParent

      public AbstractHtml getParent()
    • setParent

      @Deprecated public void setParent(AbstractHtml parent)
      Deprecated.
      This method is not allowed to use. It's not implemented.
      Parameters:
      parent -
      Since:
      2.0.0
    • getChildren

      public List<AbstractHtml> getChildren()
      Returns:
      the unmodifiable list of children
      Since:
      2.0.0
    • getChildren

      public final Set<AbstractHtml> getChildren(Object accessObject)
      NB: this method is for internal use. The returned object should not be modified.
      Returns:
      the internal children object.
      Since:
      2.0.0
    • setChildren

      public void setChildren(Set<AbstractHtml> children)
      Removes all current children and adds the given children under this tag. Unlike setter methods, it will not reuse the given set object but it will copy all children from the given set object.
      Parameters:
      children - which will be set as the children tag after removing all current children. Empty set or null will remove all current children from this tag.
      Since:
      2.1.12 proper implementation is available since 2.1.12
    • getChildrenAsArray

      public AbstractHtml[] getChildrenAsArray()
      Gets the children of this tag as an array. An efficient way to get the children as an array.
      Returns:
      the array of children of this tag.
      Since:
      3.0.1
    • getFirstChild

      public AbstractHtml getFirstChild()
      Gets the first child of this tag. The efficient way to get the first child.
      Returns:
      the first child of this tag or null if there is no child.
      Since:
      3.0.1
    • getLastChild

      public AbstractHtml getLastChild()
      Gets the last child of this tag. The efficient way to get the last child.
      Returns:
      the last child of this tag or null if there is no child.
      Since:
      3.0.15
    • getChildrenSize

      public int getChildrenSize()
      Gets the number of children in this tag. An efficient way to find the size of children.
      Returns:
      the size of children.
      Since:
      3.0.1
    • getChildAt

      public AbstractHtml getChildAt(int index)
      Gets the child at the specified position. An efficient way to get the child at particular position. If you want to get the child at 0th(zeroth) index then use AbstractHtml#getFirstChild() method instead of this method.
      Parameters:
      index - from this index the tag will be returned
      Returns:
      the child at the specified index.
      Since:
      3.0.1
    • getIndexByChild

      public int getIndexByChild(AbstractHtml child)
      Gets the nth index of the given tag in this tag's children.
      Parameters:
      child -
      Returns:
      the index of this child in this tag's children. If the given tag is not a child in this tag's children then -1 will be returned.
      Since:
      3.0.7
    • getIndexByChild

      public final int getIndexByChild(Object accessObject, AbstractHtml child)
      NB: only for internal use. Use getIndexByChild(AbstractHtml).

      Gets the nth index of the given tag in this tag's children.

      Parameters:
      accessObject -
      child -
      Returns:
      the index of this child in this tag's children. If the given tag is not a child in this tag's children then -1 will be returned.
      Since:
      3.0.7
    • containsChild

      public boolean containsChild(AbstractHtml childTag)
      Checks whether a tag is contained in its direct children. An efficient way to check if the given tag is a direct child of this tag.
      Parameters:
      childTag -
      Returns:
      true if the given tag is a child of this tags.
      Since:
      3.0.1
    • getOpeningTag

      public final String getOpeningTag()
      For internal purpose. Not recommended for external purpose.
      Returns:
      the opening tag of this object
    • getClosingTag

      public String getClosingTag()
      For internal purpose.
      Returns:
      the closing tag of this object
    • getPrintStructure

      protected String getPrintStructure()
      Returns:
      String equalent to the html string of the tag including the child tags.
      Since:
      1.0.0
    • getPrintStructure

      protected String getPrintStructure(boolean rebuild)
      Parameters:
      rebuild -
      Returns:
      Since:
      1.0.0
    • writePrintStructureToOutputStream

      protected int writePrintStructureToOutputStream(Charset charset, OutputStream os, boolean rebuild) throws IOException
      Parameters:
      charset -
      os -
      rebuild -
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      1.0.0
    • writePrintStructureToOutputStream

      protected int writePrintStructureToOutputStream(OutputStream os, boolean rebuild, Charset charset, boolean flushOnWrite) throws IOException
      Parameters:
      os -
      rebuild -
      charset -
      flushOnWrite - true to flush on each write to OutputStream
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      3.0.2
    • writePrintStructureToWffBinaryMessageOutputStream

      protected void writePrintStructureToWffBinaryMessageOutputStream(boolean rebuild) throws IOException
      Parameters:
      rebuild -
      Throws:
      IOException
      Since:
      2.0.0
    • toBigHtmlString

      public String toBigHtmlString()
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toHtmlString method which is faster than this method. The advantage of toBigHtmlString over toHtmlString is it will never throw StackOverflowError.
      NB:- this method has not been undergone all testing process.
      Returns:
      the HTML string similar to toHtmlString method.
      Since:
      2.1.12
    • toBigHtmlString

      public String toBigHtmlString(boolean rebuild)
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toHtmlString method which is faster than this method. The advantage of toBigHtmlString over toHtmlString is it will never throw StackOverflowError.
      NB:- this method has not been undergone all testing process.
      Parameters:
      rebuild - true to rebuild the tag hierarchy or false to return from cache if available.
      Returns:
      the HTML string similar to toHtmlString method.
      Since:
      2.1.12
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      2.1.12
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os, Charset charset) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      charset - the charset
      Returns:
      Throws:
      IOException
      Since:
      2.1.12
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os, String charset) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      charset - the charset
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      2.1.12
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os, boolean rebuild) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      2.1.12
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os, boolean rebuild, Charset charset) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      charset - the charset
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      2.1.12
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os, boolean rebuild, Charset charset, boolean flushOnWrite) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      charset - the charset
      flushOnWrite - true to flush on each write to OutputStream
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      3.0.15
    • toBigOutputStream

      public int toBigOutputStream(OutputStream os, boolean rebuild, String charset) throws IOException
      Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy use toOutputStream method which is faster than this method. The advantage of toBigOutputStream over toOutputStream is it will never throw StackOverflowError and the memory consumed at the time of writing could be available for GC (depends on JVM GC rules).
      NB:- this method has not been undergone all testing process.
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      charset - the charset
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      2.1.12
    • toHtmlString

      public String toHtmlString()
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values. rebuilds the html string if the child tags/values or attributes have been modified.
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(Charset charset)
      Deprecated.
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values using the given charset. rebuilds the html string if the child tags/values or attributes have been modified.
      Parameters:
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(String charset)
      Deprecated.
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values using the given charset. rebuilds the html string if the child tags/values or attributes have been modified.
      Parameters:
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8.name()
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      public String toHtmlString(boolean rebuild)
      Description copied from interface: TagBase
      rebuilds the html string of the tag including the child tags/values if parameter is true, otherwise returns the html string prebuilt and kept in the cache.
      Parameters:
      rebuild - true to rebuild & false to return previously built string.
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(boolean rebuild, Charset charset)
      Deprecated.
      Description copied from interface: TagBase
      rebuilds the html string of the tag including the child tags/values if parameter is true, otherwise returns the html string prebuilt and kept in the cache.
      Parameters:
      rebuild - true to rebuild & false to return previously built string.
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toHtmlString

      @Deprecated public String toHtmlString(boolean rebuild, String charset)
      Deprecated.
      Description copied from interface: TagBase
      rebuilds the html string of the tag including the child tags/values if parameter is true, otherwise returns the html string prebuilt and kept in the cache.
      Parameters:
      rebuild - true to rebuild & false to return previously built string.
      charset - the charset to set for the returning value, eg: StandardCharsets.UTF_8.name()
      Returns:
      String equalent to the html string of the tag including the child tags.
    • toOutputStream

      public int toOutputStream(OutputStream os) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      Returns:
      the total number of bytes written
      Throws:
      IOException
    • toOutputStream

      public int toOutputStream(OutputStream os, Charset charset) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      charset - the charset
      Returns:
      Throws:
      IOException
    • toOutputStream

      public int toOutputStream(OutputStream os, Charset charset, boolean flushOnWrite) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      charset - the charset
      flushOnWrite - true to flush on each write to OutputStream
      Returns:
      Throws:
      IOException
      Since:
      3.0.2
    • toOutputStream

      public int toOutputStream(OutputStream os, String charset) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      charset - the charset
      Returns:
      the total number of bytes written
      Throws:
      IOException
    • toOutputStream

      public int toOutputStream(OutputStream os, boolean rebuild) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      Returns:
      the total number of bytes written
      Throws:
      IOException
    • toOutputStream

      public int toOutputStream(OutputStream os, boolean rebuild, boolean flushOnWrite) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      flushOnWrite - true to flush on each write to OutputStream
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      3.0.2
    • toOutputStream

      public int toOutputStream(OutputStream os, boolean rebuild, Charset charset) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      charset - the charset
      Returns:
      the total number of bytes written
      Throws:
      IOException
    • toOutputStream

      public int toOutputStream(OutputStream os, boolean rebuild, Charset charset, boolean flushOnWrite) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      charset - the charset
      flushOnWrite - true to flush on each write to OutputStream
      Returns:
      the total number of bytes written
      Throws:
      IOException
      Since:
      3.0.2
    • toOutputStream

      public int toOutputStream(OutputStream os, boolean rebuild, String charset) throws IOException
      Parameters:
      os - the object of OutputStream to write to.
      rebuild - true to rebuild & false to write previously built bytes.
      charset - the charset
      Returns:
      the total number of bytes written
      Throws:
      IOException
    • toString

      public String toString()
      Description copied from interface: TagBase
      gets the html string of the tag including the child tags/values. rebuilds the html string if the child tags/values or attributes have been modified.
      Specified by:
      toString in interface TagBase
      Overrides:
      toString in class Object
      Returns:
      String equalent to the html string of the tag including the child tags.
    • getTagName

      public String getTagName()
      Eg tag names :- html, body, div table, input, button etc...
      Returns:
      the tagName set by AbstractHtml5#setTagName(String) method.
      Since:
      1.0.0
    • getAttributeHtmlBytesCompressedByIndex

      public byte[][] getAttributeHtmlBytesCompressedByIndex(boolean rebuild, Charset charset) throws IOException
      Throws:
      IOException
    • getSharedObject

      public final AbstractHtml5SharedObject getSharedObject()
      NB: it will not always return the same object as could be modified by the framework at any time.
      Specified by:
      getSharedObject in class AbstractJsObject
      Returns:
      the sharedObject
      Since:
      1.0.0
    • getHtmlMiddleSB

      protected StringBuilder getHtmlMiddleSB()
      Returns:
      the htmlMiddleSB
      Since:
      1.0.0
    • isHtmlStartSBAsFirst

      public boolean isHtmlStartSBAsFirst()
      Returns:
      the htmlStartSBAsFirst
      Since:
      1.0.0
    • deepClone

      protected AbstractHtml deepClone(AbstractHtml objectToBeClonned) throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • beforePrintStructure

      protected void beforePrintStructure()
      invokes just before getPrintStructure(final boolean method and only if the getPrintStructure(final boolean} rebuilds the structure.
      Since:
      1.0.0
    • beforeWritePrintStructureToOutputStream

      protected void beforeWritePrintStructureToOutputStream()
      invokes just before writePrintStructureToOutputStream(final OutputStream method.
      Since:
      1.0.0
    • beforeWritePrintStructureToWffBinaryMessageOutputStream

      protected void beforeWritePrintStructureToWffBinaryMessageOutputStream()
      invokes just before writePrintStructureToWffBinaryMessageOutputStream(final OutputStream method.
      Since:
      2.0.0
    • clone

      Creates and returns a deeply cloned copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:
       x.clone() != x
       
      will be true, and that the expression:
       x.clone().getClass() == x.getClass()
       
      will be true, but these are not absolute requirements. While it is typically the case that:
       x.clone().equals(x)
       
      will be true, this is not an absolute requirement.

      By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

      By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

      The method clone for class AbstractHtml performs a specific cloning operation. First, if the class of this object does not implement the interfaces Cloneable and Serializable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable and that the return type of the clone method of an array type T[] is T[] where T is any reference or primitive type. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.

      Overrides:
      clone in class Object
      Returns:
      a deep clone of this instance.
      Throws:
      CloneNotSupportedException - if the object's class does not support the Cloneable and Serializable interfaces. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
      See Also:
    • clone

      public AbstractHtml clone(String... excludeAttributes) throws CloneNotSupportedException
      Creates and returns a deeply cloned copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:
       x.clone() != x
       
      will be true, and that the expression:
       x.clone().getClass() == x.getClass()
       
      will be true, but these are not absolute requirements. While it is typically the case that:
       x.clone().equals(x)
       
      will be true, this is not an absolute requirement.

      By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

      By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

      The method clone for class AbstractHtml performs a specific cloning operation. First, if the class of this object does not implement the interfaces Cloneable and Serializable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable and that the return type of the clone method of an array type T[] is T[] where T is any reference or primitive type. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.

      Parameters:
      excludeAttributes - pass the attributes names which need to be excluded from all tags including their child tags.
      Returns:
      a deep clone of this instance without the given attributes.
      Throws:
      CloneNotSupportedException - if the object's class does not support the Cloneable and Serializable interfaces. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
      Since:
      2.0.0
      See Also:
    • getCharset

      @Deprecated public Charset getCharset()
      Deprecated.
      not recommended since 3.0.19, it will be removed in future major version.
      Returns:
      the charset
    • setCharset

      @Deprecated public void setCharset(Charset charset)
      Deprecated.
      not recommended since 3.0.19, it will be removed in future major version.
      Parameters:
      charset - the charset to set
    • toWffBMBytes

      public byte[] toWffBMBytes()
      Returns:
      the Wff Binary Message bytes of this tag. It uses default charset for encoding values.
      Since:
      2.0.0 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true
    • toWffBMBytes

      public byte[] toWffBMBytes(String charset)
      Parameters:
      charset - Eg: UTF-8
      Returns:
      the Wff Binary Message bytes of this tag
      Throws:
      InvalidTagException
      Since:
      2.0.0 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true
    • toWffBMBytes

      public byte[] toWffBMBytes(Charset charset)
      Parameters:
      charset -
      Returns:
      the Wff Binary Message bytes of this tag
      Throws:
      InvalidTagException
      Since:
      3.0.1 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true
    • toWffBMBytes

      public final byte[] toWffBMBytes(Charset charset, Object accessObject)
      Only for internal use.
      Parameters:
      charset -
      accessObject -
      Returns:
      the Wff Binary Message bytes of this tag
      Throws:
      InvalidTagException
      Since:
      3.0.1 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true, 3.0.15 accessObject added
    • toCompressedWffBMBytes

      public byte[] toCompressedWffBMBytes(Charset charset)
      Parameters:
      charset -
      Returns:
      the Wff Binary Message bytes of this tag containing indexed tag name and attribute name
      Throws:
      InvalidTagException
      Since:
      3.0.3
    • toCompressedWffBMBytesV2

      public byte[] toCompressedWffBMBytesV2(Charset charset)
      Parameters:
      charset -
      Returns:
      the Wff Binary Message bytes of this tag containing indexed tag name and attribute name
      Throws:
      InvalidTagException
      Since:
      3.0.6
    • toCompressedWffBMBytesV2

      public final byte[] toCompressedWffBMBytesV2(Charset charset, Object accessObject)
      Only for internal purpose
      Parameters:
      charset -
      accessObject -
      Returns:
      the Wff Binary Message bytes of this tag containing indexed tag name and attribute name
      Throws:
      InvalidTagException
      Since:
      3.0.6, 3.0.15 accessObject added
    • getTagFromWffBMBytes

      public static AbstractHtml getTagFromWffBMBytes(byte[] bmMessageBytes)
      Parameters:
      bmMessageBytes -
      Returns:
      the AbstractHtml instance from the given Wff BM bytes. It uses system default charset.
      Since:
      2.0.0 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true
    • getTagFromWffBMBytes

      public static AbstractHtml getTagFromWffBMBytes(byte[] bmBytes, String charset)
      Parameters:
      bmBytes - Wff Binary Message bytes of tag i.e. returned by toWffBMBytes(String)
      charset - the charset used to generate bm bytes in toWffBMBytes(String)
      Returns:
      the AbstractHtml instance from the given Wff BM bytes
      Since:
      2.0.0 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true
    • getTagFromWffBMBytes

      public static AbstractHtml getTagFromWffBMBytes(byte[] bmBytes, Charset charset)
      Parameters:
      bmBytes - Wff Binary Message bytes of tag i.e. returned by toWffBMBytes(Charset)
      charset - the charset used to generate bm bytes in toWffBMBytes(Charset)
      Returns:
      the AbstractHtml instance from the given Wff BM bytes
      Since:
      3.0.1 initial implementation, 3.0.2 improved to handle NoTag with contentTypeHtml true
    • getExactTagFromWffBMBytes

      public static AbstractHtml getExactTagFromWffBMBytes(byte[] bmBytes, Charset charset)
      Parameters:
      bmBytes - Wff Binary Message bytes of tag i.e. returned by toWffBMBytes(Charset)
      charset - the charset used to generate bm bytes in toWffBMBytes(Charset)
      Returns:
      the AbstractHtml instance from the given Wff BM bytes
      Since:
      3.0.2 Also includes the improvement to handle NoTag with contentTypeHtml true
    • getDataWffId

      public DataWffId getDataWffId()
      Returns:
      the dataWffId
    • setDataWffId

      public void setDataWffId(DataWffId dataWffId)
      adds data-wff-id for the tag if doesn't already exist. NB:- this method is ony for internal use.
      Parameters:
      dataWffId - the dataWffId to set
    • insertBefore

      public boolean insertBefore(AbstractHtml... abstractHtmls) throws NoParentException
      Inserts the given tags before this tag. There must be a parent for this method tag otherwise throws NoParentException.
      Parameters:
      abstractHtmls - to insert before this tag
      Returns:
      true if inserted otherwise false.
      Throws:
      NoParentException - if this tag has no parent
      Since:
      2.1.1
    • insertBeforeIfPossible

      public boolean insertBeforeIfPossible(AbstractHtml... abstractHtmls)
      Inserts the given tags before this tag only if this tag has parent.
      Parameters:
      abstractHtmls - to insert before this tag
      Returns:
      true if inserted otherwise false.
      Since:
      3.0.15
    • replaceWith

      public boolean replaceWith(AbstractHtml... tags) throws NoParentException
      Replaces this tag with the given tags. There must be a parent for this method tag otherwise throws NoParentException. Obviously, this tag will be removed from its parent if this method is called.
      Parameters:
      tags - tags for the replacement of this tag
      Returns:
      true if replaced otherwise false.
      Throws:
      NoParentException - if this tag has no parent
      Since:
      3.0.7
    • replaceWithIfPossible

      public boolean replaceWithIfPossible(AbstractHtml... tags)
      Replaces this tag with the given tags only if it has a parent. Obviously, this tag will be removed from its parent if this method is called.
      Parameters:
      tags - tags for the replacement of this tag
      Returns:
      true if replaced otherwise false.
      Since:
      3.0.15
    • insertAfter

      public boolean insertAfter(AbstractHtml... abstractHtmls)
      Inserts the given tags after this tag. There must be a parent for this method tag otherwise throws NoParentException.
      Note : As promised this method is improved and works as performing and reliable as insertBefore method.
      Parameters:
      abstractHtmls - to insert after this tag
      Returns:
      true if inserted otherwise false.
      Throws:
      NoParentException - if this tag has no parent
      Since:
      2.1.6, 3.0.7 better implementation
    • insertAfterIfPossible

      public boolean insertAfterIfPossible(AbstractHtml... abstractHtmls)
      Inserts the given tags after this tag only if this tag has a parent.
      Parameters:
      abstractHtmls - to insert after this tag
      Returns:
      true if inserted otherwise false.
      Since:
      3.0.15
    • loopThroughAllNestedChildren

      protected static void loopThroughAllNestedChildren(NestedChild nestedChild, boolean includeParents, AbstractHtml... parents)
      Loops through all nested children tags (excluding the given tag) of the given tag. The looping is in a random order to gain maximum performance and minimum memory footprint.
      Parameters:
      nestedChild - the object of NestedChild from which the eachChild(AbstractHtml) to be invoked.
      includeParents - true to include the given parent tags in the loop
      parents - the tags from which to loop through.
      Since:
      2.1.8
    • addWffData

      protected WffBMData addWffData(String key, WffBMData wffBMData)
      Parameters:
      key -
      wffBMData -
      Returns:
      Since:
      2.1.8
    • removeWffData

      protected WffBMData removeWffData(String key)
      Parameters:
      key -
      Returns:
      Since:
      2.1.8
    • getWffData

      protected WffBMData getWffData(String key)
      Parameters:
      key -
      Returns:
      Since:
      3.0.1
    • getWffObjects

      public Map<String,WffBMData> getWffObjects()
      Gets the unmodifiable map of wffObjects which are upserted by TagRepository.upsert(AbstractHtml, String, WffBMObject) or TagRepository.upsert(AbstractHtml, String, WffBMArray). null checking is required while consuming this map.
      Returns:
      the unmodifiable map of wffObjects. The value may either be an instance of WffBMObject or WffBMArray. This map may be null if there is no TagRepository#upsert operation has been done at least once in the whole life cycle. Otherwise it may also be empty.
      Since:
      2.1.8
    • getRootTag

      public AbstractHtml getRootTag()
      Gets the root level tag of this tag.
      Returns:
      the root parent tag or the current tag if there is no parent for the given tag
      Since:
      2.1.11
    • getSharedData

      public Object getSharedData()
      Gets the object which is accessible in all of this tag hierarchy.


      Eg:-
       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
            }};
        }};
      
        Div div = TagRepository.findOneTagAssignableToTag(Div.class, html);
        Head head = TagRepository.findOneTagAssignableToTag(Head.class, html);
      
        Object sharedData = "some object";
      
        div.setSharedData(sharedData);
      
        System.out.println(sharedData == head.getSharedData());
      
        System.out.println(div.getSharedData() == head.getSharedData());
      
        System.out.println(div.getSharedData().equals(head.getSharedData()));
      
        //prints
      
        true
        true
        true
      
       
       
      Returns:
      the sharedData object set by setSharedData method. This object is same across all of this tag hierarchy.
      Since:
      2.1.11
    • setSharedData

      public void setSharedData(Object sharedData)
      Sets the object which will be accessible by getSharedData method in all of this tag hierarchy. setData sets an object for the specific tag but setSharedData sets an object for all of the tag hierarchy.


      Eg:-
       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
            }};
        }};
      
        Div div = TagRepository.findOneTagAssignableToTag(Div.class, html);
        Head head = TagRepository.findOneTagAssignableToTag(Head.class, html);
      
        Object sharedData = "some object";
      
        div.setSharedData(sharedData);
      
        System.out.println(sharedData == head.getSharedData());
      
        System.out.println(div.getSharedData() == head.getSharedData());
      
        System.out.println(div.getSharedData().equals(head.getSharedData()));
      
        //prints
      
        true
        true
        true
      
       
       
      Parameters:
      sharedData - the object to access through all of this tag hierarchy.
      Since:
      2.1.11
    • setSharedDataIfNull

      public boolean setSharedDataIfNull(Object sharedData)
      Parameters:
      sharedData -
      Returns:
      true if set or false if it already had a value
      Since:
      3.0.1
    • resetHierarchy

      public final void resetHierarchy() throws InvalidTagException
      Resets the hierarchy of this tag so that it can be used in another instance of BrowserPage. If a tag is used under a BrowserPage instance and the same instance of tag needs to be used in another instance of BrowserPage then the tag needs to be reset before use otherwise there could be some strange behaviour in the UI. To avoid compromising performance such usage never throws any exception.

      NB:- Child tag cannot be reset, i.e. this tag should not be a child of another tag.

      Throws:
      InvalidTagException - if the tag is already used by another tag, i.e. if this tag has a parent tag.
      Since:
      2.1.13
    • getAllNestedChildrenIncludingParent

      protected static Stream<AbstractHtml> getAllNestedChildrenIncludingParent(AbstractHtml parent)
      NB: it might lead to StackOverflowException if the tag hierarchy is deep.
      Parameters:
      parent - the parent object from which the nested children stream to be built.
      Returns:
      stream of all nested children including the given parent object.
      Since:
      2.1.15
    • getReadLock

      protected Lock getReadLock()
      Returns:
      the read lock object
      Since:
      3.0.1
    • getWriteLock

      protected Lock getWriteLock()
      Returns:
      the write lock object
      Since:
      3.0.1
    • give

      public <T extends AbstractHtml> T give(Consumer<T> consumer)
      This method can avoid creating anonymous class coding.
      Eg:
       Div rootDiv = new Div(null, new Id("rootDivId")).<Div>give(parent -> {
           new Div(parent, new Id("parentDivId")).give(nestedTag1 -> {
               new Div(nestedTag1, new Id("child1"));
               new Div(nestedTag1, new Id("child2"));
               new Div(nestedTag1, new Id("child3"));
           });
       });
      
       System.out.println(rootDiv.toHtmlString());
       

      produces

       
       <div id="rootDivId">
          <div id="parentDivId">
               <div id="child1"></div>
               <div id="child2"></div>
               <div id="child3"></div>
           </div>
       </div>
       
       
      Parameters:
      consumer - the consumer object
      Returns:
      the same object on which give method is called.
      Since:
      3.0.7
    • give

      public <R extends AbstractHtml, I> R give(BiFunction<R,I,R> consumer, I input)
      This method can avoid creating anonymous class coding.
      Eg:
       Div div = new Div(null, new Id("rootDivId")).give(TagContent::text, "Hello World");
       System.out.println(div.toHtmlString());
      
       

      produces

       
       <div id="rootDivId">Hello World</div>
       
       

      A mix of give methods will be

       Div div = new Div(null).give(dv -> {
           new Span(dv).give(TagContent::text, "Hello World");
       });
       

      produces

       
       <div>
           <span>Hello World</span>
       </div>
       
       
      Parameters:
      consumer -
      input - the object to be passed as second argument of BiFunction#apply(Object, Object) method.
      Returns:
      the object which BiFunction#apply(Object, Object) returns which will be a subclass of AbstractHtml
      Since:
      3.0.13
    • internalId

      public final InternalId internalId()
      Returns:
      the unique id for this object.
      Since:
      3.0.18