info.bliki.wiki.model
Class AbstractWikiModel

java.lang.Object
  extended by info.bliki.wiki.model.AbstractWikiModel
All Implemented Interfaces:
IConfiguration, IContext, IWikiModel
Direct Known Subclasses:
WikiModel

public abstract class AbstractWikiModel
extends java.lang.Object
implements IWikiModel, IContext

Standard model implementation for the Wikipedia syntax


Field Summary
protected  java.util.Map<java.lang.Class,java.lang.Object> attributeRenderers
          A Map that allows people to register a renderer for a particular kind of object to be displayed in this template.
protected  java.util.Map<java.lang.String,java.lang.Object> attributes
          Map an attribute name to its value(s).
protected  INamespace fNamespace
           
protected  java.lang.String fPageTitle
           
protected  int fParserRecursionCount
           
protected  int fRecursionLevel
           
protected  java.lang.String fRedirectLink
           
protected  java.util.Map<java.lang.String,java.lang.Integer> fReferenceNames
           
protected  java.util.ArrayList<Reference> fReferences
           
protected  int fSectionCounter
           
protected  java.util.List<java.lang.Object> fTableOfContent
          "table of content"
protected  TableOfContentTag fTableOfContentTag
          A tag that manages the "table of content"
protected  TagStack fTagStack
           
protected  int fTemplateRecursionCount
           
protected  java.util.HashSet<java.lang.String> fToCSet
          Contains all anchor strings to create unique anchors
 
Constructor Summary
AbstractWikiModel()
           
AbstractWikiModel(Configuration configuration)
           
AbstractWikiModel(Configuration configuration, java.util.Locale locale)
           
AbstractWikiModel(Configuration configuration, java.util.Locale locale, java.util.ResourceBundle resourceBundle, INamespace namespace)
           
AbstractWikiModel(Configuration configuration, java.util.ResourceBundle resourceBundle, INamespace namespace)
          Deprecated. use the (Configuration configuration, Locale locale,...) constructors instead.
 
