com.xpn.xwiki.content.parsers
Class DocumentParser
java.lang.Object
com.xpn.xwiki.content.parsers.DocumentParser
- All Implemented Interfaces:
- ContentParser
public class DocumentParser
- extends Object
- implements ContentParser
Parse document source content as typed by the user.
Note: This is a very basic parser which currently only parses wiki links. It should probably
not be developed further. Instead we should migrate to a proper parser such as
WikiModel. In any case parsing should be done
with a proper parser, such as ANTLR, JavaCC, etc.
- Version:
- $Id: 242d26f7704971a95759dd3746f128e8f7b42291 $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DocumentParser
public DocumentParser()
parseLinks
public ParsingResultCollection parseLinks(String contentToParse)
- Parse the links contained into the passed content represent the raw content from a document
(as typed by the user).
- Parameters:
contentToParse
- the raw document content to parse.
- Returns:
- a list of
Link
objects containing the parsed links and a list of invalid
link contents found, returned as a ParsingResultCollection
. This allows
users of this method to decide what they want to do with invalid links (like
report them to the user, fix them, generate an error, etc).
parseLinksAndReplace
public ReplacementResultCollection parseLinksAndReplace(String contentToParse,
Link linkToLookFor,
Link newLink,
ReplaceLinkHandler linkHandler,
String currentSpace)
- Parse the links contained into the passed content represent the raw content from a document
(as typed by the user) and replace links that matches the passed linkToLookFor Link with the
specified newLink link. The comparison between found links and the link to look for is done
by the ReplaceLinkHandler passed as parameter.
- Parameters:
contentToParse
- the raw document content to parse.linkToLookFor
- the link to look for that will be replaced by the new linknewLink
- the new linklinkHandler
- the handler to use for comparing the links and for deciding what the
replaced link will look like. For example two links may be pointing to the same
document but one link may have a different alias or target. The handler decides
what to do in these cases.currentSpace
- the space to use for normalizing links. This is used for links that have
no space defined.
- Returns:
- a list of
Link
objects containing the parsed links, a list of invalid
link contents found and a list of replaced links, returned as a
ReplacementResultCollection
. This allows users of this method to decide what
they want to do with invalid links (like report them to the user, fix them, generate
an error, etc).
Copyright © 2004-2013 XWiki. All Rights Reserved.