public class DocumentParser extends Object implements ContentParser
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.
Constructor and Description |
---|
DocumentParser() |
Modifier and Type | Method and Description |
---|---|
ParsingResultCollection |
parseLinks(String contentToParse)
Parse the links contained into the passed content represent the raw content from a document
(as typed by the user).
|
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.
|
public ParsingResultCollection parseLinks(String contentToParse)
contentToParse
- the raw document content to parse.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).public ReplacementResultCollection parseLinksAndReplace(String contentToParse, Link linkToLookFor, Link newLink, ReplaceLinkHandler linkHandler, String currentSpace)
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.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–2014 XWiki. All rights reserved.