Package org.zkoss.html
Class HTMLs
java.lang.Object
org.zkoss.html.HTMLs
Utilities for HTML attributes and styles.
- Since:
- 6.0.0
- Author:
- tomyeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidappendAttribute(StringBuffer sb, String name, boolean val) Appends an attribute to the string buffer for HTML/XML (name="val").static final voidappendAttribute(StringBuffer sb, String name, double val) Appends an attribute with a long value to the string buffer for HTML/XML (name="val").static final voidappendAttribute(StringBuffer sb, String name, int val) Appends an attribute with a int value to the string buffer for HTML/XML (name="val").static final voidappendAttribute(StringBuffer sb, String name, long val) Appends an attribute with a long value to the string buffer for HTML/XML (name="val").static final voidappendAttribute(StringBuffer sb, String name, short val) Appends an attribute with a short value to the string buffer for HTML/XML (name="val").static final voidappendAttribute(StringBuffer sb, String name, String val) Appends an attribute to the string buffer for HTML/XML (name="val").static final voidappendAttribute(StringBuffer sb, String name, String val, boolean emptyIgnored) Appends an attribute to the string buffer for HTML/XML (name="val").static final voidappendStyle(StringBuffer sb, String name, String val) Appends a style value to the string buffer for HTML/XML (name:"val";).static final intgetSubstyleIndex(String style, String substyle) Returns the position of the specified substyle, or -1 if not found.static final StringgetSubstyleValue(String style, int j) Returns the value starting at the specified index (never null).static final StringgetTextRelevantStyle(String style) Retrieves text relevant CSS styles.static final booleanisOrphanTag(String tagname) Returns whether the specified tag is an 'orphan' tag.
-
Constructor Details
-
HTMLs
public HTMLs()
-
-
Method Details
-
appendAttribute
Appends an attribute to the string buffer for HTML/XML (name="val"). If val is null or empty (if String), nothing is generated.Note:
XMLs.encodeAttribute(java.lang.String)is called automatically to encode val. -
appendAttribute
public static final void appendAttribute(StringBuffer sb, String name, String val, boolean emptyIgnored) Appends an attribute to the string buffer for HTML/XML (name="val"). If emptyIgnored is true and val is null or empty (if String), nothing is generated.Note:
XMLs.encodeAttribute(java.lang.String)is called automatically to encode val.- Parameters:
emptyIgnored- whether to ignore a null or empty string. If false, it is always generated (null is generated as "null").
-
appendAttribute
Appends an attribute with a int value to the string buffer for HTML/XML (name="val"). -
appendAttribute
Appends an attribute with a long value to the string buffer for HTML/XML (name="val"). -
appendAttribute
Appends an attribute with a long value to the string buffer for HTML/XML (name="val"). -
appendAttribute
Appends an attribute with a short value to the string buffer for HTML/XML (name="val"). -
appendAttribute
Appends an attribute to the string buffer for HTML/XML (name="val"). -
appendStyle
Appends a style value to the string buffer for HTML/XML (name:"val";). If val is null or empty (if String), nothing is generated. -
getSubstyleIndex
Returns the position of the specified substyle, or -1 if not found.- Parameters:
style- the stylesubstyle- the sub-style, e.g., display.- Throws:
IllegalArgumentException- if style is null, or substyle is null or empty.
-
getSubstyleValue
Returns the value starting at the specified index (never null).Note: the index is usually the returned vale of
getSubstyleIndex(java.lang.String, java.lang.String).- Parameters:
style- the stylej- the index that the substyle starts at (including the style's name)
-
getTextRelevantStyle
Retrieves text relevant CSS styles.For example, if style is "border: 1px solid blue; font-size: 10px; padding: 3px; color: black;", then "font-size: 10px;color: black;" is returned.
- Returns:
- null if style is null. Otherwise, it never returns null.
-
isOrphanTag
Returns whether the specified tag is an 'orphan' tag. By orphan we mean it doesn't support the format of <xx> </xx>.For example, br and img are orphan tags.
- Parameters:
tagname- the tag name, e.g., br and tr.
-