|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.maven.doxia.util.HtmlTools
public class HtmlTools
The HtmlTools class defines methods to HTML handling.
| Constructor Summary | |
|---|---|
HtmlTools()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
encodeFragment(java.lang.String text)
Replace all characters in a text. |
static java.lang.String |
encodeId(java.lang.String id)
Construct a valid id. |
static java.lang.String |
encodeURL(java.lang.String url)
Encode an url |
static java.lang.String |
escapeHTML(java.lang.String text)
Escape special characters in a text in HTML. |
static boolean |
isId(java.lang.String text)
Determines if the specified text is a valid id according to the rules laid out in encodeId(String). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HtmlTools()
| Method Detail |
|---|
public static java.lang.String escapeHTML(java.lang.String text)
< becomes< > becomes> & becomes& " becomes"
text - the String to escape, may be null
public static java.lang.String encodeURL(java.lang.String url)
url - the String to encode, may be null
public static java.lang.String encodeFragment(java.lang.String text)
HtmlTools.encodeFragment( null ) = null HtmlTools.encodeFragment( "" ) = "" HtmlTools.encodeFragment( "http://www.google.com" ) = "httpwwwgooglecom"
text - the String to check, may be null
public static java.lang.String encodeId(java.lang.String id)
According to the HTML 4.01 specification section 6.2 SGML basic types:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
According to XHTML 1.0 section C.8. Fragment Identifiers:
When defining fragment identifiers to be backward-compatible, only strings matching the pattern [A-Za-z][A-Za-z0-9:_.-]* should be used.
To achieve this we need to convert the id String. Two conversions are necessary and one is done to get prettier ids:
For letters, the case is preserved in the conversion.
Here are some examples:
HtmlTools.encodeId( null ) = null HtmlTools.encodeId( "" ) = "" HtmlTools.encodeId( " _ " ) = "a_" HtmlTools.encodeId( "1" ) = "a1" HtmlTools.encodeId( "1anchor" ) = "a1anchor" HtmlTools.encodeId( "_anchor" ) = "a_anchor" HtmlTools.encodeId( "a b-c123 " ) = "a_b-c123" HtmlTools.encodeId( " anchor" ) = "anchor" HtmlTools.encodeId( "myAnchor" ) = "myAnchor"
id - The id to be encoded
public static boolean isId(java.lang.String text)
text - The text to be tested
true if the text is a valid id, otherwise falseencodeId(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||