• Welcome to DictionaryForMids Forum.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - njp

#1
Problems / Re: Interfacing to DictionaryForMids
16. April 2008, 15:43:09

QuotePlease do continue asking until everything runs fine for you !!

OK then, in the interest of improving your documentation.  Having added



DictionaryDataFile.initValues(false);



I now get the following error.  The line in the code represents the call to DictionaryDataFile.initValues(false);



java.lang.NullPointerException
        at de.kugihan.dictionaryformids.general.UtilMid.openProperties(+38)
        at de.kugihan.dictionaryformids.dataaccess.DictionaryDataFile.initValues(+8)
        at LwlPlay.<init>(LwlPlay.java:58)

#2
Problems / Re: Interfacing to DictionaryForMids
15. April 2008, 11:04:12
Thanks for the response Gert.

However, I'm only one step closer to the solution.


Having added the additional code you suggested I now have this error when the getTranslationResult function is called from within the Translation class.



java.lang.NullPointerException
        at de.kugihan.dictionaryformids.translation.Translation.getTranslationResult(+26)
        at de.kugihan.dictionaryformids.translation.TranslationThread.doTranslation(+220)
        at de.kugihan.dictionaryformids.translation.TranslationThread.runInForeground(+4)
        at de.kugihan.dictionaryformids.translation.TranslationExecution.executeTranslation(+46)
        at LwlPlay.commandAction(LwlPlay.java:99)



I'm confident the exception is being reported from within this block of code within the Translation.java file in the getTranslationResults function.



try {
Normation normationObj =      DictionaryDataFile.supportedLanguages[DictionarySettings.getInputLanguage()].normationObj;
// determine search words from the to be translated word
Vector searchWords = normationObj.searchWord(toBeTranslatedWord);
// get translation for each searchWord
for (int wordCount = 0; wordCount < searchWords.size(); ++wordCount) {
SearchedWord searchWord = (SearchedWord) searchWords.elementAt(wordCount);
String nonNormatedWord = searchWord.word;
String toBeTranslatedWordNormated = normationObj.normateWord(new StringBuffer(nonNormatedWord), true).toString();
if (toBeTranslatedWordNormated.length() > 0) {
searchTranslationForNormatedWord(toBeTranslatedWordNormated);
}
}
}
catch (Throwable t) {
Util.getUtil().log(t);
}




I'm affraid I dont know enough about the architechture to solve this problem easily though.

Again, any help appreciated  :)
#3
Problems / Interfacing to DictionaryForMids
14. April 2008, 18:02:19
Hello there,

I've downloaded the DictionaryForMIDs_engdeu_DTS.jar from the dicts.info site and added it to my project in netbeans.

I have a basic Form

public class LwlPlay extends Form implements CommandListener, ItemStateListener, TranslationExecutionCallback{
}


with this line in the constructor...

TranslationExecution.setTranslationExecutionCallback(this);

with the following implementations for the TranslationExecutionCallback interface...

    public void newTranslationResult(TranslationResult resultOfTranslation)
    {
        if (resultOfTranslation.translationFound)
        {
            Enumeration temp = resultOfTranslation.translations.elements();
           
            while(temp.hasMoreElements())
            {
                SingleTranslation t = (SingleTranslation)temp.nextElement();
                append(new StringItem(t.fromText.toString(), t.toText.toString()));
            }
        }
    }

    public void deletePreviousTranslationResult()
    {

    }

during an event when a button is clicked I execute this...

                try
                {
                    TranslationExecution.executeTranslation("hello", false);
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }

if executeInBackground is false, I get the following exception...

java.lang.NullPointerException
        at de.kugihan.dictionaryformids.general.Util.memCheck(+3)
        at de.kugihan.dictionaryformids.translation.Translation.getTranslationResult(+20)
        at de.kugihan.dictionaryformids.translation.TranslationThread.doTranslation(+220)
        at de.kugihan.dictionaryformids.translation.TranslationThread.runInForeground(+4)
        at de.kugihan.dictionaryformids.translation.TranslationExecution.executeTranslation(+46)
        at LwlPlay.commandAction(LwlPlay.java:92)
        at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(Display.java:2093)
        at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(Display.java:2929)
        at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(DefaultEventHandler.java:297)
        at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(AutomatedEventHandler.java:667)
        at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(DefaultEventHandler.java:711)
        at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(DefaultEventHandler.java:608)

if its set to true, I get an unhandeled java.lang.NullPointerException

If anyone can help me out I'd greatly appriciate it!

Cheers

John