info.bliki.wiki.template.extension
Class DollarContext

java.lang.Object
  extended by info.bliki.wiki.template.AbstractTemplateFunction
      extended by info.bliki.wiki.template.extension.DollarContext
All Implemented Interfaces:
ITemplateFunction

public class DollarContext
extends AbstractTemplateFunction

A template parser function for Java attributes. You can use the following syntax: {{#$:object|formatstring|separator|null-value}}. Example:

 public void testRendererForST() throws Exception {
        wikiModel.setAttribute("created", new GregorianCalendar(2005, 07 - 1, 05));
        wikiModel.registerRenderer(GregorianCalendar.class, wikiModel.new DateRenderer());
        String expecting = "date: 2005.07.05";
        assertEquals(expecting, wikiModel.parseTemplates("date: {{#$:created}}"));
 }
 
 public class DateRenderer implements AttributeRenderer {
        public String toString(Object o) {
                SimpleDateFormat f = new SimpleDateFormat("yyyy.MM.dd");
                return f.format(((Calendar) o).getTime());
        }
 
        public String toString(Object o, String formatString) {
                return toString(o);
        }
 }


Field Summary
static ITemplateFunction CONST
           
 
Constructor Summary
DollarContext()
           
 
Method Summary
 java.lang.String parseFunction(java.util.List<java.lang.String> list, IWikiModel model, char[] src, int beginIndex, int endIndex)
          Parse a template function (like for example {{ #if: ... }}) The result is also a text string in Wikipedia syntax notation which will be parsed again (recursively) in the TemplateParser step.
 
Methods inherited from class info.bliki.wiki.template.AbstractTemplateFunction
getFunctionDoc, parse, parseFunction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONST

public static final ITemplateFunction CONST
Constructor Detail

DollarContext

public DollarContext()
Method Detail

parseFunction

public java.lang.String parseFunction(java.util.List<java.lang.String> list,
                                      IWikiModel model,
                                      char[] src,
                                      int beginIndex,
                                      int endIndex)
                               throws java.io.IOException
Description copied from interface: ITemplateFunction
Parse a template function (like for example {{ #if: ... }}) The result is also a text string in Wikipedia syntax notation which will be parsed again (recursively) in the TemplateParser step.

Specified by:
parseFunction in interface ITemplateFunction
Specified by:
parseFunction in class AbstractTemplateFunction
Parameters:
list - the parser function arguments (extracted from the wiki text by splitting the string at the pipe symbol ´|´)
model - the wiki model
src - the array of the current Wikipedia source text
beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.
Returns:
the result string of this template function or null if the parsing fails or isn't valid
Throws:
java.io.IOException
See Also:
TemplateParser#parseTemplate(StringBuffer)


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