public class WikiModel extends AbstractWikiModel
IConfiguration.Casing
Modifier and Type | Field and Description |
---|---|
protected Map<String,String> |
categories
A map for categories and their associated sort keys
|
protected Set<String> |
includes |
protected Set<String> |
links |
protected List<SemanticAttribute> |
semanticAttributes |
protected List<SemanticRelation> |
semanticRelations |
protected Set<String> |
templates |
attributes, fExternalLinksCounter, fLocale, fNamespace, fNamespaceName, fNoToc, fPageTitle, fParameterParsingMode, fRecursionLevel, fRedirectLink, fReferenceNames, fReferences, fSectionCounter, fTagStack, fTemplateRecursionCount, fTemplates, fTemplateTopic, fToCSet, logger
Constructor and Description |
---|
WikiModel(Configuration configuration,
Locale locale,
INamespace namespace,
String imageBaseURL,
String linkBaseURL) |
WikiModel(Configuration configuration,
Locale locale,
String imageBaseURL,
String linkBaseURL) |
WikiModel(Configuration configuration,
String imageBaseURL,
String linkBaseURL) |
WikiModel(String imageBaseURL,
String linkBaseURL) |
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.
|
void |
appendInternalLink(String topic,
String hashSection,
String topicDescription,
String cssClass,
boolean parseRecursive)
Append an internal wikilink as described in Help Links
|
protected void |
appendInternalLink(String topic,
String hashSection,
String topicDescription,
String cssClass,
boolean parseRecursive,
boolean topicExists) |
protected String |
createImageName(ImageFormat imageFormat) |
Map<String,String> |
getCategories()
Get the set of Wikipedia category names used in this text
|
String |
getImageBaseURL()
Return a URL string which contains a "${image}" variable, which
will be replaced by the image name, to create links to images.
|
Set<String> |
getIncludes()
Gets the names of all included pages outside the template namespace.
|
Set<String> |
getLinks()
Get the set of Wikipedia links used in this text
|
INamespace |
getNamespace()
Get the namespace of this model.
|
List<SemanticAttribute> |
getSemanticAttributes()
Get the list of SemanticAttributes
|
List<SemanticRelation> |
getSemanticRelations()
Get the list of SemanticRelations.
|
Set<String> |
getTemplates()
Gets the names of all included pages in the template namespace.
|
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.
|
void |
parseInternalImageLink(String imageNamespace,
String rawImageLink)
Append the internal wiki image link to this model.
|
boolean |
replaceColon()
Replace a colon ':' with a slash '/' in wiki names (i.e. links,
categories, templates)
|
void |
setUp()
Prepare or initialize the wiki model before rendering the wikipedia text
|
static String |
toHtml(String rawWikiText)
Convert a given text in wiki notation into HTML text.
|
static void |
toHtml(String rawWikiText,
Appendable resultBuffer)
Convert a given text in wiki notation into HTML text.
|
static void |
toHtml(String rawWikiText,
Appendable resultBuffer,
String imageBaseURL,
String linkBaseURL)
Convert a given text in wiki notation into HTML text.
|
static void |
toText(IWikiModel model,
ITextConverter converter,
String rawWikiText,
Appendable resultBuffer,
boolean templateTopic,
boolean parseTemplates)
Convert a given text in wiki notation into another format.
|
addCodeFormatter, addInterwikiLink, addTemplateFunction, addTokenTag, addToReferences, addToTableOfContent, append, appendExternalImageLink, appendExternalLink, appendHead, appendInternalImageLink, appendInterWikiLink, appendISBNLink, appendMailtoLink, appendRawNamespaceLinks, appendRawWikipediaLink, appendRedirectLink, appendSignature, appendStack, buildEditLinkUrl, casing, createNewInstance, createScribuntoEngine, createTableOfContent, decrementRecursionLevel, decrementTemplateRecursionLevel, encodeTitleDotUrl, encodeTitleToUrl, getAttribute, getAttributeRenderer, getCodeFormatterMap, getCurrentTimeStamp, getFrame, getInterwikiMap, getLocale, getMagicWord, getNamespaceName, getNextNumber, getNode, getPageName, getRawWikiContent, getRecursionLevel, getRedirectLink, getReferences, getResourceBundle, getSimpleDateFormat, getTableOfContent, getTemplateCallsCache, getTemplateFunction, getTemplateMap, getTokenMap, getUriSchemeSet, getWikiBaseEditURL, getWikiListener, incrementRecursionLevel, incrementTemplateRecursionLevel, initialize, isCamelCaseEnabled, isEditorMode, isInterWiki, isMathtranRenderer, isNamespace, isNoToc, isParameterParsingMode, isPreviewMode, isSemanticWebActive, isTemplateTopic, isValidUriScheme, isValidUriSchemeSpecificPart, parseBehaviorSwitch, parseEvents, parseTemplates, parseTemplates, peekNode, popNode, pushNode, rawSetAttribute, reduceTokenStack, registerRenderer, render, render, render, render, render, renderPDF, setAttribute, setAttributeRenderers, setDefaultThumbWidth, setFrame, setNamespaceName, setNoToc, setPageName, setParameterParsingMode, setSemanticWebActive, setTemplateCallsCache, showSyntax, splitNsTitle, stackSize, substituteTemplateCall, swapStack, tearDown
protected Map<String,String> categories
protected List<SemanticRelation> semanticRelations
protected List<SemanticAttribute> semanticAttributes
public WikiModel(String imageBaseURL, String linkBaseURL)
imageBaseURL
- a url string which must contains a "${image}"
variable which will be replaced by the image name, to create
links to images.linkBaseURL
- a url string which must contains a "${title}"
variable which will be replaced by the topic title, to create
links to other wiki topics.public WikiModel(Configuration configuration, String imageBaseURL, String linkBaseURL)
public WikiModel(Configuration configuration, Locale locale, String imageBaseURL, String linkBaseURL)
public WikiModel(Configuration configuration, Locale locale, INamespace namespace, String imageBaseURL, String linkBaseURL)
public void addCategory(String categoryName, String sortKey)
IWikiModel
sortKey
see also Wikipedia:Categorization#Category_sortingaddCategory
in interface IWikiModel
addCategory
in class AbstractWikiModel
categoryName
- 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".public void addLink(String topicName)
IWikiModel
addLink
in interface IWikiModel
addLink
in class AbstractWikiModel
topicName
- The name of the topic that is linked to.public boolean addSemanticAttribute(String attribute, String attributeValue)
IWikiModel
addSemanticAttribute
in interface IWikiModel
addSemanticAttribute
in class AbstractWikiModel
public boolean addSemanticRelation(String relation, String relationValue)
IWikiModel
addSemanticRelation
in interface IWikiModel
addSemanticRelation
in class AbstractWikiModel
public void addTemplate(String template)
IWikiModel
addTemplate
in interface IWikiModel
addTemplate
in class AbstractWikiModel
template
- The name of the template that is being included (excluding the
template namespace).public void addInclude(String pageName)
IWikiModel
addInclude
in interface IWikiModel
addInclude
in class AbstractWikiModel
pageName
- The name of the page that is being included (including its
namespace).IWikiModel.addTemplate(String)
public void appendInternalLink(String topic, String hashSection, String topicDescription, String cssClass, boolean parseRecursive)
IWikiModel
appendInternalLink
in interface IWikiModel
appendInternalLink
in class AbstractWikiModel
cssClass
- the links CSS class styleparseRecursive
- TODOprotected void appendInternalLink(String topic, String hashSection, String topicDescription, String cssClass, boolean parseRecursive, boolean topicExists)
public Map<String,String> getCategories()
public Set<String> getLinks()
public List<SemanticAttribute> getSemanticAttributes()
IWikiModel
getSemanticAttributes
in interface IWikiModel
getSemanticAttributes
in class AbstractWikiModel
null
if no
SemanticAttribute existspublic List<SemanticRelation> getSemanticRelations()
IWikiModel
getSemanticRelations
in interface IWikiModel
getSemanticRelations
in class AbstractWikiModel
null
if no
SemanticRelation existspublic Set<String> getTemplates()
public Set<String> getIncludes()
public void parseInternalImageLink(String imageNamespace, String rawImageLink)
rawImageLink
into different segments. The first segment is
used as the <image-name>
and typically ends with
extensions like .png
, .gif
, .jpg
or .jpeg
.
<size>px-<image-name>
,
otherwise it's only the <image-name>
.
imageNamespace
- the image namespacerawImageLink
- the raw image link text without the surrounding
[[...]]
protected String createImageName(ImageFormat imageFormat)
public boolean replaceColon()
IWikiModel
replaceColon
in interface IWikiModel
replaceColon
in class AbstractWikiModel
public void setUp()
IWikiModel
setUp
in interface IWikiModel
setUp
in class AbstractWikiModel
public INamespace getNamespace()
IWikiModel
public static void toText(IWikiModel model, ITextConverter converter, String rawWikiText, Appendable resultBuffer, boolean templateTopic, boolean parseTemplates) throws IOException
model
- a wiki modelconverter
- 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 textresultBuffer
- the buffer to which to append the resulting HTML code.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.parseTemplates
- parses the template expansion step (parses include,
onlyinclude, includeonly etc)IOException
public static void toHtml(String rawWikiText, Appendable resultBuffer, String imageBaseURL, String linkBaseURL) throws IOException
rawWikiText
- a raw wiki textresultBuffer
- the buffer to which to append the resulting HTML code.imageBaseURL
- a url string which must contains a "${image}"
variable which will be replaced by the image name, to create
links to images.linkBaseURL
- a url string which must contains a "${title}"
variable which will be replaced by the topic title, to create
links to other wiki topics.IOException
public static void toHtml(String rawWikiText, Appendable resultBuffer) throws IOException
rawWikiText
- a raw wiki textresultBuffer
- the buffer to which to append the resulting HTML code.IOException
public static String toHtml(String rawWikiText)
rawWikiText
- a raw wiki textnull
, if an
IOException
occured.public String getImageBaseURL()
IWikiModel
getImageBaseURL
in interface IWikiModel
getImageBaseURL
in class AbstractWikiModel
IWikiModel.getWikiBaseURL()
,
IWikiModel.getWikiBaseEditURL()
public String getWikiBaseURL()
IWikiModel
http://en.wikipedia.org/wiki/${title}
getWikiBaseURL
in interface IWikiModel
getWikiBaseURL
in class AbstractWikiModel
IWikiModel.getImageBaseURL()
,
IWikiModel.getWikiBaseEditURL()
Copyright © 2016 Java Wikipedia API (Bliki engine). All rights reserved.