public final class Element extends Object implements ApiElement<Element>, Html
Modifier and Type | Field and Description |
---|---|
protected ApiElement |
internalElement
An original XML element
|
A, A_ACTION, A_ALT, A_CELLPADDING, A_CELLSPACING, A_CLASS, A_COLS, A_COLSPAN, A_CONTENT, A_FOR, A_HREF, A_HTTP_EQUIV, A_CHARSET, A_CHECKED, A_ID, A_LANG, A_LANGUAGE, A_MAXLENGTH, A_MEDIA, A_METHOD, A_NAME, A_READONLY, A_REL, A_ROWS, A_ROWSPAN, A_SELECTED, A_SRC, A_TARGET, A_TYPE, A_VALUE, BODY, BR, BUTTON, DIV, FIELDSET, FORM, H1, H2, H3, HEAD, HEADING_PREFIX, HR, HTML, IMAGE, INPUT, LABEL, LEGEND, LI, LINK, META, OL, OPTION, P, PRE, SCRIPT, SELECT, SPAN, STYLE, TABLE, TD, TEXT_AREA, TH, THEAD, TITLE, TR, UL, V_BLANK, V_GET, V_HIDDEN, V_CHECKBOX, V_PASSWORD, V_POST, V_RESET, V_STYLESHEET, V_SUBMIT, V_TEXT, V_TEXT_CSS
Constructor and Description |
---|
Element(ApiElement original)
New element with a parent
|
Modifier and Type | Method and Description |
---|---|
Element |
addAnchor(String url,
CharSequence... cssClasses)
Add an anchor element with URL and CSS classes
|
Element |
addAnchoredText(String url,
Object... text)
Add an anchor element with texts
|
Element |
addBody(CharSequence... cssClasses)
Add new body element
|
Element |
addBreak(CharSequence... cssClasses)
Add a line break
|
Element |
addButton(CharSequence... cssClasses)
Add new body element
|
Element |
addCDATA(CharSequence charData)
Add a character data in
CDATA format to XML only. |
Element |
addComment(CharSequence comment)
Add a comment text.
|
Element |
addDiv(CharSequence... cssClasses)
Add new body element
|
Element |
addElement(String name)
Create new Element
|
Element |
addElement(String name,
CharSequence... cssClasses)
Add a new Element with optional CSS classes
|
Element |
addFieldset(String title,
CharSequence... cssClasses)
Add new fieldset element including a title
|
Element |
addForm(CharSequence... cssClasses)
Add new body element
|
Element |
addHeading(CharSequence title,
CharSequence... cssClasses)
Add a top heading (level one)
|
Element |
addHeading(int level,
CharSequence title,
CharSequence... cssClasses)
Add new heading with the required level where the first level is the one,
|
Element |
addImage(CharSequence imageLink,
CharSequence alt,
CharSequence... cssClasses)
Add a link to an image
|
Element |
addImage(InputStream imageStream,
CharSequence alt,
CharSequence... cssClasses)
Add an embeded image
|
Element |
addInput(CharSequence... cssClasses)
Add new input element
|
Element |
addLabel(CharSequence... cssClasses)
Add new body element
|
Element |
addLink(CharSequence... cssClasses)
Add new body element
|
Element |
addListItem(CharSequence... cssClasses) |
Element |
addOption(CharSequence... cssClasses)
Add new body element
|
Element |
addOrderedList(CharSequence... cssClasses)
Add new body element
|
Element |
addParagraph(CharSequence... cssClasses)
Add new body element
|
Element |
addPasswordInput(CharSequence... cssClasses)
Add new input element type of password
|
Element |
addPreformatted(CharSequence... cssClasses)
Add new body element
|
Element |
addRawText(Object data)
Add an native text with no escaped characters, for example: XML code, JavaScript, CSS styles
|
Element |
addScript(CharSequence... cssClasses)
Add new body element
|
Element |
addSelect(CharSequence... cssClasses)
Add new select element
|
Element |
addSelectOptions(Object value,
Map<?,?> options,
CharSequence... cssClasses)
Add options from map to current select element
|
Element |
addSpan(CharSequence... cssClasses)
Add new body element
|
Element |
addStyle(CharSequence... cssClasses)
Add new body element
|
Element |
addSubmitButton(CharSequence... cssClasses)
Add a submit button
|
Element |
addTable(CharSequence... cssClasses)
Add new Table
|
Element |
addTable(List<Object[]> data,
CharSequence... cssClass)
Create a HTML table according to data
|
Element |
addTable(Object[][] data,
CharSequence... cssClass)
Create a HTML table according to data
|
Element |
addTableDetail(CharSequence... cssClasses)
Add new body element
|
Element |
addTableHead(CharSequence... cssClasses)
Add new body element
|
Element |
addTableNoSpaces(CharSequence... cssClasses)
Deprecated.
Use a CSS style rather.
|
Element |
addTableRow(CharSequence... cssClasses)
Add new body element
|
Element |
addTemplate(String template,
Object... data)
Add a template based text with parameters
|
Element |
addText(Object... data)
Add many texts with no separator
|
Element |
addText(Object data)
Add simple text
|
Element |
addTextArea(CharSequence... cssClasses)
Add new body element
|
Element |
addTextInput(CharSequence... cssClasses)
Add new input element type of text
|
Element |
addTextSeparted(CharSequence separator,
Object... data)
Add many words separated by the separator
|
Element |
addTitle(CharSequence... cssClasses)
Add new body element
|
Element |
addUnorderedlist(CharSequence... cssClasses)
Add new body element
|
void |
close()
Close the element
|
protected CharSequence |
createEmbededImage(InputStream imageStream,
StringBuilder result)
Create a content of an embeded image
|
static Element |
createHtmlRoot(Object title,
CharSequence... cssLinks)
Crate a root element
|
static Element |
createHtmlRoot(Object title,
Charset charset,
CharSequence... cssLinks)
Crate a root element
|
String |
getName()
Get an element name
|
Element |
setAction(Object value)
Set an action type of from
|
Element |
setAttrib(String name,
Object value)
A shortcut for the method
setAttribute(java.lang.String, java.lang.Object) . |
Element |
setAttribute(String name,
Object value)
Set an attribute
|
Element |
setCellPadding(int value)
Deprecated.
|
Element |
setCellSpacing(int value)
Deprecated.
|
Element |
setClass(CharSequence... cssClasses)
Set a CSS class attribute optionally, the empty attribute is ignored.
|
Element |
setCols(Object value)
Column count of a text area
|
Element |
setColSpan(int value)
Column span inside the table
|
Element |
setFor(CharSequence value)
Set an value of input element
|
Element |
setHref(CharSequence value)
Set hyperlink reference
|
Element |
setId(CharSequence value)
Set an identifier of the element
|
Element |
setMethod(Object value)
Set a method of form
|
Element |
setName(CharSequence value)
Set an name of input element
|
Element |
setRows(int value)
Row count of a text area
|
Element |
setRowSpan(int value)
Row span inside the table
|
Element |
setType(Object value)
Set a type of input element
|
Element |
setValue(Object value)
Set an value of input element
|
String |
toString()
String value
|
protected final ApiElement internalElement
public Element(@Nonnull ApiElement original)
@Nonnull public String getName()
ApiElement
getName
in interface ApiElement<Element>
@Nonnull public final Element setAttribute(@Nonnull String name, @Nullable Object value)
setAttribute
in interface ApiElement<Element>
name
- Required element namevalue
- The null
value is silently ignored. Formatting is performed by the
XmlWriter#writeValue(java.lang.Object, org.ujorm.tools.model.XmlModel, java.lang.String, java.io.Writer)
method, where the default implementation calls a toString()
only.@Nonnull public final Element setAttrib(@Nonnull String name, @Nullable Object value)
setAttribute(java.lang.String, java.lang.Object)
.setAttrib
in interface ApiElement<Element>
name
- Required element namevalue
- The null
value is silently ignored. Formatting is performed by the
XmlWriter#writeValue(java.lang.Object, org.ujorm.tools.model.XmlModel, java.lang.String, java.io.Writer)
method, where the default implementation calls a toString()
only.@Nonnull public Element addText(Object data) throws IllegalStateException
addText
in interface ApiElement<Element>
data
- Text itemIllegalStateException
addAnchoredText(java.lang.String, java.lang.Object...)
@Nonnull public Element addText(@Nonnull Object... data) throws IllegalStateException
data
- Text itemsIllegalStateException
addAnchoredText(java.lang.String, java.lang.Object...)
@Nonnull public Element addTemplate(@Nonnull String template, @Nonnull Object... data) throws IllegalStateException
template
- A message template with an ENGLISH locale. See {@link String#format(java.lang.String, java.lang.Object...) for more parameters.data
- A template parametersIllegalStateException
public Element addTextSeparted(@Nonnull CharSequence separator, @Nonnull Object... data) throws IllegalStateException
separator
- A raw text separatordata
- Data to printIllegalStateException
@Nonnull public Element addRawText(@Nullable Object data) throws IllegalStateException
ApiElement
addRawText
in interface ApiElement<Element>
data
- The null
value is ignored.IllegalStateException
@Nonnull public Element addComment(CharSequence comment) throws IllegalStateException
ApiElement
addComment
in interface ApiElement<Element>
comment
- A comment text must not contain a string -->
.IllegalStateException
@Nonnull public Element addCDATA(CharSequence charData) throws IllegalStateException
ApiElement
CDATA
format to XML only.
The CDATA structure isn't really for HTML at all.addCDATA
in interface ApiElement<Element>
charData
- A text including the final DATA sequence. An empty argument is ignored.IllegalStateException
@Nonnull public void close() throws IllegalStateException
ApiElement
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ApiElement<Element>
IllegalStateException
@Nonnull public Element addElement(@Nonnull String name) throws IllegalStateException
addElement
in interface ApiElement<Element>
name
- The element nameIllegalStateException
- An envelope for IO exceptions@Nonnull public final Element addElement(@Nonnull String name, @Nonnull CharSequence... cssClasses)
name
- A required name of the elementcssClasses
- Optional CSS classes.@Nonnull public Element addTable(@Nonnull CharSequence... cssClasses)
@Deprecated @Nonnull public Element addTableNoSpaces(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addTable(Object[][] data, CharSequence... cssClass)
@Nonnull public Element addTable(List<Object[]> data, CharSequence... cssClass)
@Nonnull public Element addImage(@Nonnull CharSequence imageLink, @Nonnull CharSequence alt, @Nonnull CharSequence... cssClasses) throws IllegalStateException
imageLink
- A link to imagealt
- An alternate textcssClasses
- Optional CSS classesIllegalStateException
@Nonnull public Element addImage(@Nonnull InputStream imageStream, @Nonnull CharSequence alt, @Nonnull CharSequence... cssClasses) throws IllegalStateException
imageStream
- Stream provides a PNG image and it will be closed after reading.alt
- An alternate textcssClasses
- Optional CSS classesIllegalStateException
@Nonnull protected CharSequence createEmbededImage(@Nonnull InputStream imageStream, @Nonnull StringBuilder result)
@Nonnull public Element addBody(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addTitle(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addLink(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addStyle(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addScript(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addDiv(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addFieldset(@Nullable String title, @Nonnull CharSequence... cssClasses)
title
- An optional titlecssClasses
- CSS classesLEGEND
@Nonnull public Element addPreformatted(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addSpan(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addParagraph(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addForm(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addHeading(@Nonnull CharSequence title, @Nonnull CharSequence... cssClasses)
@Nonnull public Element addHeading(int level, @Nonnull CharSequence title, @Nonnull CharSequence... cssClasses)
@Nonnull public Element addTableHead(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addTableRow(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addTableDetail(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addLabel(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addInput(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addTextInput(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addPasswordInput(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addTextArea(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addSelect(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addSelectOptions(@Nonnull Object value, @Nonnull Map<?,?> options, @Nonnull CharSequence... cssClasses)
value
- Value of a select elementoptions
- Consider an instance of the LinkedHashMap
class predictable iteration order of options.cssClasses
- this
addSelect(java.lang.CharSequence...)
@Nonnull public Element addOption(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addButton(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addSubmitButton(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addAnchor(@Nonnull String url, @Nonnull CharSequence... cssClasses)
@Nonnull public Element addAnchoredText(@Nonnull String url, @Nonnull Object... text)
@Nonnull public Element addUnorderedlist(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addOrderedList(@Nonnull CharSequence... cssClasses)
@Nonnull public Element addListItem(@Nonnull CharSequence... cssClasses)
@Nonnull public Element setClass(@Nonnull CharSequence... cssClasses)
cssClasses
- Optional CSS classes. The css item is ignored when the value is empty or null
.@Nonnull public Element addBreak(@Nonnull CharSequence... cssClasses)
@Deprecated @Nonnull public Element setCellPadding(int value)
@Deprecated @Nonnull public Element setCellSpacing(int value)
@Nonnull public static Element createHtmlRoot(@Nonnull Object title, @Nullable CharSequence... cssLinks)
cssLinks
- Nullable CSS link array@Nonnull public static Element createHtmlRoot(@Nonnull Object title, @Nullable Charset charset, @Nullable CharSequence... cssLinks)
title
- A HTML titlecharset
- A charsetcssLinks
- Nullable CSS link array@Nonnull public Element setId(@Nullable CharSequence value)
@Nonnull public Element setName(@Nullable CharSequence value)
@Nonnull public Element setFor(@Nullable CharSequence value)
@Nonnull public Element setHref(@Nullable CharSequence value)
Copyright 2019-2022, Pavel Ponec