public interface IWikiModel extends IConfiguration
IConfiguration.Casing
Modifier and Type | Method and Description |
---|---|
void |
addCategory(String categoryName,
String sortKey)
When an article contains a token indicating that the article belongs to a
specific category this method should be called to add that category to
the output metadata.
|
void |
addInclude(String pageName)
When a document contains a token indicating that the document includes an
other Wiki page, i.e. transclusion, this method should be called to add
that page to the output metadata.
|
void |
addLink(String topicName)
When a document contains a token indicating that the document links to
another Wiki topic this method should be called to add that topic link to
the output metadata.
|
boolean |
addSemanticAttribute(String attribute,
String attributeValue)
See Semantic
MediaWiki for more information.
|
boolean |
addSemanticRelation(String relation,
String relationValue)
See Semantic
MediaWiki for more information.
|
void |
addTemplate(String template)
When a document contains a token indicating that the document includes a
Wiki template this method should be called to add that template to the
output metadata.
|
String[] |
addToReferences(String reference,
String nameAttribute)
Add a reference (i.e. footnote) to the internal list
|
void |
append(BaseToken contentNode)
Append the content as a child on the top node of the internal stack
|
void |
appendExternalImageLink(String imageSrc,
String imageAltText)
Append an external wiki image link (starting with http, https,... and
ending with gif, png, jpg, bmp)
|
void |
appendExternalLink(String uriSchemeName,
String link,
String linkName,
boolean withoutSquareBrackets)
Append an external link (starting with http, https, ftp,...) as described
in Help
Links
|
ITableOfContent |
appendHead(String rawHead,
int headLevel,
boolean noToC,
int headCounter,
int startPosition,
int endPosition)
Add a single wiki head (i.e. ==...==, ===...===, ====...====,...) to the
table of content
|
void |
appendInternalImageLink(String hrefImageLink,
String srcImageLink,
ImageFormat imageFormat)
Append this internal wiki image link.
|
void |
appendInternalLink(String topic,
String hashSection,
String topicDescription,
String cssClass,
boolean parseRecursive)
Append an internal wikilink as described in Help Links
|
void |
appendInterWikiLink(String namespace,
String title,
String linkText)
Append an InterWiki link
|
void |
appendISBNLink(String isbnPureText)
Append an external ISBN link (starting with
ISBN ) as
described in Wikipedia:ISBN
Note: The default implementation in the AbstractWikiModel class creates a link to Amazon.com. |
void |
appendMailtoLink(String link,
String linkName,
boolean withoutSquareBrackets)
Append an external link (starting with mailto:...) as described in Help:Wikitext#Links
|
boolean |
appendRawNamespaceLinks(String rawNamespaceTopic,
String viewableLinkDescription,
boolean containsNoPipe)
Check if the topic is a special namespace topic.
|
boolean |
appendRawWikipediaLink(String rawLinkText,
String suffix)
Main entry method for parsing a raw wiki link (i.e. the text between the
[[...]] square brackets).
|
boolean |
appendRedirectLink(String redirectLink)
Append the redirect link to the model
|
void |
appendSignature(Appendable writer,
int numberOfTildes)
Append the user signature to the writer (i.e. '~~~', '~~~~' or '~~~~').
|
void |
appendStack(TagStack stack)
Append the given tag stack to the current tag stack of the model.
|
void |
buildEditLinkUrl(int section)
Build the link to edit a section of the wikipedia article
|
AbstractWikipediaParser |
createNewInstance(String rawWikitext)
Create a new parser instance
|
ScribuntoEngine |
createScribuntoEngine() |
ITableOfContent |
createTableOfContent(boolean isTOCIdentifier)
Create the "table of content" placeholder
|
int |
decrementRecursionLevel()
Decrement the current recursion level of the parser.
|
int |
decrementTemplateRecursionLevel()
Decrement the current template recursion level of the temlate parser.
|
String |
encodeTitleDotUrl(String wikiTitle,
boolean firstCharacterAsUpperCase)
Encode the wiki links title into a URL for HTML hyperlinks (i.e.
|
String |
encodeTitleToUrl(String wikiTitle,
boolean firstCharacterAsUpperCase)
Encode the wiki links title into a URL for HTML hyperlinks (i.e.
|
Date |
getCurrentTimeStamp()
Get the current time stamp.
|
Frame |
getFrame() |
String |
getImageBaseURL()
Return a URL string which contains a "${image}" variable, which
will be replaced by the image name, to create links to images.
|
InterWikiMap |
getInterwikiMap()
Get the
interwiki links
map for converting interwiki links into external URLs.
|
Set<String> |
getLinks()
Get the set of Wikipedia link names
|
Locale |
getLocale()
Get the locale of this model.
|
Object |
getMagicWord(String name)
Gets the magic word object for the given string.
|
INamespace |
getNamespace()
Get the namespace of this model.
|
String |
getNamespaceName()
Get the namespace name of this model for the current locale.
|
int |
getNextNumber()
Get the next unique number
|
TagToken |
getNode(int offset)
Get the node at the given offset on the internal stack For example
getNode(fWikiModel.stackSize() - 2) returns the node before
the node at top of the stack. |
String |
getPageName()
Get the title of the current wiki article.
|
String |
getRawWikiContent(ParsedPageName templateName,
Map<String,String> templateParameters)
Get the raw wiki text for the given namespace and article name
|
int |
getRecursionLevel()
Get the current recursion level of the parser.
|
String |
getRedirectLink()
Get the redirect link.
|
List<Reference> |
getReferences()
Get the internal list of references (i.e. footnotes)
|
ResourceBundle |
getResourceBundle()
Get the resource bundle associated with this model for I18N support
|
List<SemanticAttribute> |
getSemanticAttributes()
Get the list of SemanticAttributes
|
List<SemanticRelation> |
getSemanticRelations()
Get the list of SemanticRelations.
|
SimpleDateFormat |
getSimpleDateFormat()
Get a simple date formatter.
|
ITableOfContent |
getTableOfContent()
Get the parsed "table of content" data after parsing the
Wikipedia text.
|
ITemplateFunction |
getTemplateFunction(String name)
Get a template parser function (i.e.
|
String |
getWikiBaseEditURL()
Return a URL string which contains, a "${title}" variable which
will be replaced by the topic title, to create links edit pages of wiki
topics.
|
String |
getWikiBaseURL()
Return a URL string which contains, a "${title}" variable which
will be replaced by the topic title, to create links to other wiki
topics.
|
IEventListener |
getWikiListener()
Get the current defined wiki listener
|
int |
incrementRecursionLevel()
Increment the current recursion level of the parser.
|
int |
incrementTemplateRecursionLevel()
Increment the current recursion level of the template parser.
|
boolean |
isCamelCaseEnabled()
Checks if CamelCase
words should also be used as wiki links.
|
boolean |
isEditorMode()
The current model is used to render a wikipage in editor mode
|
boolean |
isInterWiki(String namespace)
Check if the given namespace is an interwiki link prefix.
|
boolean |
isMathtranRenderer()
|
boolean |
isNamespace(String namespace)
Check if the given namespace is a namespace in this model
|
boolean |
isNoToc()
Check if the rendering of the "table of contents" is disabled
globally.
|
boolean |
isParameterParsingMode()
The current model currently renders a template parameter value
|
boolean |
isPreviewMode()
The current model is used to render a wikipage in preview mode
|
boolean |
isSemanticWebActive()
Allow the parsing of semantic mediawiki (SMW) links.
|
boolean |
isTemplateTopic()
Determine if the currently parsed wiki text is a template.
|
boolean |
isValidUriScheme(String uriScheme)
Check if the top level URI (Uniform Resource Identifier) scheme name is
valid in this model.
|
boolean |
isValidUriSchemeSpecificPart(String uriScheme,
String uriSchemeSpecificPart)
Check if the scheme-specific part for a given top level URI (Uniform
Resource Identifier) scheme name is valid in this model.
|
boolean |
parseBehaviorSwitch(String identifier)
Parse a behavior switch (i.e. an identifier with two leading and trailing
underscores "__" like for example
__NOEDITSECTION__ ). |
void |
parseEvents(IEventListener listener,
String rawWikiText)
Parse the raw Wikipedia text and notify the listener
|
void |
parseInternalImageLink(String imageNamespace,
String rawImageLink)
Append the internal wiki image link to this model.
|
String |
parseTemplates(String rawWikiText)
Parse the templates in a raw wikipedia text into a resulting wikipedia
text.
|
String |
parseTemplates(String rawWikiText,
boolean parseOnlySignature)
Parse the templates in a raw wikipedia text into a resulting wikipedia
text.
|
TagToken |
peekNode()
Get the current TagNode on top of the internal stack
|
TagToken |
popNode()
Pop the current TagNode from top of the internal stack
|
boolean |
pushNode(TagToken node)
Push the given TagNode on top of the internal stack
|
void |
reduceTokenStack(TagToken node)
Reduce the current token stack until an allowed parent is at the top of
the stack
|
String |
render(ITextConverter converter,
String rawWikiText)
Render the raw Wikipedia text into a string for a given converter
|
void |
render(ITextConverter converter,
String rawWikiText,
Appendable buffer,
boolean templateTopic,
boolean parseTemplates)
Render the raw Wikipedia text into a string for a given converter
|
String |
render(ITextConverter converter,
String rawWikiText,
boolean templateTopic)
Render the raw Wikipedia text into a string for a given converter
|
String |
render(String rawWikiText)
Render the raw Wikipedia text into an HTML string and use the default
HTMLConverter
|
String |
render(String rawWikiText,
boolean templateTopic)
Render the raw Wikipedia text into an HTML string and use the default
HTMLConverter
|
String |
renderPDF(String rawWikiText)
Render the raw Wikipedia text into an HTML string and use the default
PDFConverter.
|
boolean |
replaceColon()
Replace a colon ':' with a slash '/' in wiki names (i.e. links,
categories, templates)
|
void |
setFrame(Frame frame) |
void |
setNamespaceName(String namespaceLowercase)
Set the "lower-case" namespace name of the article rendered with this
model.
|
void |
setNoToc(boolean disableToc)
Set to
true if the rendering of the "table of
contents" should be disabled globally. |
void |
setPageName(String pageTitle)
Set the title of the currently rendered page data.
|
void |
setParameterParsingMode(boolean parameterParsingMode)
Activate the mode for rendering a template parameter value
|
void |
setSemanticWebActive(boolean semanticWeb)
Activate the parsing of semantic Mediawiki (SMW) links See Semantic
MediaWiki for more information.
|
void |
setUp()
Prepare or initialize the wiki model before rendering the wikipedia text
|
boolean |
showSyntax(String tagName)
Show the syntax highlighting of the source code
|
String[] |
splitNsTitle(String fullTitle)
Splits the given full title into its namespace and page title components
and normalises both components using
Encoder#normaliseTitle(String, boolean, char) keeping
underscores. |
int |
stackSize()
The size of the internal stack
|
void |
substituteTemplateCall(String templateName,
Map<String,String> parameterMap,
Appendable writer)
Substitute the template name by the template content and parameters and
append the new content to the writer.
|
TagStack |
swapStack(TagStack stack) |
void |
tearDown()
Clean up (i.e. free internal resources) in the wiki model after rendering
the wikipedia text, if necessary
|
addCodeFormatter, addInterwikiLink, addTemplateFunction, addTokenTag, casing, getCodeFormatterMap, getTemplateCallsCache, getTemplateMap, getTokenMap, getUriSchemeSet, setTemplateCallsCache
void addCategory(String categoryName, String sortKey)
sortKey
see also Wikipedia:Categorization#Category_sortingcategoryName
- The name of the category that the document belongs to.sortKey
- The sort key for the category, or null
if no sort
key has been specified. The sort key determines what order
categories are sorted on category index pages, so a category
for "John Doe" might be given a sort key of "Doe, John".void addLink(String topicName)
topicName
- The name of the topic that is linked to.boolean addSemanticAttribute(String attribute, String attributeValue)
attribute
- attributeValue
- boolean addSemanticRelation(String relation, String relationValue)
relation
- relationValue
- void addTemplate(String template)
template
- The name of the template that is being included (excluding the
template namespace).void addInclude(String pageName)
pageName
- The name of the page that is being included (including its
namespace).addTemplate(String)
String[] addToReferences(String reference, String nameAttribute)
reference
- the rendered HTML code of the ref-Tag bodynameAttribute
- the value of the name
attribute or
null
void append(BaseToken contentNode)
contentNode
- void appendExternalImageLink(String imageSrc, String imageAltText)
imageSrc
- hashSection
- imageAltText
- void appendExternalLink(String uriSchemeName, String link, String linkName, boolean withoutSquareBrackets)
uriSchemeName
- the top level URI (Uniform Resource Identifier) scheme name
(without the following colon character ":"). Example "ftp",
"http", "https". See URI schemelink
- the external link with
http://, https:// or ftp://
prefixlinkName
- the link name which is separated from the URL by a spacewithoutSquareBrackets
- if true
a link with no square brackets around the
link was parsedITableOfContent appendHead(String rawHead, int headLevel, boolean noToC, int headCounter, int startPosition, int endPosition)
rawHead
- the unparsed header stringheadLevel
- level of header (i.e. h1, h2, h3, h4, 5h,..)noToc
- don't show the "table of content"headCounter
- the total number of headers parsedstartPosition
- the start index in the text where the header line of the
section beginsendPosition
- the start index in the text where the header line of the
section endsvoid appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat)
HTMLConverter#imageNodeToText()
method.hrefImageLink
- srcImageLink
- imageFormat
- void appendInternalLink(String topic, String hashSection, String topicDescription, String cssClass, boolean parseRecursive)
topic
- hashSection
- topicDescription
- cssClass
- the links CSS class styleparseRecursive
- TODOvoid appendInterWikiLink(String namespace, String title, String linkText)
namespace
- title
- linkText
- void appendISBNLink(String isbnPureText)
ISBN
) as
described in Wikipedia:ISBN
AbstractWikiModel
class creates a link to Amazon.com.isbnPureText
- the pure ISBN string which contains the ISBN prefix and
optional dashes in the ISBN numbervoid appendMailtoLink(String link, String linkName, boolean withoutSquareBrackets)
link
- the external link with mailto:
prefixlinkName
- the link name which is separated from the URL by a spacewithoutSquareBrackets
- if true
a mailto link with no square brackets
around the link was parsedboolean appendRawNamespaceLinks(String rawNamespaceTopic, String viewableLinkDescription, boolean containsNoPipe)
AbstractWikiModel
defaults implementation this namespace
topic is parsed and checks for various namespaces, like
Categories
and Interwiki
links.rawNamespaceTopic
- the text between the [[...]] square brackets of a wiki link
before the pipe symbolviewableLinkDescription
- containsNoPipe
- set to true
if the rawLinkText contained no pipe
symbol.true
if the topic is a special namespace topicboolean appendRawWikipediaLink(String rawLinkText, String suffix)
AbstractWikiModel
defaults
implementation this link is parsed and the various other
append...
methods of the model are called for the different
cases.rawLinkText
- the text between the [[...]] square brackets of a wiki linksuffix
- a String of lowercase letters which directly follow the link
after the closing ]] brackets. Useful for topic plurals.true
if the method used the suffix for rendering the
wiki link. If false
the parser should append the
suffix as normal text after the wiki link (i.e. in the case of an
image of file wiki link).boolean appendRedirectLink(String redirectLink)
redirectLink
- the raw string between the wikilink tags [[ ]]
true
if the the wikitext shouldn't be parsedvoid appendSignature(Appendable writer, int numberOfTildes) throws IOException
writer
- numberOfTildes
- an int
value between 3 and 5IOException
void appendStack(TagStack stack)
stack
- void buildEditLinkUrl(int section)
section
- AbstractWikipediaParser createNewInstance(String rawWikitext)
rawWikitext
- ITableOfContent createTableOfContent(boolean isTOCIdentifier)
isTOCIdentifier
- true
if the __TOC__ keyword was parsedint decrementRecursionLevel()
int decrementTemplateRecursionLevel()
String encodeTitleDotUrl(String wikiTitle, boolean firstCharacterAsUpperCase)
firstCharacterAsUpperCase
parameters must be set to
true
. For an example encoding routine see:
Encoder.encodeTitleDotUrl(String, boolean)
firstCharacterAsUpperCase
- if true
convert the first of the title to uppercaseEncoder.encodeTitleToUrl(String, boolean)
String encodeTitleToUrl(String wikiTitle, boolean firstCharacterAsUpperCase)
firstCharacterAsUpperCase
parameters must be set to
true
. For an example encoding routine see
Encoder.encodeTitleToUrl(String, boolean)
firstCharacterAsUpperCase
- if true
convert the first of the title to uppercaseEncoder.encodeTitleToUrl(String, boolean)
Date getCurrentTimeStamp()
new Date(System.currentTimeMillis());
.String getImageBaseURL()
getWikiBaseURL()
,
getWikiBaseEditURL()
Set<String> getLinks()
Set
of link names 8i.e. [[...]] links)InterWikiMap getInterwikiMap()
Locale getLocale()
INamespace getNamespace()
String getNamespaceName()
int getNextNumber()
int
number.TagToken getNode(int offset)
getNode(fWikiModel.stackSize() - 2)
returns the node before
the node at top of the stack.offset
- Frame getFrame()
void setFrame(Frame frame)
ScribuntoEngine createScribuntoEngine()
String getPageName()
@Nullable String getRawWikiContent(ParsedPageName templateName, Map<String,String> templateParameters) throws WikiModelContentException
templateName
- the parsed template nametemplateParameters
- if the namespace is the Template namespace, the current
template parameters are stored as String
s in this
mapnull
if no content was foundWikiModelContentException
AbstractParser#parsePageName(IWikiModel, String, INamespaceValue,
boolean)
int getRecursionLevel()
String getRedirectLink()
[[ ]]
or
null
if no redirect existsList<Reference> getReferences()
null
if no reference
existsReference
ResourceBundle getResourceBundle()
List<SemanticAttribute> getSemanticAttributes()
null
if no
SemanticAttribute existsList<SemanticRelation> getSemanticRelations()
null
if no
SemanticRelation existsSimpleDateFormat getSimpleDateFormat()
ITableOfContent getTableOfContent()
ITemplateFunction getTemplateFunction(String name)
{{ #if: ... }}
)
implementation.name
- the name of the function without the "#" and
":" delimitersnull
if no function is
available for the given nameString getWikiBaseEditURL()
http://en.wikipedia.org/w/index.php?title=${title}
getWikiBaseURL()
,
getImageBaseURL()
String getWikiBaseURL()
http://en.wikipedia.org/wiki/${title}
getImageBaseURL()
,
getWikiBaseEditURL()
IEventListener getWikiListener()
null
if no listener is definedint incrementRecursionLevel()
int incrementTemplateRecursionLevel()
boolean isCamelCaseEnabled()
true
if CamelCase words should also be used as wiki
linksboolean isEditorMode()
true
if your model is used in an editor modeboolean isNoToc()
true
if the rendering of the "table of
contents" is disabled globally.boolean isInterWiki(String namespace)
namespace
- true
if the namespace is a interwiki namespace (i.e.
prefix).boolean isMathtranRenderer()
true
the <math>
tag should be
rendered fro mathtran.org.boolean isNamespace(String namespace)
namespace
- true
if the namespace is a namespace in this modelboolean isParameterParsingMode()
true
if your model renders a template parameter
valueboolean isPreviewMode()
true
if your model is used in a preview modeboolean isSemanticWebActive()
namespace
- true
if parsing of semantic mediawiki (SMW) links is
enabledboolean isTemplateTopic()
true
if the currently parsed wiki text is a
template.boolean isValidUriScheme(String uriScheme)
uriScheme
- the top level URI (Uniform Resource Identifier) scheme name
(without the following colon character ":")true
if the specified URI scheme is valid.isValidUriSchemeSpecificPart(String, String)
boolean isValidUriSchemeSpecificPart(String uriScheme, String uriSchemeSpecificPart)
uriScheme
- the top level URI (Uniform Resource Identifier) scheme name
(without the following colon character ":")uriSchemeSpecificPart
- the URI (Uniform Resource Identifier) scheme part following
the top level scheme name and the colon character ":"true
if the specified URI scheme is valid.isValidUriScheme(String)
boolean parseBehaviorSwitch(String identifier)
__NOEDITSECTION__
). See Help
:Magic_words#Behavior_switches.identifier
- the identifier without the leading and trailing underscores
("__")true
if the switch was parsedvoid parseEvents(IEventListener listener, String rawWikiText)
listener
- an event listenerrawWikiText
- the raw wiki textvoid parseInternalImageLink(String imageNamespace, String rawImageLink)
imageNamespace
- the image namespacerawImageLink
- the raw image link text without the surrounding
[[...]]
String parseTemplates(String rawWikiText)
rawWikiText
- String parseTemplates(String rawWikiText, boolean parseOnlySignature)
rawWikiText
- parseOnlySignature
- if true
parse only the signature wiki texts, no
templates and wiki comment parsingTagToken peekNode()
TagToken popNode()
boolean pushNode(TagToken node)
true
if the push on the internal stack was
successfulvoid reduceTokenStack(TagToken node)
String render(ITextConverter converter, String rawWikiText) throws IOException
converter
- a text converter. Note the converter may be
null
, if you only would like to analyze the raw
wiki text and don't need to convert. This speeds up the
parsing process.rawWikiText
- a raw wiki textIOException
void render(ITextConverter converter, String rawWikiText, Appendable buffer, boolean templateTopic, boolean parseTemplates) throws IOException
converter
- a text converter. Note the converter may be
null
, if you only would like to analyze the raw
wiki text and don't need to convert. This speeds up the
parsing process.rawWikiText
- a raw wiki textbuffer
- write to this buffertemplateTopic
- if true
, render the wiki text as if a template
topic will be displayed directly, otherwise render the text as
if a common wiki topic will be displayed.parseTemplates
- parses the template expansion step (parses include,
onlyinclude, includeonly etc)IOException
String render(ITextConverter converter, String rawWikiText, boolean templateTopic) throws IOException
converter
- a text converter. Note the converter may be
null
, if you only would like to analyze the raw
wiki text and don't need to convert. This speeds up the
parsing process.rawWikiText
- a raw wiki texttemplateTopic
- if true
, render the wiki text as if a template
topic will be displayed directly, otherwise render the text as
if a common wiki topic will be displayed.null
if an IOException occurs or
converter==null
IOException
String render(String rawWikiText) throws IOException
IOException
String render(String rawWikiText, boolean templateTopic) throws IOException
rawWikiText
- templateTopic
- if true
, render the wiki text as if a template
topic will be displayed directly, otherwise render the text as
if a common wiki topic will be displayed.IOException
String renderPDF(String rawWikiText) throws IOException
rawWikiText
- null
if an IOException occursIOException
boolean replaceColon()
void setNamespaceName(String namespaceLowercase)
namespaceLowercase
- the lowercase key for the namespace.Locale
,
Namespace.getNamespace(String)
void setNoToc(boolean disableToc)
true
if the rendering of the "table of
contents" should be disabled globally.disableToc
- set to true
if the rendering of the "table
of contents" should be disabled globally.void setPageName(String pageTitle)
pageTitle
- void setParameterParsingMode(boolean parameterParsingMode)
void setSemanticWebActive(boolean semanticWeb)
void setUp()
boolean showSyntax(String tagName)
int stackSize()
void substituteTemplateCall(String templateName, Map<String,String> parameterMap, Appendable writer) throws IOException
templateName
- the name of the templateparameterMap
- the templates parameter java.util.SortedMap
writer
- the buffer to append the substituted template contentIOException
void tearDown()
@Nullable Object getMagicWord(String name)
name
- the (potential) magic wordMagicWord.MagicWordE
in case
MagicWord
is used) or
null if this is no valid magic wordString[] splitNsTitle(String fullTitle)
Encoder#normaliseTitle(String, boolean, char)
keeping
underscores.fullTitle
- the (full) title including a namespace (if present)Copyright © 2016 Java Wikipedia API (Bliki engine). All rights reserved.