public abstract class AbstractElement<E extends AbstractElement> extends Object implements Closeable
HtmlElement| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_INTENDATION
Default intendation have got 4 spaces per level
|
static String |
HTML_DOCTYPE
HTML doctype
|
protected String |
name
Element name
|
protected static String |
REQUIRED_MSG
Assertion message template
|
static String |
XML_HEADER
XML header
|
| Constructor and Description |
|---|
AbstractElement(CharSequence name)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
abstract <T extends E> |
addCDATA(CharSequence charData)
Add a character data in
CDATA format to XML only. |
abstract <T extends E> |
addComment(CharSequence comment)
Add a comment text.
|
abstract <T extends E> |
addElement(String name)
Create a new
XmlElement for a required name and add it to children. |
abstract <T extends E> |
addRawText(Object value)
Add an native text with no escaped characters, for example: XML code, JavaScript, CSS styles
|
abstract <T extends E> |
addText(Object value)
Add a text and escape special character
|
String |
getName()
Get an element name
|
abstract <T extends E> |
setAttrib(String name,
Object value)
Set an attribute
|
public static final String XML_HEADER
public static final String HTML_DOCTYPE
public static final String DEFAULT_INTENDATION
protected static final String REQUIRED_MSG
public AbstractElement(@Nonnull CharSequence name)
@Nonnull public abstract <T extends E> T addElement(@Nonnull String name) throws IOException
XmlElement for a required name and add it to children.name - A name of the new XmlElement is required.IOException@Nonnull public abstract <T extends E> T setAttrib(@Nonnull String name, @Nullable Object value) throws IOException
name - Required element namevalue - The null value is silently ignored. Formatting is performed by the
XmlWriter#writeValue(java.lang.Object, org.ujorm.tools.dom.XmlElement, java.lang.String, java.io.Writer)
method, where the default implementation calls a toString() only.IOException@Nonnull public abstract <T extends E> T addText(@Nullable Object value) throws IOException
value - The null value is allowed. Formatting is performed by the
XmlWriter#writeValue(java.lang.Object, org.ujorm.tools.dom.XmlElement, java.lang.String, java.io.Writer)
method, where the default implementation calls a toString() only.IOException@Nonnull public abstract <T extends E> T addRawText(@Nullable Object value) throws IOException
value - The null value is ignored.IOException@Nonnull public abstract <T extends E> T addComment(@Nullable CharSequence comment) throws IOException
comment - A comment text must not contain a string --> .IOException@Nonnull public abstract <T extends E> T addCDATA(@Nullable CharSequence charData) throws IOException
CDATA format to XML only.
The CDATA structure isn't really for HTML at all.charData - A text including the final DATA sequence. An empty argument is ignored.IOExceptionCopyright 2015, Pavel Ponec