public class LinkParser extends Object implements ContentParser
Link
.Link
Constructor and Description |
---|
LinkParser() |
Modifier and Type | Method and Description |
---|---|
Link |
parse(String contentToParse)
Parse the raw content representing a Wiki link (as typed by the user) and transfer it into
a structured form as a
Link Object. |
protected void |
parseAlias(StringBuffer content,
Link link)
Find out the alias part of the full link.
|
protected String |
parseElementAfterString(StringBuffer content,
String separator)
Find out the element located to the right of the passed separator.
|
protected String |
parseElementBeforeString(StringBuffer content,
String separator)
Find out the element located to the left of the passed separator.
|
protected void |
parseTarget(StringBuffer content,
Link link)
Find out the target part of the full link.
|
protected URI |
parseURI(StringBuffer content)
Find out the URI part of the full link.
|
public Link parse(String contentToParse) throws ContentParserException
Link
Object.contentToParse
- the raw content to parse. This is the link content without the
square brackets.Link
object containing the parsed dataContentParserException
- in case of an error while parsing, like a malformed
element for exampleprotected void parseAlias(StringBuffer content, Link link)
Note: As it's possible to specify a target we need a way to differentiate the following 2 links:
content
- the string to parse. This parameter will be modified by the method to remove
the parsed content.link
- the link on which to set the alias and the delimiter symbol usedprotected void parseTarget(StringBuffer content, Link link) throws ContentParserException
Note: The target element must start with an underscore ("_"). See
parseAlias(StringBuffer, Link)
for more details as to why.
content
- the string to parse. This parameter will be modified by the method to remove
the parsed content.link
- the link on which to set the target and the delimiter symbol usedContentParserException
- if the target does not start with an underscoreprotected URI parseURI(StringBuffer content) throws ContentParserException
content
- the string to parse. This parameter will be modified by the method to remove
the parsed content.ContentParserException
- if the URI is malformedprotected String parseElementBeforeString(StringBuffer content, String separator)
content
- the string to parse. This parameter will be modified by the method to remove
the parsed content.separator
- the separator string to locate the elementprotected String parseElementAfterString(StringBuffer content, String separator)
content
- the string to parse. This parameter will be modified by the method to remove
the parsed content.separator
- the separator string to locate the elementCopyright © 2004–2014 XWiki. All rights reserved.