本文整理汇总了Java中org.sweble.wikitext.engine.PageId类的典型用法代码示例。如果您正苦于以下问题:Java PageId类的具体用法?Java PageId怎么用?Java PageId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PageId类属于org.sweble.wikitext.engine包,在下文中一共展示了PageId类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompiledPage
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
/**
* Returns CompiledPage produced by the SWEBLE parser using the
* SimpleWikiConfiguration.
*
* @return the parsed page
* @throws WikiApiException
*/
public CompiledPage getCompiledPage() throws WikiApiException
{
CompiledPage cp;
try{
SimpleWikiConfiguration config = new SimpleWikiConfiguration(SWEBLE_CONFIG);
PageTitle pageTitle = PageTitle.make(config, this.getTitle().toString());
PageId pageId = new PageId(pageTitle, -1);
// Compile the retrieved page
Compiler compiler = new Compiler(config);
cp = compiler.postprocess(pageId, this.getText(), null);
}catch(Exception e){
throw new WikiApiException(e);
}
return cp;
}
示例2: parse
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
public String parse(String markupText) {
if (config == null || compiler == null) {
init();
}
try {
PageTitle pageTitle = PageTitle.make(config, "PageTitle");
PageId pageId = new PageId(pageTitle, -1);
CompiledPage cp = compiler.postprocess(pageId, markupText, null);
StringWriter w = new StringWriter();
HtmlPrinter p = new HtmlPrinter(w, pageTitle.getFullTitle());
p.setStandaloneHtml(false, "");
p.go(cp.getPage());
return w.toString();
} catch (Exception e) {
return "<b>Failed to compile message:</b><br/>" + e.toString();
}
}
示例3: parseText
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
/** Generate an Abstract Syntax Tree representation (AST) representation
* of a given wikitext using the Sweble Parser 2.0.0-alpha-2-SNAPSHOT version,
* and eventually generates an XML representation using a visitor class.
*
* @param wikitext
* @param pagetitle
* @return wikitext in XML
* @throws JAXBException
* @throws CompilerException
* @throws LinkTargetException
* @throws IOException
*/
public String parseText(String wikitext, String pagetitle, String language)
throws JAXBException, CompilerException, LinkTargetException, IOException {
WikiConfig config = DefaultConfigEn.generate();
// Instantiate Sweble parser
WtEngine engine = new WtEngine(config);
PageTitle pageTitle = PageTitle.make(config, pagetitle);
PageId pageId = new PageId(pageTitle, -1);
// Parse Wikitext into AST
EngCompiledPage cp = engine.postprocess(pageId, wikitext, null);
// Render AST to XML
String uri = language+".wikipedia.org/wiki/";
String wikiXML = XMLRenderer.print(new MyRendererCallback(), config, pageTitle, cp.getPage(),uri);
return wikiXML;
}
示例4: processedPage
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
private EngProcessedPage processedPage(Article article) {
try {
PageTitle pageTitle = PageTitle.make(config, article.getTitle());
PageId pageId = new PageId(pageTitle, Integer.parseInt(article.getRevisionId()));
return engine.postprocess(pageId, article.getText(), null);
} catch (LinkTargetException | EngineException e) {
throw new RuntimeException(e);
}
}
示例5: getCompiledPage
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
/**
* Returns CompiledPage produced by the SWEBLE parser using the
* SimpleWikiConfiguration.
*
* @return the parsed page
* @throws LinkTargetException
* @throws CompilerException if the wiki page could not be compiled by the parser
* @throws JAXBException
* @throws FileNotFoundException
*/
private static CompiledPage getCompiledPage(String text, String title, long revision) throws LinkTargetException, CompilerException, FileNotFoundException, JAXBException
{
SimpleWikiConfiguration config = new SimpleWikiConfiguration(SWEBLE_CONFIG);
PageTitle pageTitle = PageTitle.make(config, title);
PageId pageId = new PageId(pageTitle, revision);
// Compile the retrieved page
Compiler compiler = new Compiler(config);
return compiler.postprocess(pageId, text, null);
}
示例6: parsePage
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
public static EngProcessedPage parsePage(WikiConfig config, String title, long revision, String markup) throws EngineException, LinkTargetException {
WtEngineImpl engine = new WtEngineImpl(config);
PageTitle pageTitle = PageTitle.make(config, title);
PageId pageId = new PageId(pageTitle, revision);
return parseWikipage(engine, pageId, markup);
}
示例7: SwebleWikipediaTextFilter
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
public SwebleWikipediaTextFilter() {
try {
config = new SimpleWikiConfiguration(
"classpath:/org/languagetool/resource/dev/SimpleWikiConfiguration.xml");
compiler = new Compiler(config);
PageTitle pageTitle = PageTitle.make(config, "fileTitle");
pageId = new PageId(pageTitle, -1);
} catch (Exception e) {
throw new RuntimeException("Could not set up text filter", e);
}
}
示例8: MathConverter
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
public MathConverter(String wikiText, String name) throws LinkTargetException, EngineException {
pageTitle = PageTitle.make(config, name);
PageId pageId = new PageId(pageTitle, -1);
page = engine.postprocess(pageId, wikiText, null);
texInfoUrl = (new BaseConfig()).getTexvcinfoUrl();
}
示例9: parseWikipage
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
public static EngProcessedPage parseWikipage(WtEngineImpl engine, PageId pageId, String markup) throws EngineException {
return engine.postprocess(pageId, markup, null);
}
示例10: parse
import org.sweble.wikitext.engine.PageId; //导入依赖的package包/类
String parse(String wikiOrigText, WikiIDTitlePair id_title, boolean csvOrReadable) throws CompilerException,
LinkTargetException, EngineException {
WikiConfig config = DefaultConfigEn.generate();
WtEngineImpl engine = new WtEngineImpl(config);
// Retrieve a page
PageTitle pageTitle = PageTitle.make(config, id_title.getWikiTitle());
PageId pageId = new PageId(pageTitle, -1);
// Compile the retrieved page
EngProcessedPage cp = engine.postprocess(pageId, wikiOrigText, null);
TextConverter p = new TextConverter(config, wrapCol);
p.setCsvOrReadable(csvOrReadable);
return (String) p.go(cp.getPage());
}