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
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class com.webfirmframework.wffweb.tag.core.AbstractJsObject
wffBMDatas
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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.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.AbstractHtml
(AbstractHtml base, AbstractHtml... children) AbstractHtml
(AbstractHtml base, String childContent) protected
AbstractHtml
(AbstractHtml base, String childContent, boolean noTagContentTypeHtml) AbstractHtml
(AbstractHtml base, Collection<? extends AbstractHtml> children) 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.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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributes
(boolean updateClient, AbstractAttribute... attributes) adds the given attributes to this tag.void
addAttributes
(boolean updateClient, Collection<AbstractAttribute> attributes) adds the given attributes to this tag.void
addAttributes
(AbstractAttribute... attributes) adds the given attributes to this tag.final boolean
addChild
(Object accessObject, AbstractHtml child, boolean invokeListener) NB: This method is for internal use<T> void
addInnerHtml
(boolean updateClient, SharedTagContent<T> sharedTagContent) <T> void
addInnerHtml
(boolean updateClient, SharedTagContent<T> sharedTagContent, SharedTagContent.ContentFormatter<T> formatter) void
addInnerHtml
(AbstractHtml innerHtml) removes all children and adds the given tag<T> void
addInnerHtml
(SharedTagContent<T> sharedTagContent) <T> void
addInnerHtml
(SharedTagContent<T> sharedTagContent, SharedTagContent.ContentFormatter<T> formatter) protected void
addInnerHtmls
(boolean updateClient, AbstractHtml... innerHtmls) Removes all children and adds the given tags as children.void
addInnerHtmls
(AbstractHtml... innerHtmls) Removes all children and adds the given tags as children.protected WffBMData
addWffData
(String key, WffBMData wffBMData) boolean
appendChild
(AbstractHtml child) Appends the given child tag to its children.void
appendChildren
(AbstractHtml... children) adds the given children to the last position of the current children of this object.void
appendChildren
(Collection<AbstractHtml> children) adds the given children to the last position of the current children of this object.protected void
invokes just beforegetPrintStructure(final boolean
method and only if the getPrintStructure(final boolean} rebuilds the structure.protected void
invokes just beforewritePrintStructureToOutputStream(final OutputStream
method.protected void
invokes just beforewritePrintStructureToWffBinaryMessageOutputStream(final OutputStream
method.clone()
Creates and returns a deeply cloned copy of this object.Creates and returns a deeply cloned copy of this object.boolean
containsChild
(AbstractHtml childTag) Checks whether a tag is contained in its direct children.protected AbstractHtml
deepClone
(AbstractHtml objectToBeClonned) protected static Stream<AbstractHtml>
NB: it might lead to StackOverflowException if the tag hierarchy is deep.getAttributeByName
(String attributeName) gets the attribute by attribute namebyte[][]
getAttributeHtmlBytesCompressedByIndex
(boolean rebuild, Charset charset) Deprecated.not recommended since 3.0.19, it will be removed in future major version.getChildAt
(int index) Gets the child at the specified position.final Set<AbstractHtml>
getChildren
(Object accessObject) NB: this method is for internal use.Gets the children of this tag as an array.int
Gets the number of children in this tag.For internal purpose.static AbstractHtml
getExactTagFromWffBMBytes
(byte[] bmBytes, Charset charset) Gets the first child of this tag.protected StringBuilder
int
getIndexByChild
(AbstractHtml child) Gets the nth index of the given tag in this tag's children.final int
getIndexByChild
(Object accessObject, AbstractHtml child) NB: only for internal use.Gets the last child of this tag.final String
For internal purpose.protected String
protected String
getPrintStructure
(boolean rebuild) protected Lock
Gets the root level tag of this tag.Gets the object which is accessible in all of this tag hierarchy.NB: it will not always return the same object as could be modified by the framework at any time.<T> SharedTagContent<T>
static AbstractHtml
getTagFromWffBMBytes
(byte[] bmMessageBytes) static AbstractHtml
getTagFromWffBMBytes
(byte[] bmBytes, String charset) static AbstractHtml
getTagFromWffBMBytes
(byte[] bmBytes, Charset charset) Eg tag names :- html, body, div table, input, button etc...protected WffBMData
getWffData
(String key) Gets the unmodifiable map of wffObjects which are upserted byTagRepository.upsert(AbstractHtml, String, WffBMObject)
orTagRepository.upsert(AbstractHtml, String, WffBMArray)
.protected Lock
<R extends AbstractHtml,
I>
Rgive
(BiFunction<R, I, R> consumer, I input) This method can avoid creating anonymous class coding.<T extends AbstractHtml>
TThis method can avoid creating anonymous class coding.boolean
insertAfter
(AbstractHtml... abstractHtmls) Inserts the given tags after this tag.boolean
insertAfterIfPossible
(AbstractHtml... abstractHtmls) Inserts the given tags after this tag only if this tag has a parent.boolean
insertBefore
(AbstractHtml... abstractHtmls) Inserts the given tags before this tag.boolean
insertBeforeIfPossible
(AbstractHtml... abstractHtmls) Inserts the given tags before this tag only if this tag has parent.final InternalId
boolean
boolean
protected static void
loopThroughAllNestedChildren
(NestedChild nestedChild, boolean includeParents, AbstractHtml... parents) Loops through all nested children tags (excluding the given tag) of the given tag.void
prependChildren
(AbstractHtml... children) prepends the given children to the first position of the current children of this object.void
Removes all children from this tag.boolean
removeAttributes
(boolean updateClient, AbstractAttribute... attributes) removes the given attributes from this tag.boolean
removeAttributes
(boolean updateClient, String... attributeNames) removes the given attributes from this tag.boolean
removeAttributes
(AbstractAttribute... attributes) removes the given attributes from this tag.final boolean
removeAttributes
(Object accessObject, boolean invokeListener, AbstractAttribute... attributes) removes the given attributes from this tag.final boolean
removeAttributes
(Object accessObject, boolean invokeListener, String... attributeNames) removes the given attributes from this tag.boolean
removeAttributes
(String... attributeNames) removes the given attributes from this tag.boolean
removeChild
(AbstractHtml child) Removes the given tag from its children only if the given tag is a child of this tag.boolean
removeChildren
(AbstractHtml... children) Removes the given tags from its children tags.boolean
removeChildren
(Collection<AbstractHtml> children) Removes the given tags from its children tags.boolean
removeSharedTagContent
(boolean removeContent) protected WffBMData
removeWffData
(String key) boolean
replaceWith
(AbstractHtml... tags) Replaces this tag with the given tags.boolean
replaceWithIfPossible
(AbstractHtml... tags) Replaces this tag with the given tags only if it has a parent.final void
Resets the hierarchy of this tag so that it can be used in another instance ofBrowserPage
.void
setCharset
(Charset charset) Deprecated.not recommended since 3.0.19, it will be removed in future major version.void
setChildren
(Set<AbstractHtml> children) Removes all current children and adds the given children under this tag.void
setDataWffId
(DataWffId dataWffId) adds data-wff-id for the tag if doesn't already exist.void
setParent
(AbstractHtml parent) Deprecated.This method is not allowed to use.void
setSharedData
(Object sharedData) Sets the object which will be accessible by getSharedData method in all of this tag hierarchy.boolean
setSharedDataIfNull
(Object sharedData) <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.<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.<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.Use this method to produce HTML from very heavy and complicated tag hierarchy.toBigHtmlString
(boolean rebuild) Use this method to produce HTML from very heavy and complicated tag hierarchy.int
Use this method to produce HTML from very heavy and complicated tag hierarchy.int
toBigOutputStream
(OutputStream os, boolean rebuild) Use this method to produce HTML from very heavy and complicated tag hierarchy.int
toBigOutputStream
(OutputStream os, boolean rebuild, String charset) Use this method to produce HTML from very heavy and complicated tag hierarchy.int
toBigOutputStream
(OutputStream os, boolean rebuild, Charset charset) Use this method to produce HTML from very heavy and complicated tag hierarchy.int
toBigOutputStream
(OutputStream os, boolean rebuild, Charset charset, boolean flushOnWrite) Use this method to produce HTML from very heavy and complicated tag hierarchy.int
toBigOutputStream
(OutputStream os, String charset) Use this method to produce HTML from very heavy and complicated tag hierarchy.int
toBigOutputStream
(OutputStream os, Charset charset) Use this method to produce HTML from very heavy and complicated tag hierarchy.byte[]
toCompressedWffBMBytes
(Charset charset) byte[]
toCompressedWffBMBytesV2
(Charset charset) final byte[]
toCompressedWffBMBytesV2
(Charset charset, Object accessObject) Only for internal purposegets the html string of the tag including the child tags/values.toHtmlString
(boolean rebuild) 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.toHtmlString
(boolean rebuild, String charset) Deprecated.toHtmlString
(boolean rebuild, Charset charset) Deprecated.toHtmlString
(String charset) Deprecated.toHtmlString
(Charset charset) Deprecated.int
int
toOutputStream
(OutputStream os, boolean rebuild) int
toOutputStream
(OutputStream os, boolean rebuild, boolean flushOnWrite) int
toOutputStream
(OutputStream os, boolean rebuild, String charset) int
toOutputStream
(OutputStream os, boolean rebuild, Charset charset) int
toOutputStream
(OutputStream os, boolean rebuild, Charset charset, boolean flushOnWrite) int
toOutputStream
(OutputStream os, String charset) int
toOutputStream
(OutputStream os, Charset charset) int
toOutputStream
(OutputStream os, Charset charset, boolean flushOnWrite) toString()
gets the html string of the tag including the child tags/values.byte[]
byte[]
toWffBMBytes
(String charset) byte[]
toWffBMBytes
(Charset charset) final byte[]
toWffBMBytes
(Charset charset, Object accessObject) Only for internal use.protected int
writePrintStructureToOutputStream
(OutputStream os, boolean rebuild, Charset charset, boolean flushOnWrite) protected int
writePrintStructureToOutputStream
(Charset charset, OutputStream os, boolean rebuild) protected void
writePrintStructureToWffBinaryMessageOutputStream
(boolean rebuild) Methods inherited from class com.webfirmframework.wffweb.tag.core.AbstractJsObject
addWffData, getWffData, removeWffData
Methods inherited from class com.webfirmframework.wffweb.tag.core.AbstractTagBase
equals, getData, hashCode, isModified, isRebuild, setData, setModified, setRebuild
-
Field Details
-
noTagContentTypeHtml
protected final boolean noTagContentTypeHtml
-
-
Constructor Details
-
AbstractHtml
- Parameters:
base
- the parent tag of this objectchildren
- the tags which will be added as a children tag of this object.
-
AbstractHtml
- Parameters:
base
- the parent tag of this objectchildren
- the tags which will be added as a children tag of this object.- Since:
- 3.0.1
-
AbstractHtml
- Parameters:
base
-childContent
- any text, it can also be html text.- Since:
- 3.0.2
-
AbstractHtml
- Parameters:
base
-childContent
- any text, it can also be html text.
-
AbstractHtml
should be invoked to generate opening and closing tag base class containing the functionalities to generate html string.- Parameters:
tagName
- TODObase
- 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 constantbase
- 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
- TODObase
- 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 constantbase
- TODO- Since:
- 3.0.3
-
-
Method Details
-
appendChild
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
removes all children and adds the given tag- Parameters:
innerHtml
- the inner html tag to add
-
addInnerHtmls
Removes all children and adds the given tags as children.- Parameters:
innerHtmls
- the inner html tags to add- Since:
- 2.1.3
-
addInnerHtmls
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
-
removeChildren
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
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
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
NB: This method is for internal use- Parameters:
accessObject
-child
-invokeListener
-- Returns:
- Since:
- 2.0.0
-
appendChildren
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
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
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
adds the given attributes to this tag.- Parameters:
attributes
- attributes to add- Since:
- 2.0.0
-
addAttributes
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
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
- Returns:
- the collection of attributes
- Since:
- 2.0.0
-
getAttributeByName
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
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 listenerattributes
- attributes to remove- Returns:
- true if any of the attributes are removed.
- Since:
- 2.0.0
-
removeAttributes
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
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 listenerattributeNames
- to remove the attributes having in the given names.- Returns:
- true if any of the attributes are removed.
- Since:
- 2.0.0
-
removeAttributes
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
-
setParent
Deprecated.This method is not allowed to use. It's not implemented.- Parameters:
parent
-- Since:
- 2.0.0
-
getChildren
- Returns:
- the unmodifiable list of children
- Since:
- 2.0.0
-
getChildren
NB: this method is for internal use. The returned object should not be modified.- Returns:
- the internal children object.
- Since:
- 2.0.0
-
setChildren
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
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
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
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
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 useAbstractHtml#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
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
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
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
For internal purpose. Not recommended for external purpose.- Returns:
- the opening tag of this object
-
getClosingTag
For internal purpose.- Returns:
- the closing tag of this object
-
getPrintStructure
- Returns:
String
equalent to the html string of the tag including the child tags.- Since:
- 1.0.0
-
getPrintStructure
- 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
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoHtmlString
method which is faster than this method. The advantage oftoBigHtmlString
overtoHtmlString
is it will never throwStackOverflowError
.
NB:- this method has not been undergone all testing process.- Returns:
- the HTML string similar to toHtmlString method.
- Since:
- 2.1.12
-
toBigHtmlString
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoHtmlString
method which is faster than this method. The advantage oftoBigHtmlString
overtoHtmlString
is it will never throwStackOverflowError
.
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
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
to write to.- Returns:
- the total number of bytes written
- Throws:
IOException
- Since:
- 2.1.12
-
toBigOutputStream
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
to write to.charset
- the charset- Returns:
- Throws:
IOException
- Since:
- 2.1.12
-
toBigOutputStream
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
to write to.charset
- the charset- Returns:
- the total number of bytes written
- Throws:
IOException
- Since:
- 2.1.12
-
toBigOutputStream
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
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
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
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 usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
to write to.rebuild
- true to rebuild & false to write previously built bytes.charset
- the charsetflushOnWrite
- true to flush on each write to OutputStream- Returns:
- the total number of bytes written
- Throws:
IOException
- Since:
- 3.0.15
-
toBigOutputStream
Use this method to produce HTML from very heavy and complicated tag hierarchy. For normal and simple HTML hierarchy usetoOutputStream
method which is faster than this method. The advantage oftoBigOutputStream
overtoOutputStream
is it will never throwStackOverflowError
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 ofOutputStream
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
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.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.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
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.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.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
- Parameters:
os
- the object ofOutputStream
to write to.- Returns:
- the total number of bytes written
- Throws:
IOException
-
toOutputStream
- Parameters:
os
- the object ofOutputStream
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 ofOutputStream
to write to.charset
- the charsetflushOnWrite
- true to flush on each write to OutputStream- Returns:
- Throws:
IOException
- Since:
- 3.0.2
-
toOutputStream
- Parameters:
os
- the object ofOutputStream
to write to.charset
- the charset- Returns:
- the total number of bytes written
- Throws:
IOException
-
toOutputStream
- Parameters:
os
- the object ofOutputStream
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 ofOutputStream
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
- Parameters:
os
- the object ofOutputStream
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 ofOutputStream
to write to.rebuild
- true to rebuild & false to write previously built bytes.charset
- the charsetflushOnWrite
- true to flush on each write to OutputStream- Returns:
- the total number of bytes written
- Throws:
IOException
- Since:
- 3.0.2
-
toOutputStream
- Parameters:
os
- the object ofOutputStream
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
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. -
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
-
getHtmlMiddleSB
- Returns:
- the htmlMiddleSB
- Since:
- 1.0.0
-
isHtmlStartSBAsFirst
public boolean isHtmlStartSBAsFirst()- Returns:
- the htmlStartSBAsFirst
- Since:
- 1.0.0
-
deepClone
- Throws:
CloneNotSupportedException
-
beforePrintStructure
protected void beforePrintStructure()invokes just beforegetPrintStructure(final boolean
method and only if the getPrintStructure(final boolean} rebuilds the structure.- Since:
- 1.0.0
-
beforeWritePrintStructureToOutputStream
protected void beforeWritePrintStructureToOutputStream()invokes just beforewritePrintStructureToOutputStream(final OutputStream
method.- Since:
- 1.0.0
-
beforeWritePrintStructureToWffBinaryMessageOutputStream
protected void beforeWritePrintStructureToWffBinaryMessageOutputStream()invokes just beforewritePrintStructureToWffBinaryMessageOutputStream(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 objectx
, the expression:x.clone() != x
x.clone().getClass() == x.getClass()
true
, but these are not absolute requirements. While it is typically the case that:x.clone().equals(x)
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 (exceptObject
) obey this convention, it will be the case thatx.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 bysuper.clone
need to be modified.The method
clone
for classAbstractHtml
performs a specific cloning operation. First, if the class of this object does not implement the interfacesCloneable
andSerializable
, then aCloneNotSupportedException
is thrown. Note that all arrays are considered to implement the interfaceCloneable
and that the return type of theclone
method of an array typeT[]
isT[]
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 classObject
- Returns:
- a deep clone of this instance.
- Throws:
CloneNotSupportedException
- if the object's class does not support theCloneable
andSerializable
interfaces. Subclasses that override theclone
method can also throw this exception to indicate that an instance cannot be cloned.- See Also:
-
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 objectx
, the expression:x.clone() != x
x.clone().getClass() == x.getClass()
true
, but these are not absolute requirements. While it is typically the case that:x.clone().equals(x)
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 (exceptObject
) obey this convention, it will be the case thatx.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 bysuper.clone
need to be modified.The method
clone
for classAbstractHtml
performs a specific cloning operation. First, if the class of this object does not implement the interfacesCloneable
andSerializable
, then aCloneNotSupportedException
is thrown. Note that all arrays are considered to implement the interfaceCloneable
and that the return type of theclone
method of an array typeT[]
isT[]
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 theCloneable
andSerializable
interfaces. Subclasses that override theclone
method can also throw this exception to indicate that an instance cannot be cloned.- Since:
- 2.0.0
- See Also:
-
getCharset
Deprecated.not recommended since 3.0.19, it will be removed in future major version.- Returns:
- the charset
-
setCharset
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
- 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
- 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
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
- 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
- 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
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
- 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
- Parameters:
bmBytes
- Wff Binary Message bytes of tag i.e. returned bytoWffBMBytes(String)
charset
- the charset used to generate bm bytes intoWffBMBytes(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
- Parameters:
bmBytes
- Wff Binary Message bytes of tag i.e. returned bytoWffBMBytes(Charset)
charset
- the charset used to generate bm bytes intoWffBMBytes(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
- Parameters:
bmBytes
- Wff Binary Message bytes of tag i.e. returned bytoWffBMBytes(Charset)
charset
- the charset used to generate bm bytes intoWffBMBytes(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
- Returns:
- the dataWffId
-
setDataWffId
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
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
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
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
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
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
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 loopparents
- the tags from which to loop through.- Since:
- 2.1.8
-
addWffData
- Parameters:
key
-wffBMData
-- Returns:
- Since:
- 2.1.8
-
removeWffData
- Parameters:
key
-- Returns:
- Since:
- 2.1.8
-
getWffData
- Parameters:
key
-- Returns:
- Since:
- 3.0.1
-
getWffObjects
Gets the unmodifiable map of wffObjects which are upserted byTagRepository.upsert(AbstractHtml, String, WffBMObject)
orTagRepository.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
orWffBMArray
. This map may be null if there is noTagRepository#upsert
operation has been done at least once in the whole life cycle. Otherwise it may also be empty. - Since:
- 2.1.8
-
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
-
resetHierarchy
Resets the hierarchy of this tag so that it can be used in another instance ofBrowserPage
. If a tag is used under aBrowserPage
instance and the same instance of tag needs to be used in another instance ofBrowserPage
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
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
- Returns:
- the read lock object
- Since:
- 3.0.1
-
getWriteLock
- Returns:
- the write lock object
- Since:
- 3.0.1
-
give
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
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 ofBiFunction#apply(Object, Object)
method.- Returns:
- the object which
BiFunction#apply(Object, Object)
returns which will be a subclass ofAbstractHtml
- Since:
- 3.0.13
-
internalId
- Returns:
- the unique id for this object.
- Since:
- 3.0.18
-