|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.melati.util.HTMLUtils
public final class HTMLUtils
An assortment of useful things to do with HTML.
Nested Class Summary | |
---|---|
static class |
HTMLUtils.TagInstance
An Instance of a tag. |
Field Summary | |
---|---|
static String |
dtdNameForHTMLParser
The DTD name. |
Method Summary | |
---|---|
static void |
add(ContentModel cm,
Element existing,
Element alt)
Add an Element to the ContentModel. |
static void |
addToContentModels(DTD dtd,
Element existing,
Element alt)
Add element to a DTD. |
static DTD |
dtdForHTMLParser()
|
static String |
entitied(String s)
Escape the given string as PCDATA without regard for any characters that cannot be encoded in some required character set. |
static String |
entitied(String s,
boolean mapBR,
String encoding,
boolean markup)
Return the String with all high value ASCII characters replaced with HTML entities. |
static String |
entityFor(char c,
boolean mapBR,
CharsetEncoder ce,
boolean markup)
If the given character has special meaning in HTML or will not necessarily encode in the character set, then return an escape string. |
static String |
jsEscaped(String s)
Javascript escape a String. |
static String |
jsEscapeFor(char c)
Javascript escape sequence for a character, if any, otherwise null. |
static String |
stringOf(HTML.Tag tag,
AttributeSet attributes)
|
static void |
write(Writer w,
HTML.Tag tag,
AttributeSet attributes)
Write a tag to a Writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String dtdNameForHTMLParser
Method Detail |
---|
public static void add(ContentModel cm, Element existing, Element alt)
cm
- the ContentModel to add toexisting
- existing elementalt
- alternate elementpublic static void addToContentModels(DTD dtd, Element existing, Element alt)
dtd
- DTD to add toexisting
- existing elementalt
- alternate elementpublic static DTD dtdForHTMLParser()
public static String entityFor(char c, boolean mapBR, CharsetEncoder ce, boolean markup)
The name of this method implies the character is escaped as a character entity but if the second argument is true then newlines are encoded as <BR>. This is not required for attribute values.
Which characters will necessarily encode depends on the charset. For backward compatibility if a charset is not passed we assume the character will encode. If a charset is passed and a character does not encode then we replace it with a numeric character reference (not an entity either but pretty similar).
c
- character to lookup entity formapBR
- whether to replace line endsce
- an encodermarkup
- whether string contains markup
public static String entitied(String s, boolean mapBR, String encoding, boolean markup)
s
- input StringmapBR
- whether to replace line ends with html breaksencoding
- the encoding of the input stringmarkup
- whether string is an sgml fragment
public static String entitied(String s)
This is for backward compatibility as it is used below.
s
- the String to replace special characters from
entitied(String, boolean, String, boolean)
public static String jsEscapeFor(char c)
c
- the character
public static String jsEscaped(String s)
s
- the String to escape
public static void write(Writer w, HTML.Tag tag, AttributeSet attributes) throws IOException
w
- the Writer to write totag
- the Tag to writeattributes
- the Tag's attributes
IOException
- if there is a problem writingpublic static String stringOf(HTML.Tag tag, AttributeSet attributes)
tag
- the Tagattributes
- the Tag's attributes
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |