|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.spy.translate.GoogleTranslateScraper
public class GoogleTranslateScraper
This class is the translation driver for using the Google Translate Scraper.
typical usage might look like this :
GoogleTranslateScraper spanishTranslator = new GoogleTranslateScraper();
spanishTranslator.setTranslateMode(TranslateMode.SPANISH_TO_ENGLISH);
String spanishText = "gracias";
String englishText = spanishTranslator.doTranslate(spanishText);
| Constructor Summary | |
|---|---|
GoogleTranslateScraper()
Simple no argument constructor. |
|
GoogleTranslateScraper(TranslateMode mode)
Overloaded constructor that takes a translation mode as an argument. |
|
| Method Summary | |
|---|---|
protected org.apache.commons.httpclient.methods.PostMethod |
composePost(java.lang.String sourceString)
This method is used for composing the PostMethod needed for submitting the data to the google translate website. |
java.lang.String |
doTranslate(java.lang.String sourceString)
This method represents the soul of the translate scraper. |
protected java.lang.String |
parseResults(java.io.InputStream inputStream)
This method sets up the tagsoup SAX compliant parser, the result handler, parses the results and tries to find the result string. |
void |
setTranslateMode(TranslateMode newMode)
Set/Change the translation mode. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GoogleTranslateScraper()
public GoogleTranslateScraper(TranslateMode mode)
mode - The translation mode to use.TranslateMode| Method Detail |
|---|
public void setTranslateMode(TranslateMode newMode)
newMode - The translation mode to use.TranslateModeprotected org.apache.commons.httpclient.methods.PostMethod composePost(java.lang.String sourceString)
sourceString - The text to be translated.
PostMethod
public java.lang.String doTranslate(java.lang.String sourceString)
throws TranslationException
sourceString - the text to be translated.
TranslationException
protected java.lang.String parseResults(java.io.InputStream inputStream)
throws org.xml.sax.SAXException,
java.io.IOException
inputStream - The stream of html tags to be parsed.
org.xml.sax.SAXException - if a SAX parsing exception occured.
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||