Package org.ujorm.tools.xml
Interface ApiElement<E extends ApiElement<?>>
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
AbstractElement,AbstractHtmlElement,Element,HtmlElement,XmlBuilder,XmlElement,XmlModel
An element model API.
The XmlElement class implements the
Closeable implementation
for an optional highlighting the tree structure in the source code.- Since:
- 1.86
- Author:
- Pavel Ponec
-
Method Summary
Modifier and TypeMethodDescriptionaddCDATA(@Nullable CharSequence charData) Add a character data inCDATAformat to XML only.addComment(@Nullable CharSequence comment) Add a comment text.addElement(@NotNull String name) Create a newApiElementfor a required name and add it to children.addRawText(@Nullable Object value) Add an native text with no escaped characters, for example: XML code, JavaScript, CSS stylesAdd a text and escape special characteraddTextTemplated(@Nullable CharSequence template, @NotNull Object... values) Message templatevoidclose()Close the element@NotNull StringgetName()Get an element namedefault EDeprecated.setAttribute(@NotNull String name, @Nullable Object value) Set an attribute
-
Method Details
-
getName
Get an element name -
addElement
Create a newApiElementfor a required name and add it to children.- Parameters:
name- A name of the new XmlElement is required.- Returns:
- The new XmlElement!
-
setAttribute
Set an attribute- Parameters:
name- Required element namevalue- Thenullvalue is silently ignored. Formatting is performed by theAbstractWriter.writeValue(Object, ApiElement, String)method, where the default implementation calls atoString()only.- Returns:
- The original element
-
setAttrib
@Deprecated @NotNull default E setAttrib(@NotNull @NotNull String name, @Nullable @Nullable Object value) Deprecated.Call a methodsetAttribute(java.lang.String, java.lang.Object)rather. -
addText
Add a text and escape special character- Parameters:
value- Thenullvalue is allowed. Formatting is performed by theAbstractWriter.writeValue(Object, ApiElement, String)} method, where the default implementation calls atoString()only.- Returns:
- This instance
-
addTextTemplated
@NotNull E addTextTemplated(@Nullable @Nullable CharSequence template, @NotNull @NotNull Object... values) Message template- Parameters:
template- Message template where parameters are marked by the{}symbolvalues- argument values- Returns:
- The original builder
-
addRawText
Add an native text with no escaped characters, for example: XML code, JavaScript, CSS styles- Parameters:
value- Thenullvalue is ignored.- Returns:
- This instance
-
addComment
Add a comment text. The CDATA structure isn't really for HTML at all.- Parameters:
comment- A comment text must not contain a string-->.- Returns:
- This instance
-
addCDATA
Add a character data inCDATAformat to XML only. The CDATA structure isn't really for HTML at all.- Parameters:
charData- A text including the final DATA sequence. An empty argument is ignored.- Returns:
- This instance
-
close
void close()Close the element- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
setAttribute(java.lang.String, java.lang.Object)rather.