Method Summary
 void addCategory(java.lang.String categoryName, java.lang.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.
 SourceCodeFormatter addCodeFormatter(java.lang.String key, SourceCodeFormatter value)
          Add a new source code formatter to the configuration
 java.lang.String addInterwikiLink(java.lang.String key, java.lang.String value)
          Add another Interwiki link to the configuration.
 void addLink(java.lang.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(java.lang.String attribute, java.lang.String attributeValue)
          See Semantic MediaWiki for more information.
 boolean addSemanticRelation(java.lang.String relation, java.lang.String relationValue)
          See Semantic MediaWiki for more information.
 void addTemplate(java.lang.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.
 ITemplateFunction addTemplateFunction(java.lang.String key, ITemplateFunction value)
          Add a new interwiki link to the configuration
 TagToken addTokenTag(java.lang.String key, TagToken value)
          Add a new HTML styled tag to the configuration
 java.lang.String[] addToReferences(java.lang.String reference, java.lang.String nameAttribute)
          Add a reference (i.e. footnote) to the internal list
protected  void addToTableOfContent(java.util.List<java.lang.Object> toc, SectionHeader strPair, int headLevel)
          Add a section header with the given headLevel to the "table of content"
 void append(BaseToken contentNode)
          Append the content as a child on the top node of the internal stack
 void appendExternalImageLink(java.lang.String imageSrc, java.lang.String imageAltText)
          Append an external wiki image link (starting with http, https,... and ending with gif, png, jpg, bmp)
 void appendExternalLink(java.lang.String link, java.lang.String linkName, boolean withoutSquareBrackets)
          Deprecated. use IWikiModel.appendExternalLink(String, String, String, boolean) instead.
 void appendExternalLink(java.lang.String uriSchemeName, java.lang.String link, java.lang.String linkName, boolean withoutSquareBrackets)
          Append an external link (starting with http, https, ftp,...) as described in Help Links
 ITableOfContent appendHead(java.lang.String rawHead, int headLevel, boolean noToC, int headCounter)
          Add a single wiki head (i.e. ==...==, ===...===, ====...====,...) to the table of content
 ITableOfContent appendHead(java.lang.String rawHead, int headLevel, boolean noToC, int headCounter, int startPosition, int endPosition)
          Append a new head to the table of content
 void appendInternalImageLink(java.lang.String hrefImageLink, java.lang.String srcImageLink, ImageFormat imageFormat)
          Append this internal wiki image link.
 void appendInternalLink(java.lang.String topic, java.lang.String hashSection, java.lang.String topicDescription, java.lang.String cssClass, boolean parseRecursive)
          Append an internal wikilink as described in Help Links
 void appendInterWikiLink(java.lang.String namespace, java.lang.String title, java.lang.String linkText)
          Append an InterWiki link
 void appendISBNLink(java.lang.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(java.lang.String link, java.lang.String linkName, boolean withoutSquareBrackets)
          Append an external link (starting with mailto:...) as described in Help:Wikitext#Links
 boolean appendRawNamespaceLinks(java.lang.String rawNamespaceTopic, java.lang.String viewableLinkDescription, boolean containsNoPipe)
          Check if the topic is a special namespace topic.
 void appendRawWikipediaLink(java.lang.String rawLinkText, java.lang.String suffix)
          Main entry method for parsing a raw wiki link (i.e. the text between the [[...]] square brackets).
 boolean appendRedirectLink(java.lang.String redirectLink)
          Append the redirect link to the model
 void appendSignature(java.lang.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.
 TagNode appendToCAnchor(java.lang.String anchor)
          
 void buildEditLinkUrl(int section)
          Build the link to edit a section of the wikipedia article
 AbstractParser createNewInstance(java.lang.String rawWikitext)
          Create a new parser instance
 ITableOfContent createTableOfContent(boolean isTOCIdentifier)
          Create the "table of content" placeholder
 int decrementRecursionLevel()
          Decrement the current recursion level of the parser.
 java.lang.String encodeTitleDotUrl(java.lang.String wikiTitle, boolean firstCharacterAsUpperCase)
          Encode the wiki links title into a URL for HTML hyperlinks (i.e.
 java.lang.String encodeTitleToUrl(java.lang.String wikiTitle, boolean firstCharacterAsUpperCase)
          Encode the wiki links title into a URL for HTML hyperlinks (i.e.
 java.lang.String get2ndCategoryNamespace()
          Get the secondary namespace (i.e. the namespace for a non-englich locale) for categories in this wiki
 java.lang.String get2ndImageNamespace()
          Get the secondary namespace (i.e. the namespace for a non-englich locale) for images in this wiki
 java.lang.String get2ndTemplateNamespace()
          Get the secondary namespace (i.e. the namespace for a non-englich locale) for templates in this wiki
 java.lang.Object getAttribute(java.lang.String attribute)
          Resolve an attribute reference.
 AttributeRenderer getAttributeRenderer(java.lang.Class attributeClassType)
          What renderer is registered for this attributeClassType for this template.
 java.lang.String getCategoryNamespace()
          Get the primary namespace for categories in this wiki
 java.util.Map<java.lang.String,SourceCodeFormatter> getCodeFormatterMap()
          Get the source code formatter map of built-in source code formatters
 java.util.Date getCurrentTimeStamp()
          Get the current time stamp.
 java.lang.String getImageNamespace()
          Get the primary namespace for images in this wiki
 java.util.Map<java.lang.String,java.lang.String> getInterwikiMap()
          Get the interwiki links map for converting interwiki links into external URLs.
 java.util.Locale getLocale()
          Get the locale of this model.
 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.
 java.lang.String getPageName()
          Get the title of the current wiki article.
 java.lang.String getRawWikiContent(java.lang.String namespace, java.lang.String templateName, java.util.Map<java.lang.String,java.lang.String> templateParameters)
          Get the raw wiki text for the given namespace and article name
 int getRecursionLevel()
          Get the current recursion level of the parser.
 java.lang.String getRedirectLink()
          Get the redirect link.
 java.util.List<Reference> getReferences()
          Get the internal list of references (i.e. footnotes)
 java.util.ResourceBundle getResourceBundle()
          Get the resource bundle associated with this model for I18N support
 java.util.List<SemanticAttribute> getSemanticAttributes()
          Get the list of SemanticAttributes
 java.util.List<SemanticRelation> getSemanticRelations()
          Get the list of SemanticRelations.
 ITableOfContent getTableOfContent()
          Get the parsed "table of content" data after parsing the Wikipedia text.
 java.util.Map<java.lang.String,java.lang.String> getTemplateCallsCache()
          Get the currently configured cache implementation for template calls.
 ITemplateFunction getTemplateFunction(java.lang.String name)
          Get a template parser function (i.e.
 java.util.Map<java.lang.String,ITemplateFunction> getTemplateMap()
          Get the template parser functions map of built-in template functions
 java.lang.String getTemplateNamespace()
          Get the primary namespace for templates in this wiki model
 java.util.Map<java.lang.String,TagToken> getTokenMap()
          Get the HTML styled tag map for built-in tags
 java.util.Set<java.lang.String> getUriSchemeSet()
          Get the set of all allowed URI scheme shortcuts like http, https, ftp,...
 IEventListener getWikiListener()
          Get the current defined wiki listener
 int incrementParserRecursionCount()
          
 int incrementRecursionLevel()
          Increment the current recursion level of the parser.
 int incrementTemplateRecursionCount()
          
protected  void initialize()
          Initialize the internal class attributes
 boolean isCamelCaseEnabled()
          Checks if CamelCase words should also be used as wiki links.
 boolean isCategoryNamespace(java.lang.String namespace)
          Check if the given namespace is a category namespace
 boolean isEditorMode()
          The current model is used to render a wikipage in editor mode
 boolean isImageNamespace(java.lang.String namespace)
          Check if the given namespace is an image namespace
 boolean isInterWiki(java.lang.String namespace)
          Check if the given namespace is an interwiki link prefix.
 boolean isMathtranRenderer()
          If the <math> tag should be rendered for the www.mathtran.org service, then return true.
 boolean isNamespace(java.lang.String namespace)
          Check if the given namespace is a namespace in this model
 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 isTemplateNamespace(java.lang.String namespace)
          Check if the given namespace is a template namespace
 boolean isTemplateTopic()
          Determine if the currently parsed wiki text is a template.
 boolean isValidUriScheme(java.lang.String uriScheme)
          Check if the top level URI (Uniform Resource Identifier) scheme name is valid in this model.
 boolean isValidUriSchemeSpecificPart(java.lang.String uriScheme, java.lang.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 parseBBCodes()
          Parse BBCode (Bulletin Board Code), like syntax codes in this wiki.
 void parseEvents(IEventListener listener, java.lang.String rawWikiText)
          Parse the raw Wikipedia text and notify the listener
 java.lang.String parseTemplates(java.lang.String rawWikiText)
          Parse the templates in a raw wikipedia text into a resulting wikipedia text.
 java.lang.String parseTemplates(java.lang.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
protected  void rawSetAttribute(java.util.Map attributes, java.lang.String name, java.lang.Object value)
          Map a value to a named attribute.
 void registerRenderer(java.lang.Class attributeClassType, AttributeRenderer renderer)
          Register a renderer for all objects of a particular type.
 java.lang.String render(ITextConverter converter, java.lang.String rawWikiText)
          Render the raw Wikipedia text into a string for a given converter
 java.lang.String render(java.lang.String rawWikiText)
          Render the raw Wikipedia text into an HTML string and use the default HTMLConverter
 java.lang.String renderPDF(java.lang.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 setAttribute(java.lang.String name, java.lang.Object value)
          Set an attribute for this template.
 void setAttributeRenderers(java.util.Map renderers)
          Specify a complete map of what object classes should map to which renderer objects.
protected  void setDefaultThumbWidth(ImageFormat imageFormat)
          Set the default thumb format width.
 void setPageName(java.lang.String pageTitle)
          Set the title of the currently rendered page data.
 void setSemanticWebActive(boolean semanticWeb)
          Activate the parsing of semantic Mediawiki (SMW) links See Semantic MediaWiki for more information.
 void setTemplateCallsCache(java.util.Map<java.lang.String,java.lang.String> map)
          Set a cache map implementation.
 void setUp()
          Prepare or initialize the wiki model before rendering the wikipedia text
 boolean showSyntax(java.lang.String tagName)
          Show the syntax highlighting of the source code
 int stackSize()
          The size of the internal stack
 void substituteTemplateCall(java.lang.String templateName, java.util.Map<java.lang.String,java.lang.String> parameterMap, java.lang.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
 java.util.List<BaseToken> toNodeList(java.lang.String rawWikiText)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.bliki.wiki.model.IWikiModel
getLinks, getNamespace, parseInternalImageLink
 

Field Detail

fReferences

protected java.util.ArrayList<Reference> fReferences

fReferenceNames

protected java.util.Map<java.lang.String,java.lang.Integer> fReferenceNames

fRecursionLevel

protected int fRecursionLevel

fParserRecursionCount

protected int fParserRecursionCount

fTemplateRecursionCount

protected int fTemplateRecursionCount

fTagStack

protected TagStack fTagStack

fNamespace

protected INamespace fNamespace

fRedirectLink

protected java.lang.String fRedirectLink

fPageTitle

protected java.lang.String fPageTitle

fSectionCounter

protected int fSectionCounter

fTableOfContentTag

protected TableOfContentTag fTableOfContentTag
A tag that manages the "table of content"


fTableOfContent

protected java.util.List<java.lang.Object> fTableOfContent
"table of content"


fToCSet

protected java.util.HashSet<java.lang.String> fToCSet
Contains all anchor strings to create unique anchors


attributes

protected java.util.Map<java.lang.String,java.lang.Object> attributes
Map an attribute name to its value(s). These values are set by outside code via st.setAttribute(name, value). StringTemplate is like self in that a template is both the "class def" and "instance". When you create a StringTemplate or setTemplate, the text is broken up into chunks (i.e., compiled down into a series of chunks that can be evaluated later). You can have multiple


attributeRenderers

protected java.util.Map<java.lang.Class,java.lang.Object> attributeRenderers
A Map that allows people to register a renderer for a particular kind of object to be displayed in this template. This overrides any renderer set for this template's group. Most of the time this map is not used because the StringTemplateGroup has the general renderer map for all templates in that group. Sometimes though you want to override the group's renderers.

Constructor Detail

AbstractWikiModel

public AbstractWikiModel()

AbstractWikiModel

public AbstractWikiModel(Configuration configuration)

AbstractWikiModel

public AbstractWikiModel(Configuration configuration,
                         java.util.Locale locale)

AbstractWikiModel

public AbstractWikiModel(Configuration configuration,
                         java.util.ResourceBundle resourceBundle,
                         INamespace namespace)
Deprecated. use the (Configuration configuration, Locale locale,...) constructors instead.

Parameters:
configuration -
resourceBundle -
namespace -

AbstractWikiModel

public AbstractWikiModel(Configuration configuration,
                         java.util.Locale locale,
                         java.util.ResourceBundle resourceBundle,
                         INamespace namespace)
Method Detail

addCategory

public void addCategory(java.lang.String categoryName,
                        java.lang.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. For the sortKey see also Wikipedia:Categorization#Category_sorting

Specified by:
addCategory in interface IWikiModel
Parameters:
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".

addCodeFormatter

public SourceCodeFormatter addCodeFormatter(java.lang.String key,
                                            SourceCodeFormatter value)
Add a new source code formatter to the configuration

Specified by:
addCodeFormatter in interface IConfiguration
Returns:

addInterwikiLink

public java.lang.String addInterwikiLink(java.lang.String key,
                                         java.lang.String value)
Add another Interwiki link to the configuration. The value string must contain the ${title} placeholder for the used wiki article link.

Specified by:
addInterwikiLink in interface IConfiguration
Parameters:
key - the prefix used in the interwiki link (i.e. [[prefix:...]] )
value - the external link which should be generated from the interwiki link
Returns:

addLink

public void addLink(java.lang.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.

Specified by:
addLink in interface IWikiModel
Parameters:
topicName - The name of the topic that is linked to.

addSemanticAttribute

public boolean addSemanticAttribute(java.lang.String attribute,
                                    java.lang.String attributeValue)
See Semantic MediaWiki for more information.

Specified by:
addSemanticAttribute in interface IWikiModel
Returns:

addSemanticRelation

public boolean addSemanticRelation(java.lang.String relation,
                                   java.lang.String relationValue)
See Semantic MediaWiki for more information.

Specified by:
addSemanticRelation in interface IWikiModel
Returns:

addTemplate

public void addTemplate(java.lang.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.

Specified by:
addTemplate in interface IWikiModel
Parameters:
template - The name of the template that is being included.

addTemplateFunction

public ITemplateFunction addTemplateFunction(java.lang.String key,
                                             ITemplateFunction value)
Add a new interwiki link to the configuration

Specified by:
addTemplateFunction in interface IConfiguration
Returns:

addTokenTag

public TagToken addTokenTag(java.lang.String key,
                            TagToken value)
Add a new HTML styled tag to the configuration

Specified by:
addTokenTag in interface IConfiguration
Returns:

addToReferences

public java.lang.String[] addToReferences(java.lang.String reference,
                                          java.lang.String nameAttribute)
Add a reference (i.e. footnote) to the internal list

Specified by:
addToReferences in interface IWikiModel
Parameters:
reference - the rendered HTML code of the ref-Tag body
nameAttribute - the value of the name attribute or null
Returns:
the current offset (i.e. size()-1) of the element in the list

addToTableOfContent

protected void addToTableOfContent(java.util.List<java.lang.Object> toc,
                                   SectionHeader strPair,
                                   int headLevel)
Add a section header with the given headLevel to the "table of content"

Parameters:
toc - the "table of content list"
strPair - a new section header
headLevel - the level of the new section header

append

public void append(BaseToken contentNode)
Append the content as a child on the top node of the internal stack

Specified by:
append in interface IWikiModel

appendExternalImageLink

public void appendExternalImageLink(java.lang.String imageSrc,
                                    java.lang.String imageAltText)
Append an external wiki image link (starting with http, https,... and ending with gif, png, jpg, bmp)

Specified by:
appendExternalImageLink in interface IWikiModel

appendExternalLink

@Deprecated
public void appendExternalLink(java.lang.String link,
                                          java.lang.String linkName,
                                          boolean withoutSquareBrackets)
Deprecated. use IWikiModel.appendExternalLink(String, String, String, boolean) instead.

Append an external link (starting with http, https, ftp,...) as described in Help Links

Specified by:
appendExternalLink in interface IWikiModel
Parameters:
link - the external link with http://, https:// or ftp:// prefix
linkName - the link name which is separated from the URL by a space
withoutSquareBrackets - if true a link with no square brackets around the link was parsed

appendExternalLink

public void appendExternalLink(java.lang.String uriSchemeName,
                               java.lang.String link,
                               java.lang.String linkName,
                               boolean withoutSquareBrackets)
Append an external link (starting with http, https, ftp,...) as described in Help Links

Specified by:
appendExternalLink in interface IWikiModel
Parameters:
uriSchemeName - the top level URI (Uniform Resource Identifier) scheme name (without the following colon character ":"). Example "ftp", "http", "https". See URI scheme
link - the external link with http://, https:// or ftp:// prefix
linkName - the link name which is separated from the URL by a space
withoutSquareBrackets - if true a link with no square brackets around the link was parsed

appendHead

public ITableOfContent appendHead(java.lang.String rawHead,
                                  int headLevel,
                                  boolean noToC,
                                  int headCounter)
Add a single wiki head (i.e. ==...==, ===...===, ====...====,...) to the table of content

Specified by:
appendHead in interface IWikiModel
Parameters:
rawHead - the unparsed header string
headLevel - level of header (i.e. h1, h2, h3, h4, 5h,..)
headCounter - the total number of headers parsed
Returns:
the "table of content" tag

appendHead

public ITableOfContent appendHead(java.lang.String rawHead,
                                  int headLevel,
                                  boolean noToC,
                                  int headCounter,
                                  int startPosition,
                                  int endPosition)
Append a new head to the table of content

Specified by:
appendHead in interface IWikiModel
Parameters:
rawHead -
headLevel -
headCounter - the total number of headers parsed
startPosition - the start index in the text where the header line of the section begins
endPosition - the start index in the text where the header line of the section ends
Returns:
the "table of content" tag

appendInternalImageLink

public void appendInternalImageLink(java.lang.String hrefImageLink,
                                    java.lang.String srcImageLink,
                                    ImageFormat imageFormat)
Append this internal wiki image link. In the current implementation some parts of the image rendering are moved to the HTMLConverter#imageNodeToText() method.

Specified by:
appendInternalImageLink in interface IWikiModel

setDefaultThumbWidth

protected void setDefaultThumbWidth(ImageFormat imageFormat)
Set the default thumb format width. This method sets a "default width" (220px) for images of type "thumb", if no width is set in the image format string.

Parameters:
imageFormat -

appendInternalLink

public void appendInternalLink(java.lang.String topic,
                               java.lang.String hashSection,
                               java.lang.String topicDescription,
                               java.lang.String cssClass,
                               boolean parseRecursive)
Append an internal wikilink as described in Help Links

Specified by:
appendInternalLink in interface IWikiModel
cssClass - the links CSS class style
parseRecursive - TODO

appendInterWikiLink

public void appendInterWikiLink(java.lang.String namespace,
                                java.lang.String title,
                                java.lang.String linkText)
Append an InterWiki link

Specified by:
appendInterWikiLink in interface IWikiModel

appendISBNLink

public void appendISBNLink(java.lang.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.

Specified by:
appendISBNLink in interface IWikiModel
Parameters:
isbnPureText - the pure ISBN string which contains the ISBN prefix and optional dashes in the ISBN number

appendMailtoLink

public void appendMailtoLink(java.lang.String link,
                             java.lang.String linkName,
                             boolean withoutSquareBrackets)
Append an external link (starting with mailto:...) as described in Help:Wikitext#Links

Specified by:
appendMailtoLink in interface IWikiModel
Parameters:
link - the external link with mailto: prefix
linkName - the link name which is separated from the URL by a space
withoutSquareBrackets - if true a mailto link with no square brackets around the link was parsed

appendRawNamespaceLinks

public boolean appendRawNamespaceLinks(java.lang.String rawNamespaceTopic,
                                       java.lang.String viewableLinkDescription,
                                       boolean containsNoPipe)
Check if the topic is a special namespace topic. In the AbstractWikiModel defaults implementation this namespace topic is parsed and checks for various namespaces, like Categories and Interwiki links.

Specified by:
appendRawNamespaceLinks in interface IWikiModel
Parameters:
rawNamespaceTopic - the text between the [[...]] square brackets of a wiki link before the pipe symbol
containsNoPipe - set to true if the rawLinkText contained no pipe symbol.
Returns:
true if the topic is a special namespace topic

appendRawWikipediaLink

public void appendRawWikipediaLink(java.lang.String rawLinkText,
                                   java.lang.String suffix)
Main entry method for parsing a raw wiki link (i.e. the text between the [[...]] square brackets). In the AbstractWikiModel defaults implementation this link is parsed and the various other append... methods of the model are called for the different cases.

Specified by:
appendRawWikipediaLink in interface IWikiModel
Parameters:
rawLinkText - the text between the [[...]] square brackets of a wiki link
suffix - a String of lowercase letters which directly follow the link after the closing ]] brackets. Useful for topic plurals.

appendRedirectLink

public boolean appendRedirectLink(java.lang.String redirectLink)
Append the redirect link to the model

Specified by:
appendRedirectLink in interface IWikiModel
Parameters:
redirectLink - the raw string between the wikilink tags [[ ]]
Returns:
true if the the wikitext shouldn't be parsed

appendSignature

public void appendSignature(java.lang.Appendable writer,
                            int numberOfTildes)
                     throws java.io.IOException
Append the user signature to the writer (i.e. '~~~', '~~~~' or '~~~~'). This method is used in the first pass of parsing the wiki text (together with template parsing). You can append a [[User:xxxx]] string according to your model.

Specified by:
appendSignature in interface IWikiModel
numberOfTildes - an int value between 3 and 5
Throws:
java.io.IOException

appendStack

public void appendStack(TagStack stack)
Append the given tag stack to the current tag stack of the model.

Specified by:
appendStack in interface IWikiModel

appendToCAnchor

public TagNode appendToCAnchor(java.lang.String anchor)


buildEditLinkUrl

public void buildEditLinkUrl(int section)
Build the link to edit a section of the wikipedia article

Specified by:
buildEditLinkUrl in interface IWikiModel

createNewInstance

public AbstractParser createNewInstance(java.lang.String rawWikitext)
Create a new parser instance

Specified by:
createNewInstance in interface IWikiModel
Returns:

createTableOfContent

public ITableOfContent createTableOfContent(boolean isTOCIdentifier)
Description copied from interface: IWikiModel
Create the "table of content" placeholder

Specified by:
createTableOfContent in interface IWikiModel
Parameters:
isTOCIdentifier - true if the __TOC__ keyword was parsed
Returns:
the "table of content" tag

decrementRecursionLevel

public int decrementRecursionLevel()
Decrement the current recursion level of the parser. The recursion level is used to prevent infinite nesting of templates, tables, lists and other parser objects.

Specified by:
decrementRecursionLevel in interface IWikiModel
Returns:
the decremented recursion level

encodeTitleDotUrl

public java.lang.String encodeTitleDotUrl(java.lang.String wikiTitle,
                                          boolean firstCharacterAsUpperCase)
Encode the wiki links title into a URL for HTML hyperlinks (i.e. create the href attribute representation for the a tag). This method uses the '.' character to encode special characters. To get the behavior of the MediaWiki software, which is configured to convert the first letter to upper case, the firstCharacterAsUpperCase parameters must be set to true. For an example encoding routine see: Encoder.encodeTitleDotUrl(String, boolean)

Specified by:
encodeTitleDotUrl in interface IWikiModel
firstCharacterAsUpperCase - if true convert the first of the title to uppercase
See Also:
Encoder.encodeTitleToUrl(String, boolean)

encodeTitleToUrl

public java.lang.String encodeTitleToUrl(java.lang.String wikiTitle,
                                         boolean firstCharacterAsUpperCase)
Encode the wiki links title into a URL for HTML hyperlinks (i.e. create the href attribute representation for the a tag). This method uses the '%' character to encode special characters. To get the behavior of the MediaWiki software, which is configured to convert the first letter to upper case, the firstCharacterAsUpperCase parameters must be set to true. For an example encoding routine see Encoder.encodeTitleToUrl(String, boolean)

Specified by:
encodeTitleToUrl in interface IWikiModel
firstCharacterAsUpperCase - if true convert the first of the title to uppercase
See Also:
Encoder.encodeTitleToUrl(String, boolean)

get2ndCategoryNamespace

public java.lang.String get2ndCategoryNamespace()
Get the secondary namespace (i.e. the namespace for a non-englich locale) for categories in this wiki

Specified by:
get2ndCategoryNamespace in interface IWikiModel
Returns:
the secondary category namespace

get2ndImageNamespace

public java.lang.String get2ndImageNamespace()
Get the secondary namespace (i.e. the namespace for a non-englich locale) for images in this wiki

Specified by:
get2ndImageNamespace in interface IWikiModel
Returns:
the secondary image namespace

get2ndTemplateNamespace

public java.lang.String get2ndTemplateNamespace()
Get the secondary namespace (i.e. the namespace for a non-englich locale) for templates in this wiki

Specified by:
get2ndTemplateNamespace in interface IWikiModel
Returns:
the secondary template namespace

getAttribute

public java.lang.Object getAttribute(java.lang.String attribute)
Resolve an attribute reference. It can be in four possible places: 1. the attribute list for the current template 2. if self is an embedded template, somebody invoked us possibly with arguments--check the argument context 3. if self is an embedded template, the attribute list for the enclosing instance (recursively up the enclosing instance chain) 4. if nothing is found in the enclosing instance chain, then it might be a map defined in the group or the its supergroup etc... Attribute references are checked for validity. If an attribute has a value, its validity was checked before template rendering. If the attribute has no value, then we must check to ensure it is a valid reference. Somebody could reference any random value like $xyz$; formal arg checks before rendering cannot detect this--only the ref can initiate a validity check. So, if no value, walk up the enclosed template tree again, this time checking formal parameters not attributes Map. The formal definition must exist even if no value. To avoid infinite recursion in toString(), we have another condition to check regarding attribute values. If your template has a formal argument, foo, then foo will hide any value available from "above" in order to prevent infinite recursion. This method is not static so people can override functionality.

Specified by:
getAttribute in interface IContext

getAttributeRenderer

public AttributeRenderer getAttributeRenderer(java.lang.Class attributeClassType)
What renderer is registered for this attributeClassType for this template. If not found, the template's group is queried.

Specified by:
getAttributeRenderer in interface IContext

getCategoryNamespace

public java.lang.String getCategoryNamespace()
Get the primary namespace for categories in this wiki

Specified by:
getCategoryNamespace in interface IWikiModel
Returns:
the primary category namespace

getCodeFormatterMap

public java.util.Map<java.lang.String,SourceCodeFormatter> getCodeFormatterMap()
Get the source code formatter map of built-in source code formatters

Specified by:
getCodeFormatterMap in interface IConfiguration
Returns:

getCurrentTimeStamp

public java.util.Date getCurrentTimeStamp()
Get the current time stamp. This is the value for the magic word "CURRENTTIMESTAMP". This method typically returns the value new Date(System.currentTimeMillis());.

Specified by:
getCurrentTimeStamp in interface IWikiModel
Returns:

getImageNamespace

public java.lang.String getImageNamespace()
Get the primary namespace for images in this wiki

Specified by:
getImageNamespace in interface IWikiModel
Returns:
the primary image namespace

getInterwikiMap

public java.util.Map<java.lang.String,java.lang.String> getInterwikiMap()
Get the interwiki links map for converting interwiki links into external URLs. Example: maps the interwiki shortcut "de" to "http://de.wikipedia.org/wiki/${title}"

Specified by:
getInterwikiMap in interface IConfiguration
Returns:

getLocale

public java.util.Locale getLocale()
Get the locale of this model.

Specified by:
getLocale in interface IWikiModel
Returns:
the locale for this model.

getNextNumber

public int getNextNumber()
Get the next unique number

Specified by:
getNextNumber in interface IWikiModel
Returns:
the next int number.

getNode

public 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.

Specified by:
getNode in interface IWikiModel
Returns:
the node at the given offset

getPageName

public java.lang.String getPageName()
Get the title of the current wiki article.

Specified by:
getPageName in interface IWikiModel
Returns:

getRawWikiContent

public java.lang.String getRawWikiContent(java.lang.String namespace,
                                          java.lang.String templateName,
                                          java.util.Map<java.lang.String,java.lang.String> templateParameters)
Get the raw wiki text for the given namespace and article name

Specified by:
getRawWikiContent in interface IWikiModel
Parameters:
namespace - the namespace of this article
templateName - the name of the template
templateParameters - if the namespace is the Template namespace, the current template parameters are stored as Strings in this map
Returns:
null if no content was found

getRecursionLevel

public int getRecursionLevel()
Get the current recursion level of the parser. The recursion level is used to prevent infinite nesting of templates, tables, lists and other parser objects.

Specified by:
getRecursionLevel in interface IWikiModel
Returns:
the current recursion level counter

getRedirectLink

public java.lang.String getRedirectLink()
Get the redirect link.

Specified by:
getRedirectLink in interface IWikiModel
Returns:
the raw string between the wikilink tags [[ ]] or null if no redirect exists

getReferences

public java.util.List<Reference> getReferences()
Get the internal list of references (i.e. footnotes)

Specified by:
getReferences in interface IWikiModel
Returns:
the list of references or null if no reference exists
See Also:
Reference

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Get the resource bundle associated with this model for I18N support

Specified by:
getResourceBundle in interface IWikiModel
Returns:
the currently used resource bundle for this wiki model

getSemanticAttributes

public java.util.List<SemanticAttribute> getSemanticAttributes()
Get the list of SemanticAttributes

Specified by:
getSemanticAttributes in interface IWikiModel
Returns:
the list of SemanticAttributes or null if no SemanticAttribute exists

getSemanticRelations

public java.util.List<SemanticRelation> getSemanticRelations()
Get the list of SemanticRelations. See Semantic MediaWiki for more information.

Specified by:
getSemanticRelations in interface IWikiModel
Returns:
the list of SemanticRelations or null if no SemanticRelation exists

getTableOfContent

public ITableOfContent getTableOfContent()
Get the parsed "table of content" data after parsing the Wikipedia text.

Specified by:
getTableOfContent in interface IWikiModel
Returns:

getTemplateCallsCache

public java.util.Map<java.lang.String,java.lang.String> getTemplateCallsCache()
Get the currently configured cache implementation for template calls.

Specified by:
getTemplateCallsCache in interface IConfiguration
Returns:
null if no cache implementation is set.
See Also:
IConfiguration.setTemplateCallsCache(Map)

getTemplateFunction

public ITemplateFunction getTemplateFunction(java.lang.String name)
Get a template parser function (i.e. {{ #if: ... }} ) implementation.

Specified by:
getTemplateFunction in interface IWikiModel
Parameters:
name - the name of the function without the "#" and ":" delimiters
Returns:
the parser function or null if no function is available for the given name

getTemplateMap

public java.util.Map<java.lang.String,ITemplateFunction> getTemplateMap()
Get the template parser functions map of built-in template functions

Specified by:
getTemplateMap in interface IConfiguration
Returns:

getTemplateNamespace

public java.lang.String getTemplateNamespace()
Get the primary namespace for templates in this wiki model

Specified by:
getTemplateNamespace in interface IWikiModel
Returns:
the primary namespace for templates

getTokenMap

public java.util.Map<java.lang.String,TagToken> getTokenMap()
Get the HTML styled tag map for built-in tags

Specified by:
getTokenMap in interface IConfiguration
Returns:

getUriSchemeSet

public java.util.Set<java.lang.String> getUriSchemeSet()
Get the set of all allowed URI scheme shortcuts like http, https, ftp,... See URI scheme

Specified by:
getUriSchemeSet in interface IConfiguration

getWikiListener

public IEventListener getWikiListener()
Get the current defined wiki listener

Specified by:
getWikiListener in interface IWikiModel
Returns:
the wiki listener or null if no listener is defined

incrementParserRecursionCount

public int incrementParserRecursionCount()

Specified by:
incrementParserRecursionCount in interface IWikiModel

incrementRecursionLevel

public int incrementRecursionLevel()
Increment the current recursion level of the parser. The recursion level is used to prevent infinite nesting of templates, tables, lists and other parser objects.

Specified by:
incrementRecursionLevel in interface IWikiModel
Returns:
the current recursion level counter

incrementTemplateRecursionCount

public int incrementTemplateRecursionCount()

Specified by:
incrementTemplateRecursionCount in interface IWikiModel

initialize

protected void initialize()
Initialize the internal class attributes


isCamelCaseEnabled

public boolean isCamelCaseEnabled()
Checks if CamelCase words should also be used as wiki links.

Specified by:
isCamelCaseEnabled in interface IWikiModel
Returns:
true if CamelCase words should also be used as wiki links

isCategoryNamespace

public boolean isCategoryNamespace(java.lang.String namespace)
Check if the given namespace is a category namespace

Specified by:
isCategoryNamespace in interface IWikiModel
Returns:
true if the namespace is a category namespace.

isEditorMode

public boolean isEditorMode()
The current model is used to render a wikipage in editor mode

Specified by:
isEditorMode in interface IWikiModel
Returns:
true if your model is used in an editor mode

isImageNamespace

public boolean isImageNamespace(java.lang.String namespace)
Check if the given namespace is an image namespace

Specified by:
isImageNamespace in interface IWikiModel
Returns:
true if the namespace is a image namespace.

isInterWiki

public boolean isInterWiki(java.lang.String namespace)
Check if the given namespace is an interwiki link prefix.

Specified by:
isInterWiki in interface IWikiModel
Returns:
true if the namespace is a interwiki namespace (i.e. prefix).

isMathtranRenderer

public boolean isMathtranRenderer()
If the <math> tag should be rendered for the www.mathtran.org service, then return true.

Specified by:
isMathtranRenderer in interface IWikiModel
Returns:
true the <math> tag should be rendered fro mathtran.org.

isNamespace

public boolean isNamespace(java.lang.String namespace)
Check if the given namespace is a namespace in this model

Specified by:
isNamespace in interface IWikiModel
Returns:
true if the namespace is a namespace in this model

isPreviewMode

public boolean isPreviewMode()
The current model is used to render a wikipage in preview mode

Specified by:
isPreviewMode in interface IWikiModel
Returns:
true if your model is used in a preview mode

isSemanticWebActive

public boolean isSemanticWebActive()
Allow the parsing of semantic mediawiki (SMW) links. See Semantic MediaWiki for more information.

Specified by:
isSemanticWebActive in interface IWikiModel
Returns:
true if parsing of semantic mediawiki (SMW) links is enabled

isTemplateNamespace

public boolean isTemplateNamespace(java.lang.String namespace)
Check if the given namespace is a template namespace

Specified by:
isTemplateNamespace in interface IWikiModel
Returns:
true if the namespace is a template namespace.

isTemplateTopic

public boolean isTemplateTopic()
Determine if the currently parsed wiki text is a template.

Specified by:
isTemplateTopic in interface IWikiModel
Returns:
true if the currently parsed wiki text is a template

isValidUriScheme

public boolean isValidUriScheme(java.lang.String uriScheme)
Check if the top level URI (Uniform Resource Identifier) scheme name is valid in this model. See URI scheme

Specified by:
isValidUriScheme in interface IWikiModel
Parameters:
uriScheme - the top level URI (Uniform Resource Identifier) scheme name (without the following colon character ":")
Returns:
true if the specified URI scheme is valid.
See Also:
IWikiModel.isValidUriSchemeSpecificPart(String, String)

isValidUriSchemeSpecificPart

public boolean isValidUriSchemeSpecificPart(java.lang.String uriScheme,
                                            java.lang.String uriSchemeSpecificPart)
Check if the scheme-specific part for a given top level URI (Uniform Resource Identifier) scheme name is valid in this model. See URI scheme

Specified by:
isValidUriSchemeSpecificPart in interface IWikiModel
Parameters:
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 ":"
Returns:
true if the specified URI scheme is valid.
See Also:
IWikiModel.isValidUriScheme(String)

parseBBCodes

public boolean parseBBCodes()
Parse BBCode (Bulletin Board Code), like syntax codes in this wiki. See http://en.wikipedia.org/wiki /BBCode for more information.

Specified by:
parseBBCodes in interface IWikiModel
Returns:
true if the bbCodes should be parsed

parseEvents

public void parseEvents(IEventListener listener,
                        java.lang.String rawWikiText)
Parse the raw Wikipedia text and notify the listener

Specified by:
parseEvents in interface IWikiModel
Parameters:
listener - an event listener
rawWikiText - the raw wiki text

parseTemplates

public java.lang.String parseTemplates(java.lang.String rawWikiText)
Parse the templates in a raw wikipedia text into a resulting wikipedia text.

Specified by:
parseTemplates in interface IWikiModel
Returns:

parseTemplates

public java.lang.String parseTemplates(java.lang.String rawWikiText,
                                       boolean parseOnlySignature)
Parse the templates in a raw wikipedia text into a resulting wikipedia text.

Specified by:
parseTemplates in interface IWikiModel
parseOnlySignature - if true parse only the signature wiki texts, no templates and wiki comment parsing
Returns:

peekNode

public TagToken peekNode()
Get the current TagNode on top of the internal stack

Specified by:
peekNode in interface IWikiModel
Returns:
the current node

popNode

public TagToken popNode()
Pop the current TagNode from top of the internal stack

Specified by:
popNode in interface IWikiModel

pushNode

public boolean pushNode(TagToken node)
Push the given TagNode on top of the internal stack

Specified by:
pushNode in interface IWikiModel
Returns:
true if the push on the internal stack was successful

rawSetAttribute

protected void rawSetAttribute(java.util.Map attributes,
                               java.lang.String name,
                               java.lang.Object value)
Map a value to a named attribute. Throw NoSuchElementException if the named attribute is not formally defined in self's specific template and a formal argument list exists.


registerRenderer

public void registerRenderer(java.lang.Class attributeClassType,
                             AttributeRenderer renderer)
Register a renderer for all objects of a particular type. This overrides any renderer set in the group for this class type.

Specified by:
registerRenderer in interface IContext

render

public java.lang.String render(ITextConverter converter,
                               java.lang.String rawWikiText)
Render the raw Wikipedia text into a string for a given converter

Specified by:
render in interface IWikiModel
Parameters:
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 text
Returns:
null if an IOException occurs or converter==null

render

public java.lang.String render(java.lang.String rawWikiText)
Render the raw Wikipedia text into an HTML string and use the default HTMLConverter

Specified by:
render in interface IWikiModel
Returns:
null if an IOException occurs

renderPDF

public java.lang.String renderPDF(java.lang.String rawWikiText)
Render the raw Wikipedia text into an HTML string and use the default PDFConverter. The resulting XHTML could be used as input for the Flying Saucer PDF renderer

Specified by:
renderPDF in interface IWikiModel
Returns:
null if an IOException occurs

replaceColon

public boolean replaceColon()
Replace a colon ':' with a slash '/' in wiki names (i.e. links, categories, templates)

Specified by:
replaceColon in interface IWikiModel
Returns:

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set an attribute for this template. If you set the same attribute more than once, you get a multi-valued attribute. If you send in a StringTemplate object as a value, it's enclosing instance (where it will inherit values from) is set to 'this'. This would be the normal case, though you can set it back to null after this call if you want. If you send in a List plus other values to the same attribute, they all get flattened into one List of values. This will be a new list object so that incoming objects are not altered. If you send in an array, it is converted to an ArrayIterator.

Specified by:
setAttribute in interface IContext

setAttributeRenderers

public void setAttributeRenderers(java.util.Map renderers)
Specify a complete map of what object classes should map to which renderer objects.


setPageName

public void setPageName(java.lang.String pageTitle)
Set the title of the currently rendered page data.

Specified by:
setPageName in interface IWikiModel

setSemanticWebActive

public void setSemanticWebActive(boolean semanticWeb)
Activate the parsing of semantic Mediawiki (SMW) links See Semantic MediaWiki for more information.

Specified by:
setSemanticWebActive in interface IWikiModel

setTemplateCallsCache

public void setTemplateCallsCache(java.util.Map<java.lang.String,java.lang.String> map)
Set a cache map implementation. For example based on JSR 107. Template calls which use the same parameters over and over again do lookup this cache and use the preparsed result if available. Note: don't use a simple java.util.HashMap implementation because it's not thread-safe an grows infinitly.

Specified by:
setTemplateCallsCache in interface IConfiguration
Parameters:
map - the cache implementation

setUp

public void setUp()
Prepare or initialize the wiki model before rendering the wikipedia text

Specified by:
setUp in interface IWikiModel

showSyntax

public boolean showSyntax(java.lang.String tagName)
Show the syntax highlighting of the source code

Specified by:
showSyntax in interface IWikiModel
Returns:

stackSize

public int stackSize()
The size of the internal stack

Specified by:
stackSize in interface IWikiModel
Returns:

substituteTemplateCall

public void substituteTemplateCall(java.lang.String templateName,
                                   java.util.Map<java.lang.String,java.lang.String> parameterMap,
                                   java.lang.Appendable writer)
                            throws java.io.IOException
Substitute the template name by the template content and parameters and append the new content to the writer.

Specified by:
substituteTemplateCall in interface IWikiModel
Parameters:
templateName - the name of the template
parameterMap - the templates parameter java.util.SortedMap
cacheKey - a key for using in a cache
writer - the buffer to append the substituted template content
Throws:
java.io.IOException

swapStack

public TagStack swapStack(TagStack stack)

Specified by:
swapStack in interface IWikiModel

tearDown

public void tearDown()
Clean up (i.e. free internal resources) in the wiki model after rendering the wikipedia text, if necessary

Specified by:
tearDown in interface IWikiModel

toNodeList

public java.util.List<BaseToken> toNodeList(java.lang.String rawWikiText)
Deprecated. 

Initialize the wiki model and parse the rawWikiText and return the parsed node list.

Parameters:
rawWikiText -
Returns:


Copyright © 2012 Java Wikipedia API (Bliki engine). All Rights Reserved.