|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wiki.parser.LinkParser
public class LinkParser
Parses JSPWiki-style "augmented" link markup into a Link object containing the link text, link reference, and any optional link attributes (as JDOM Attributes).
The parser recognizes three link forms:
where the attributes are space-delimited, each in the form of
name1='value1' name2='value2' name3='value3' (etc.)
If the attribute parsing fails, the parser will still return the basic link, writing a warning to the log.
Attributes that aren't declared on <a> or those that permit scripting in HTML (as this is a security risk) are ignored and have no effect on parsing, nor show up in the resulting attribute list). The 'href' and 'name' attributes are also ignored as spurious. The permitted list is: 'accesskey', 'charset', 'class', 'hreflang', 'id', 'lang', 'dir', 'rel', 'rev', 'style' , 'tabindex', 'target' , 'title', and 'type'. The declared attributes that will be ignored are: 'href', 'name', 'shape', 'coords', 'onfocus', 'onblur', or any of the other 'on*' event attributes.
The permitted attributes and target attribute values are static
String arrays (PERMITTED_ATTRIBUTES
and
PERMITTED_TARGET_VALUES
resp.) that could be compile-time
modified (i.e., predeclared).
The following target names are reserved in HTML 4 and have special meanings. These are the only values permitted by the parser.
This returns a Link object, a public inner class with methods:
The attributeCount() method can be used to circumvent calling getAttributes(), which will create an empty Iterator rather than return a null.
From an incoming wikitext link of:
[Acme]returns:
getText(): "Acme" getReference(): "Acme" attributeCount(): 0 getAttributes(): an empty Iterator
From an incoming wikitext link of:
[Acme | http://www.acme.com/]returns:
getText(): "Acme" getReference(): "http://www.acme.com/" attributeCount(): 0 getAttributes(): an empty Iterator
From an incoming wikitext link of:
[Acme | http://www.acme.com/ | id='foo' rel='Next']returns:
getText(): "Acme" getReference(): "http://www.acme.com/" attributeCount(): 2 getAttributes(): an Iterator containing: JDOM Attribute: id="foo" JDOM Attribute: rel="Next"
Nested Class Summary | |
---|---|
static class |
LinkParser.Link
Inner class serving as a struct containing the parsed components of a link. |
Constructor Summary | |
---|---|
LinkParser()
|
Method Summary | |
---|---|
static boolean |
isSpace(char c)
Returns true if char c is a member of S (space) [XML 1.1 production 3]. |
static boolean |
isSpace(String s)
Returns true if the String s is completely composed of whitespace. |
LinkParser.Link |
parse(String linktext)
Processes incoming link text, separating out the link text, the link URI, and then any specified attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LinkParser()
Method Detail |
---|
public LinkParser.Link parse(String linktext) throws ParseException
linktext
- the wiki link text to be parsed
ParseException
- if the parameter is nullpublic static final boolean isSpace(String s)
s
- The string to check
public static final boolean isSpace(char c)
c
- Character to check.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |