Package games.stendhal.server.util
Class WikipediaAccess
java.lang.Object
org.xml.sax.helpers.DefaultHandler
games.stendhal.server.util.WikipediaAccess
- All Implemented Interfaces:
Runnable,ContentHandler,DTDHandler,EntityResolver,ErrorHandler
Gets the first text paragraph from the specified Wikipedia article using the
MediaWiki bot API.
You can invoke the parser either inline using the method parse() or start it
in a new thread.
TODO: handle redirects (but take care, there might be two redirects that
point to each other).
- Author:
- hendrik
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) getError()Gets the last error message.Returns the first paragraph of the specified article without wiki code.getText()Returns the unparsed text.booleanReturns true when the XML response was completely parsed.voidrun()voidstartElement(String namespaceURI, String lName, String qName, Attributes attrs) Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
WikipediaAccess
Creates a new WikipeidaAccess.- Parameters:
title- title of the page to access
-
-
Method Details
-
startElement
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException
-
getText
Returns the unparsed text.- Returns:
- content
-
getError
Gets the last error message.- Returns:
- error message or
nullin case no error occurred
-
getProcessedText
Returns the first paragraph of the specified article without wiki code.- Returns:
- content
-
run
public void run() -
isFinished
public boolean isFinished()Returns true when the XML response was completely parsed.- Returns:
- true if the parsing was completed, false otherwise
-