本文整理汇总了Java中org.wikipedia.Wiki.edit方法的典型用法代码示例。如果您正苦于以下问题:Java Wiki.edit方法的具体用法?Java Wiki.edit怎么用?Java Wiki.edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wikipedia.Wiki
的用法示例。
在下文中一共展示了Wiki.edit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: templateReplace
import org.wikipedia.Wiki; //导入方法依赖的package包/类
/**
* Replaces all transclusions of a template/page with specified text
*
* @param template The template (including namespace prefix) to be replaced
* @param replacementText The text to replace the template with (can include subst:XXXX)
* @param reason Edit summary to use
* @param wiki The wiki object to use.
*
* @throws IOException If network error.
*
*
*/
public static void templateReplace(String template, String replacementText, String reason, Wiki wiki) throws IOException
{
String[] list = wiki.whatTranscludesHere(template);
if (template.startsWith("Template:"))
template = namespaceStrip(template, wiki);
for (String page : list)
{
try
{
wiki.edit(page, wiki.getPageText(page).replaceAll("(?i)(" + template + ")", replacementText), reason);
}
catch (Throwable e)
{
e.printStackTrace();
}
}
}
示例2: nullEdit
import org.wikipedia.Wiki; //导入方法依赖的package包/类
/**
* Performs null edit on a list of pages by wiki. PRECONDITION: wiki object must be logged in
*
* @param wiki The wiki object to use
* @param l The list of pages to null edit.
*/
public static void nullEdit(Wiki wiki, String... l)
{
for (String s : l)
{
try
{
System.err.println("Attempting null edit on '" + s + "'");
wiki.edit(s, wiki.getPageText(s), "");
}
catch (Throwable e)
{
e.printStackTrace();
}
}
}
示例3: fileReplace
import org.wikipedia.Wiki; //导入方法依赖的package包/类
public static void fileReplace(String[] list, String file,
String replacement, String summary, Wiki wiki) {
file = file.replace((CharSequence) "_", (CharSequence) " ");
String regex = "(?i)(" + file + "|"
+ file.replace((CharSequence) " ", (CharSequence) "_") + ")";
for (String page : list) {
try {
wiki.edit(page,
wiki.getPageText(page).replaceAll(regex, replacement),
summary);
continue;
} catch (Throwable e) {
e.printStackTrace();
}
}
}
示例4: findAndReplace
import org.wikipedia.Wiki; //导入方法依赖的package包/类
/**
* Generic find and replace method.
*
* @param find The text to be found. You can use a regex for this
* @param replacement The text to replace any text matching the <tt>find</tt> field
* @param summary The edit summary to use
* @param wiki The wiki object to use
* @param pages The wiki pages to act upon.
*/
public static void findAndReplace(String find, String replacement, String summary, Wiki wiki, String... pages)
{
for (String s : pages)
{
try
{
wiki.edit(s, wiki.getPageText(s).replaceAll(find, replacement), summary);
}
catch (Throwable e)
{
e.printStackTrace();
}
}
}
示例5: templateReplace
import org.wikipedia.Wiki; //导入方法依赖的package包/类
public static void templateReplace(String template, String replacementText, String reason, Wiki wiki) throws IOException {
String[] list = wiki.whatTranscludesHere(template, new int[0]);
if (template.startsWith("Template:")) {
template = FbotParse.namespaceStrip(template);
}
for (String page : list) {
try {
wiki.edit(page, wiki.getPageText(page).replaceAll("(?i)(" + template + ")", replacementText), reason);
continue;
}
catch (Throwable e) {
e.printStackTrace();
}
}
}
示例6: dbrDump
import org.wikipedia.Wiki; //导入方法依赖的package包/类
public static void dbrDump(String page, String[] list, String headerText,
String footerText, Wiki wiki) throws LoginException, IOException {
String dump = headerText + " This report last updated as of ~~~~~\n";
for (String s : list) {
dump = dump + "*[[:" + s + "]]\n";
}
dump = dump + "\n" + footerText;
wiki.edit(page, dump, "Updating list");
}
示例7: addTextList
import org.wikipedia.Wiki; //导入方法依赖的package包/类
public static void addTextList(String[] pages, String text, String summary,
Wiki wiki) {
for (String page : pages) {
try {
wiki.edit(page, wiki.getPageText(text) + text, summary);
continue;
} catch (Throwable e) {
e.printStackTrace();
}
}
}