public final class XhtmlUtil extends Object
This uses JDOM2 as its backing implementation.
To generate a single element, an Element with PCDATA content, and then embed the latter in the former:
Element div = XhtmlUtil.element(XHTML.div); Element p = XhtmlUtil.element(XHTML.p,"Some content"); div.addContent(p);
There is also a convenient link and link target constructor methods:
Element link = XhtmlUtil.link("hrefValue","linkText"); Element target = XhtmlUtil.target("targetIdValue","linkText");
Modifier and Type | Field and Description | |
---|---|---|
static org.jdom2.output.Format |
EXPAND_EMPTY_NODES
to print instead of
|
Modifier and Type | Method and Description |
---|---|
static org.jdom2.Element |
element(XHTML element)
Return an Element with an element type name matching the parameter.
|
static org.jdom2.Element |
element(XHTML element,
String content)
Return an Element with an element type name matching the parameter,
and optional PCDATA (parsed character data, a String) content.
|
static org.jdom2.Element |
img(String src,
String alt)
Return an XHTML img element with an required 'src' attribute
and optional 'alt' alternative text value.
|
static org.jdom2.Element |
input(String type,
String name,
String value)
Return an XHTML form input element with optional 'type', 'name' and 'value' attributes.
|
static org.jdom2.Element |
link(String href,
String content)
Return an XHTML link with a required 'href' attribute value and optional link (PCDATA) content.
|
static String |
serialize(org.jdom2.Element element)
Serializes the Element to a String using a compact serialization format.
|
static String |
serialize(org.jdom2.Element element,
boolean pretty)
Serializes the Element to a String.
|
static String |
serialize(org.jdom2.Element element,
org.jdom2.output.Format format)
Serializes the Element to a String.
|
static void |
setClass(org.jdom2.Element element,
String classValue) |
static org.jdom2.Element |
target(String id,
String content)
Return an XHTML link target with a required 'id' attribute value.
|
public static final org.jdom2.output.Format EXPAND_EMPTY_NODES
public static String serialize(org.jdom2.Element element)
element
- the element to serialize.public static String serialize(org.jdom2.Element element, boolean pretty)
element
- the element to serialize.pretty
- if true, use a pretty whitespace format.public static String serialize(org.jdom2.Element element, org.jdom2.output.Format format)
element
- the element to serialize.format
- custom format used to serialize the Element.public static org.jdom2.Element element(XHTML element)
element
- the XHTML element type.public static org.jdom2.Element element(XHTML element, String content)
element
- the XHTML element type.content
- the optional PCDATA content.public static org.jdom2.Element link(String href, String content)
href
- the required 'href' value.content
- the optional link (PCDATA) content.public static org.jdom2.Element target(String id, String content)
id
- the required 'id' link target value.public static org.jdom2.Element img(String src, String alt)
src
- the required 'src' value.alt
- the optional 'alt' alternative text value.public static org.jdom2.Element input(String type, String name, String value)
type
- the optional 'type' value.name
- the optional 'name' value.value
- the optional 'value' value.Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.