info.bliki.wiki.template.AbstractTemplateFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bliki-core Show documentation
Show all versions of bliki-core Show documentation
This is the core project.
The newest version!
package info.bliki.wiki.template;
import info.bliki.wiki.filter.TemplateParser;
import info.bliki.wiki.model.IWikiModel;
import java.io.IOException;
import java.util.List;
/**
* An abstract template parser function.
*
*/
public abstract class AbstractTemplateFunction implements ITemplateFunction {
@Override
public String getFunctionDoc() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public abstract String parseFunction(List parts, IWikiModel model, char[] src, int beginIndex, int endIndex,
boolean isSubst) throws IOException;
/**
* Parse the given content string with the template parser.
*
* @param content
* the raw content string
* @param model
* the wiki model
* @return
*/
public static String parse(String content, IWikiModel model) {
if (content == null || content.length() == 0) {
return "";
}
StringBuilder buf = new StringBuilder(content.length());
try {
TemplateParser.parse(content, model, buf, false);
} catch (IOException e) {
e.printStackTrace();
}
return buf.toString();
}
/**
* Parse the given content string with the template parser and
* trim()
the resulting string.
*
* @param content
* the raw content string
* @param model
* the wiki model
* @return
*/
public static String parseTrim(String content, IWikiModel model) {
return parse(content, model).trim();
}
}