From 107fcce56502613db5605c82a2aa50d2340959cf Mon Sep 17 00:00:00 2001 From: amontano Date: Sun, 27 Feb 2005 05:48:03 +0000 Subject: [PATCH] Added debug info to the servlet version. --- .../tib/scanner/DictionaryTableModel.java | 12 +-- .../thdl/tib/scanner/DuffScannerPanel.java | 74 ++++++------- .../tib/scanner/FileSyllableListTree.java | 98 ++++++++--------- .../thdl/tib/scanner/LocalTibetanScanner.java | 12 +-- .../thdl/tib/scanner/OnLineScannerFilter.java | 83 +++++++------- .../thdl/tib/scanner/RemoteScannerFilter.java | 20 ++-- .../org/thdl/tib/scanner/ScannerLogger.java | 9 +- .../org/thdl/tib/scanner/TibetanScanner.java | 102 +++++++++--------- 8 files changed, 210 insertions(+), 200 deletions(-) diff --git a/source/org/thdl/tib/scanner/DictionaryTableModel.java b/source/org/thdl/tib/scanner/DictionaryTableModel.java index 12e1596..b12270a 100644 --- a/source/org/thdl/tib/scanner/DictionaryTableModel.java +++ b/source/org/thdl/tib/scanner/DictionaryTableModel.java @@ -61,12 +61,12 @@ public class DictionaryTableModel extends AbstractTableModel { switch(column) { - case 0: - if (tibetanActivated) return arrayTibetan[row]; - else return array[row].getWylie(); - case 1: return array[row].getDefPreview(); - default: return array[row].toString(); - } + case 0: + if (tibetanActivated) return arrayTibetan[row]; + else return array[row].getWylie(); + case 1: return array[row].getDefPreview(); + default: return array[row].toString(); + } } diff --git a/source/org/thdl/tib/scanner/DuffScannerPanel.java b/source/org/thdl/tib/scanner/DuffScannerPanel.java index 50286c1..cefd292 100644 --- a/source/org/thdl/tib/scanner/DuffScannerPanel.java +++ b/source/org/thdl/tib/scanner/DuffScannerPanel.java @@ -208,50 +208,50 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener public void clear() { - txtInput.setText(""); - duffInput.setText(""); - fullDef.setText(""); - model.newSearch(null); - table.tableChanged(new TableModelEvent(model)); + txtInput.setText(""); + duffInput.setText(""); + fullDef.setText(""); + model.newSearch(null); + table.tableChanged(new TableModelEvent(model)); table.repaint(); } public void translate() { - String in; - setDicts(scanner.getDictionarySource()); + String in; + setDicts(scanner.getDictionarySource()); - in = ""; - if (showingTibetan) - in = duffInput.getWylie(new boolean[] { false }); - else - in = txtInput.getText(); + in = ""; + if (showingTibetan) + in = duffInput.getWylie(new boolean[] { false }); + else + in = txtInput.getText(); - if (!in.equals("")) - { - doingStatus("Translating..."); - scanner.scanBody(in); - scanner.finishUp(); - model.newSearch(scanner.getWordArray()); -// printAllDefs(); - scanner.clearTokens(); - returnStatusToNorm(); - fullDef.setText(""); -/* ListSelectionModel lsm = (ListSelectionModel)table.getSelectionModel(); - if (!lsm.isSelectionEmpty()) - { - int selectedRow = lsm.getMinSelectionIndex(); - //TableModel tm = table.getModel(); - if (selectedRow"); @@ -389,7 +388,7 @@ public class OnLineScannerFilter extends HttpServlet { int i, j; Word words[]; - SwingWord word; + SwingWord word=null; Definitions defs; String tag; DictionarySource ds; @@ -402,38 +401,48 @@ public class OnLineScannerFilter extends HttpServlet for (j=0; j"); - tag = ds.getTag(0); - // else tag = null; - /*if (tag!=null) - {*/ - pw.println(" "+ word.getBookmark(tibetan) +""); - pw.println(" "+ tag +""); - pw.println(" " + defs.def[0] + ""); - /*} - else - { - pw.println(" "+ words[j].getBookmark(tibetan) +""); - pw.println(" " + defs.def[0] + ""); - }*/ - pw.println(" "); - for (i=1; i"); - if (ds!=null) tag = ds.getTag(i); - else tag = null; - if (tag!=null) - { - pw.println(" "+ tag +""); - pw.println(" " + defs.def[i] + ""); - } - else pw.println(" " + defs.def[i] + ""); - pw.println(" "); - } + try + { + + word = new SwingWord(words[j]); + defs = word.getDefs(); + ds = defs.getDictionarySource(); + if (ds==null || ds.isEmpty()) continue; + pw.println(" "); + tag = ds.getTag(0); + // else tag = null; + /*if (tag!=null) + {*/ + pw.println(" "+ word.getBookmark(tibetan) +""); + pw.println(" "+ tag +""); + pw.println(" " + defs.def[0] + ""); + /*} + else + { + pw.println(" "+ words[j].getBookmark(tibetan) +""); + pw.println(" " + defs.def[0] + ""); + }*/ + pw.println(" "); + for (i=1; i"); + if (ds!=null) tag = ds.getTag(i); + else tag = null; + if (tag!=null) + { + pw.println(" "+ tag +""); + pw.println(" " + defs.def[i] + ""); + } + else pw.println(" " + defs.def[i] + ""); + pw.println(" "); + } + } + catch (Exception e) + { + sl.writeLog("Crash\tOnLineScannerFilter\t" + word.getWylie()); + sl.writeException(e); + } + } pw.println(""); } diff --git a/source/org/thdl/tib/scanner/RemoteScannerFilter.java b/source/org/thdl/tib/scanner/RemoteScannerFilter.java index 9a0c105..315be2c 100644 --- a/source/org/thdl/tib/scanner/RemoteScannerFilter.java +++ b/source/org/thdl/tib/scanner/RemoteScannerFilter.java @@ -62,8 +62,7 @@ public class RemoteScannerFilter extends GenericServlet res.setContentType ("text/plain"); sl.setUserIP(req.getRemoteAddr()); - Token token[] = null; - Word word = null; + Word word = null, words[] = null; PrintWriter out; try @@ -117,28 +116,29 @@ public class RemoteScannerFilter extends GenericServlet } - /* FIXME: sometimes getDef returns raises a NullPointerException. + /* FIXME: sometimes getDef raises a NullPointerException. In the meantime, I'll just keep it from crashing */ sl.writeLog("Translation\tRemoteScannerFilter"); try { + scanner.clearTokens(); while((linea = br.readLine())!= null) scanner.scanLine(linea); br.close(); scanner.finishUp(); - token = scanner.getTokenArray(); + words = scanner.getWordArray(); - for (i=0; i