Class HTMLFragment
java.lang.Object
com.amalgamasimulation.desktop.html.HTMLFragment
- All Implemented Interfaces:
HTMLConvertable
Represents a container for multiple HTML components that can be converted to HTML.
Supports hierarchical numbering for headers and allows building complex HTML structures
through composition. Maintains internal numbering state for consistent section numbering
across nested fragments.
- Author:
- Alexey Glazyrin
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty HTML fragment.HTMLFragment(List<? extends HTMLConvertable> children) Creates a fragment from a list of HTML components. -
Method Summary
Modifier and TypeMethodDescriptionappend(HTMLConvertable child) Appends a new HTML component to the fragment.Creates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.static HTMLFragmentof(HTMLConvertable... children) Creates a fragment from variable arguments of HTML components.Converts the object to an HTML string.withNumbering(boolean withNumbering) Enables or disables automatic hierarchical numbering for headers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.html.HTMLConvertable
copy, toHTML
-
Constructor Details
-
HTMLFragment
public HTMLFragment()Creates an empty HTML fragment. -
HTMLFragment
Creates a fragment from a list of HTML components.- Parameters:
children- list of components to include in the fragment
-
-
Method Details
-
of
Creates a fragment from variable arguments of HTML components.- Parameters:
children- array of components to include in the fragment- Returns:
- new HTMLFragment containing specified components
-
withNumbering
Enables or disables automatic hierarchical numbering for headers.- Parameters:
withNumbering- true to enable section numbering, false to disable- Returns:
- this fragment for method chaining
-
append
Appends a new HTML component to the fragment.- Parameters:
child- component to add- Returns:
- this fragment for method chaining
-
toHTML
Description copied from interface:HTMLConvertableConverts the object to an HTML string.- Specified by:
toHTMLin interfaceHTMLConvertable- Parameters:
outStrings- set of unique strings of text content- Returns:
-
copy
Description copied from interface:HTMLConvertableCreates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.- Specified by:
copyin interfaceHTMLConvertable- Parameters:
stringsSubstitutionMap- a map where keys are original text strings (as collected byHTMLConvertable.toHTML(Set)) and values are their translations. During copying, any encountered text content present in this map will be replaced with its translated version.- Returns:
- a new independent copy of this HTMLConvertable instance with translated content
-