org.xwiki.rendering.internal.parser.reference
Class GenericLinkReferenceParser

java.lang.Object
  extended by org.xwiki.rendering.internal.parser.reference.GenericLinkReferenceParser
All Implemented Interfaces:
ResourceReferenceParser

@Component
@Named(value="default/link")
@Singleton
public class GenericLinkReferenceParser
extends Object
implements ResourceReferenceParser

Each syntax should have its own resource reference parser. However while we wait for syntax specific parser to be implemented this generic parser should provide a good approximation.

Since:
2.5RC1
Version:
$Id$

Field Summary
static char ESCAPE_CHAR
          Escape character to allow "#", "@" and "?" characters in a reference's name.
static String SEPARATOR_ANCHOR
          Anchor separator.
static String SEPARATOR_INTERWIKI
          Interwiki separator.
static String SEPARATOR_QUERYSTRING
          Query String separator.
 
Constructor Summary
GenericLinkReferenceParser()
           
 
Method Summary
protected  List<String> getAllowedURIPrefixes()
           
 ResourceReference parse(String rawReference)
          Parses a resource reference represented (reference to a link, image, attachment, etc) as a String into a ResourceReference object.
protected  String parseElementAfterString(StringBuffer content, String separator)
          Find out the element located to the right of the passed separator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR_INTERWIKI

public static final String SEPARATOR_INTERWIKI
Interwiki separator.

See Also:
Constant Field Values

SEPARATOR_QUERYSTRING

public static final String SEPARATOR_QUERYSTRING
Query String separator.

See Also:
Constant Field Values

SEPARATOR_ANCHOR

public static final String SEPARATOR_ANCHOR
Anchor separator.

See Also:
Constant Field Values

ESCAPE_CHAR

public static final char ESCAPE_CHAR
Escape character to allow "#", "@" and "?" characters in a reference's name.

See Also:
Constant Field Values
Constructor Detail

GenericLinkReferenceParser

public GenericLinkReferenceParser()
Method Detail

getAllowedURIPrefixes

protected List<String> getAllowedURIPrefixes()
Returns:
the list of URI prefixes the link parser recognizes

parse

public ResourceReference parse(String rawReference)
Parses a resource reference represented (reference to a link, image, attachment, etc) as a String into a ResourceReference object.

Specified by:
parse in interface ResourceReferenceParser
Parameters:
rawReference - the string representation of the resource reference to parse (the supported syntax depends on the parser implementation used)
Returns:
the parsed resource reference
See Also:
ResourceReferenceParser.parse(java.lang.String)

parseElementAfterString

protected String parseElementAfterString(StringBuffer content,
                                         String separator)
Find out the element located to the right of the passed separator.

Parameters:
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 element
Returns:
the parsed element or null if the separator string wasn't found


Copyright © 2004-2011 XWiki. All Rights Reserved.