Removed/commented out/tagged some unused local variables.

Added a JUnit test for the new Trie that fails at present since the Trie is
case-insensitive.  Running JUnit tests is not something our build system
knows about at present, but Eclipse 2.0 makes it very easy.

Fixed a few compiler errors due to imports I'd forgotten.
This commit is contained in:
dchandler 2002-11-02 16:01:40 +00:00
parent b8391e923d
commit a6cc4a7ff3
31 changed files with 292 additions and 179 deletions

View file

@ -21,6 +21,8 @@ package org.thdl.media;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.util.*; import java.util.*;
import org.thdl.util.ThdlDebug;
public class SmartPlayerFactory { public class SmartPlayerFactory {
/** You cannot instantiate this class. */ /** You cannot instantiate this class. */
private SmartPlayerFactory() { } private SmartPlayerFactory() { }
@ -33,7 +35,7 @@ public class SmartPlayerFactory {
for (int i=0; i<possiblePlayers.length; i++) { for (int i=0; i<possiblePlayers.length; i++) {
try { try {
Class mediaClass = Class.forName(possiblePlayers[i]); Class mediaClass = Class.forName(possiblePlayers[i]);
playerClasses.add(mediaClass); //FIXME: playerClasses.add(mediaClass);
SmartMoviePanel smp = (SmartMoviePanel)mediaClass.newInstance(); SmartMoviePanel smp = (SmartMoviePanel)mediaClass.newInstance();
moviePlayers.add(smp); moviePlayers.add(smp);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {

View file

@ -208,7 +208,7 @@ public class SmartQT4JPlayer extends SmartMoviePanel
//mechanism of internally of the TimeCallback. //mechanism of internally of the TimeCallback.
//Its recomended to use this Timer class to do callbacks , which would take care of the time base time changes and //Its recomended to use this Timer class to do callbacks , which would take care of the time base time changes and
//recscheduling of the tickle method . //recscheduling of the tickle method .
Timer timer = new Timer(1, 2, new Tickler(), getMovie() ); Timer timer = new Timer(1, 2, new Tickler(), getMovie() ); //FIXME: is this used?
// timer.setActive(true); // timer.setActive(true);
} }

View file

@ -96,8 +96,8 @@ public class QD extends JDesktopPane {
protected DuffPane sharedDP = new DuffPane(); protected DuffPane sharedDP = new DuffPane();
protected DuffPane sharedDP2 = new DuffPane(); protected DuffPane sharedDP2 = new DuffPane();
protected AbstractDocument findDoc = null; protected StyledDocument findDoc = null;
protected AbstractDocument replaceDoc = null; protected StyledDocument replaceDoc = null;
protected KeyStroke cutKey, copyKey, pasteKey, selectAllKey; protected KeyStroke cutKey, copyKey, pasteKey, selectAllKey;
protected KeyStroke insert1TimeKey, insert2TimesKey, insertSpeakerKey; protected KeyStroke insert1TimeKey, insert2TimesKey, insertSpeakerKey;
@ -700,7 +700,7 @@ public void setMedia(URL url) {
} }
public Project() { public Project() {
JPanel p = new JPanel(new GridLayout(2,2)); JPanel p = new JPanel(new GridLayout(2,2)); //FIXME: is this used?
titleField = new JTextField(); titleField = new JTextField();
int preferredHeight = titleField.getPreferredSize().height; int preferredHeight = titleField.getPreferredSize().height;
titleField.setPreferredSize(new Dimension(300, preferredHeight)); titleField.setPreferredSize(new Dimension(300, preferredHeight));
@ -775,11 +775,7 @@ public void changeKeyboard(JskadKeyboard kbd) {
public boolean saveTranscript() { public boolean saveTranscript() {
currentWork.stopWork(); currentWork.stopWork();
//URGENT!! fix saving problem //URGENT!! fix saving problem (FIXME: grep for URGENT and fix or Fix or FIX)
//change keyboard back to wylie for a second
DuffPane dp = (DuffPane)pane;
org.jdom.Element title = new org.jdom.Element("title"); org.jdom.Element title = new org.jdom.Element("title");
title.setText(project.getTitle().trim()); title.setText(project.getTitle().trim());
@ -840,7 +836,6 @@ public boolean saveTranscript() {
org.jdom.Element text = new org.jdom.Element("text"); org.jdom.Element text = new org.jdom.Element("text");
TibetanDocument doc = (TibetanDocument)pane.getDocument(); TibetanDocument doc = (TibetanDocument)pane.getDocument();
ImageIcon[] icons = sd.getSpeakerIcons();
int lastPoint = 0; int lastPoint = 0;
int k; int k;
for (k=0; k<doc.getLength(); k++) { for (k=0; k<doc.getLength(); k++) {
@ -893,7 +888,7 @@ public boolean saveTranscript() {
File htmlOut = new File(f.substring(0, f.lastIndexOf('.')) + ".html"); File htmlOut = new File(f.substring(0, f.lastIndexOf('.')) + ".html");
transformer.transform(new JDOMSource(qdDoc), new StreamResult(new FileOutputStream(htmlOut))); transformer.transform(new JDOMSource(qdDoc), new StreamResult(new FileOutputStream(htmlOut)));
//URGENT FIX SAVING PROBLEM //URGENT FIX SAVING PROBLEM (FIXME)
return true; return true;
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
@ -954,7 +949,7 @@ public boolean loadTranscript(File t) {
project = new Project(); project = new Project();
//change keyboard back to wylie for a second //change keyboard back to wylie for a second
DuffPane dp = (DuffPane)pane; // DuffPane dp = (DuffPane)pane;
//URGENT FIX LOADING PROBLEM //URGENT FIX LOADING PROBLEM
@ -1022,20 +1017,20 @@ if (keyboard_url != null) {
} }
org.jdom.Element text = qd.getChild("text"); org.jdom.Element text = qd.getChild("text");
// DuffPane dp = (DuffPane)pane; DuffPane dp = (DuffPane)pane;
TibetanDocument tDoc = (TibetanDocument)dp.getDocument(); TibetanDocument tDoc = (TibetanDocument)dp.getDocument();
if (tDoc.getLength() > 0) if (tDoc.getLength() > 0)
dp.setText(""); dp.setText("");
java.util.List textContent = text.getContent(); java.util.List textContent = text.getContent();
ImageIcon[] icons = sd.getSpeakerIcons(); ImageIcon[] icons = sd.getSpeakerIcons();
Iterator textIter = textContent.iterator(); Iterator textIter = textContent.iterator();
boolean wasLastComponent = true; // boolean wasLastComponent = true;
while (textIter.hasNext()) { while (textIter.hasNext()) {
Object nextContent = textIter.next(); Object nextContent = textIter.next();
if (nextContent instanceof org.jdom.Text) { if (nextContent instanceof org.jdom.Text) {
String wylie = ((org.jdom.Text)nextContent).getText(); String wylie = ((org.jdom.Text)nextContent).getText();
dp.toTibetanMachineWeb(wylie, tDoc.getLength()); dp.toTibetanMachineWeb(wylie, tDoc.getLength());
wasLastComponent = false; // wasLastComponent = false;
} }
else if (nextContent instanceof org.jdom.Element) { else if (nextContent instanceof org.jdom.Element) {
org.jdom.Element e = (org.jdom.Element)nextContent; org.jdom.Element e = (org.jdom.Element)nextContent;
@ -1050,7 +1045,7 @@ if (keyboard_url != null) {
} }
*/ */
new TimePoint(dp, clockIcon, Integer.valueOf(e.getAttributeValue("t"))); new TimePoint(dp, clockIcon, Integer.valueOf(e.getAttributeValue("t")));
wasLastComponent = true; // wasLastComponent = true;
} }
else if (e.getName().equals("who")) { else if (e.getName().equals("who")) {
/* if (!wasLastComponent) /* if (!wasLastComponent)
@ -1062,7 +1057,7 @@ if (keyboard_url != null) {
} }
*/ */
dp.insertComponent(new JLabel(" ", icons[Integer.parseInt(e.getAttributeValue("id"))], SwingConstants.LEFT)); dp.insertComponent(new JLabel(" ", icons[Integer.parseInt(e.getAttributeValue("id"))], SwingConstants.LEFT));
wasLastComponent = true; // wasLastComponent = true;
} }
} }
} }
@ -1534,7 +1529,7 @@ public JMenuBar getTextMenuBar() {
return bar; return bar;
} }
public int findNextText(int startPos, TibetanDocument sourceDoc, TibetanDocument findDoc) { public int findNextText(int startPos, StyledDocument sourceDoc, StyledDocument findDoc) {
if (startPos<0 || startPos>sourceDoc.getLength()-1) if (startPos<0 || startPos>sourceDoc.getLength()-1)
return -1; return -1;

View file

@ -146,8 +146,6 @@ public final class JdkVersionHacks {
// f.getToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH) // f.getToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)
// if possible. // if possible.
boolean success = false;
Method isFSSMethod = null; Method isFSSMethod = null;
try { try {
isFSSMethod isFSSMethod

View file

@ -262,7 +262,7 @@ public class Savant extends JDesktopPane
fullScreen.getContentPane().setBackground(Color.black); fullScreen.getContentPane().setBackground(Color.black);
Dimension screenSize = fullScreen.getToolkit().getScreenSize(); Dimension screenSize = fullScreen.getToolkit().getScreenSize();
Dimension videoSize = sp.getVisualComponent().getPreferredSize(); Dimension videoSize = sp.getVisualComponent().getPreferredSize();
Dimension controlSize = sp.getControlComponent().getPreferredSize(); // Dimension controlSize = sp.getControlComponent().getPreferredSize();
int videoWidth = videoSize.width; int videoWidth = videoSize.width;
int videoHeight = videoSize.height; int videoHeight = videoSize.height;
float vWidth = new Integer(videoWidth).floatValue(); float vWidth = new Integer(videoWidth).floatValue();

View file

@ -80,11 +80,11 @@ public class TibetanEnglish implements TranscriptView
Element current = null; Element current = null;
DuffData[] dd; DuffData[] dd;
DuffData[] space = TibTextUtils.getTibetanMachineWeb("_"); // DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet(); MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue); StyleConstants.setForeground(mas, Color.blue);
Position endPos = null; Position endPos = null;
int wherestart; // int wherestart;
TibetanDocument doc = new TibetanDocument(new StyleContext()); TibetanDocument doc = new TibetanDocument(new StyleContext());
@ -111,7 +111,7 @@ public class TibetanEnglish implements TranscriptView
} }
else else
{ {
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
} }
@ -153,7 +153,7 @@ public class TibetanEnglish implements TranscriptView
{ {
doc.insertString(endPos.getOffset(), "\n", null); doc.insertString(endPos.getOffset(), "\n", null);
String wylie = current.getAttributeValue("who"); String wylie = current.getAttributeValue("who");
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext()) if (iter.hasNext())
current = (org.jdom.Element)iter.next(); current = (org.jdom.Element)iter.next();

View file

@ -81,11 +81,11 @@ public class TibetanWylie implements TranscriptView
String wylie; String wylie;
DuffData[] dd; DuffData[] dd;
DuffData[] space = TibTextUtils.getTibetanMachineWeb("_"); // DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet(); MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue); StyleConstants.setForeground(mas, Color.blue);
Position endPos = null; Position endPos = null;
int wherestart; // int wherestart;
TibetanDocument doc = new TibetanDocument(new StyleContext()); TibetanDocument doc = new TibetanDocument(new StyleContext());
@ -112,7 +112,7 @@ public class TibetanWylie implements TranscriptView
} }
else else
{ {
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
} }
@ -154,7 +154,7 @@ public class TibetanWylie implements TranscriptView
{ {
doc.insertString(endPos.getOffset(), "\n", null); doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who"); wylie = current.getAttributeValue("who");
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext()) if (iter.hasNext())
current = (org.jdom.Element)iter.next(); current = (org.jdom.Element)iter.next();

View file

@ -80,13 +80,13 @@ public class TibetanWylieEnglish implements TranscriptView
Element current = null; Element current = null;
DuffData[] dd; DuffData[] dd;
DuffData[] space = TibTextUtils.getTibetanMachineWeb("_"); // DuffData[] space = TibTextUtils.getTibetanMachineWeb("_");
MutableAttributeSet mas = new SimpleAttributeSet(); MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue); StyleConstants.setForeground(mas, Color.blue);
MutableAttributeSet mas2 = new SimpleAttributeSet(); MutableAttributeSet mas2 = new SimpleAttributeSet();
StyleConstants.setItalic(mas2, true); StyleConstants.setItalic(mas2, true);
Position endPos = null; Position endPos = null;
int wherestart; // int wherestart;
String wylie; String wylie;
TibetanDocument doc = new TibetanDocument(new StyleContext()); TibetanDocument doc = new TibetanDocument(new StyleContext());
@ -113,7 +113,7 @@ public class TibetanWylieEnglish implements TranscriptView
} }
else else
{ {
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
} }
@ -156,7 +156,7 @@ public class TibetanWylieEnglish implements TranscriptView
{ {
doc.insertString(endPos.getOffset(), "\n", null); doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who"); wylie = current.getAttributeValue("who");
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext()) if (iter.hasNext())
current = (org.jdom.Element)iter.next(); current = (org.jdom.Element)iter.next();

View file

@ -83,7 +83,7 @@ public class Wylie implements TranscriptView
MutableAttributeSet mas = new SimpleAttributeSet(); MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue); StyleConstants.setForeground(mas, Color.blue);
Position endPos = null; Position endPos = null;
AbstractDocument doc = new TibetanDocument(new StyleContext()); StyledDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer(); idBuffer = new StringBuffer();
startBuffer = new StringBuffer(); startBuffer = new StringBuffer();

View file

@ -79,15 +79,14 @@ public class WylieEnglish implements TranscriptView
Iterator iter = elements.iterator(); Iterator iter = elements.iterator();
Element current = null; Element current = null;
DuffData[] dd;
MutableAttributeSet mas = new SimpleAttributeSet(); MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setForeground(mas, Color.blue); StyleConstants.setForeground(mas, Color.blue);
MutableAttributeSet mas2 = new SimpleAttributeSet(); MutableAttributeSet mas2 = new SimpleAttributeSet();
StyleConstants.setItalic(mas2, true); StyleConstants.setItalic(mas2, true);
Position endPos = null; Position endPos = null;
int wherestart; // int wherestart;
String wylie; String wylie;
AbstractDocument doc = new TibetanDocument(new StyleContext()); StyledDocument doc = new TibetanDocument(new StyleContext());
idBuffer = new StringBuffer(); idBuffer = new StringBuffer();
startBuffer = new StringBuffer(); startBuffer = new StringBuffer();
@ -112,7 +111,7 @@ public class WylieEnglish implements TranscriptView
} }
else else
{ {
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
} }
@ -153,7 +152,7 @@ public class WylieEnglish implements TranscriptView
{ {
doc.insertString(endPos.getOffset(), "\n", null); doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who"); wylie = current.getAttributeValue("who");
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext()) if (iter.hasNext())
current = (org.jdom.Element)iter.next(); current = (org.jdom.Element)iter.next();

View file

@ -92,7 +92,6 @@ public class All implements TranscriptView
StyleConstants.setFontFamily(mas3, "Monospaced"); StyleConstants.setFontFamily(mas3, "Monospaced");
StyleConstants.setFontSize(mas3, 14); StyleConstants.setFontSize(mas3, 14);
Position endPos = null; Position endPos = null;
int wherestart;
String wylie; String wylie;
idBuffer = new StringBuffer(); idBuffer = new StringBuffer();
@ -118,7 +117,7 @@ public class All implements TranscriptView
} }
else else
{ {
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
} }
@ -164,7 +163,7 @@ public class All implements TranscriptView
{ {
doc.insertString(endPos.getOffset(), "\n", null); doc.insertString(endPos.getOffset(), "\n", null);
wylie = current.getAttributeValue("who"); wylie = current.getAttributeValue("who");
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext()) if (iter.hasNext())
current = (org.jdom.Element)iter.next(); current = (org.jdom.Element)iter.next();

View file

@ -91,7 +91,6 @@ public class QuechuaEnglish implements TranscriptView
StyleConstants.setFontSize(mas2, 16); StyleConstants.setFontSize(mas2, 16);
StyleConstants.setFontSize(mas2, 16); StyleConstants.setFontSize(mas2, 16);
Position endPos = null; Position endPos = null;
int wherestart;
String wylie; String wylie;
idBuffer = new StringBuffer(); idBuffer = new StringBuffer();
@ -117,7 +116,7 @@ public class QuechuaEnglish implements TranscriptView
} }
else else
{ {
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
} }
@ -160,7 +159,7 @@ public class QuechuaEnglish implements TranscriptView
{ {
doc.insertString(endPos.getOffset(), "\n", mas0); doc.insertString(endPos.getOffset(), "\n", mas0);
wylie = current.getAttributeValue("who"); wylie = current.getAttributeValue("who");
wherestart = endPos.getOffset(); // wherestart = endPos.getOffset();
doc.insertString(endPos.getOffset(), wylie, mas); doc.insertString(endPos.getOffset(), wylie, mas);
if (iter.hasNext()) if (iter.hasNext())
current = (org.jdom.Element)iter.next(); current = (org.jdom.Element)iter.next();

View file

@ -1605,7 +1605,6 @@ public void paste(int offset) {
StringBuffer sb; StringBuffer sb;
AttributeSet attr; AttributeSet attr;
String fontName; String fontName;
int fontNum;
Position endPos; Position endPos;
int i; int i;
@ -1618,7 +1617,7 @@ public void paste(int offset) {
attr = doc.getCharacterElement(i).getAttributes(); attr = doc.getCharacterElement(i).getAttributes();
fontName = StyleConstants.getFontFamily(attr); fontName = StyleConstants.getFontFamily(attr);
if ((0 != (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) { if ((0 != TibetanMachineWeb.getTMWFontNumber(fontName)) || i==endPos.getOffset()) {
if (i != start) { if (i != start) {
try { try {
DuffData[] duffdata = TibTextUtils.getTibetanMachineWeb(sb.toString()); DuffData[] duffdata = TibTextUtils.getTibetanMachineWeb(sb.toString());
@ -1653,7 +1652,7 @@ public void paste(int offset) {
* document consists of both Tibetan and non-Tibetan fonts, however, * document consists of both Tibetan and non-Tibetan fonts, however,
* the conversion stops at the first non-Tibetan font. * the conversion stops at the first non-Tibetan font.
* @return the string of Wylie corresponding to the associated document * @return the string of Wylie corresponding to the associated document
* @see org.thdl.tib.text.TibetanDocument.getWylie() */ * @see org.thdl.tib.text.TibetanDocument#getWylie() */
public String getWylie() { public String getWylie() {
return doc.getWylie(); return doc.getWylie();
} }

View file

@ -26,6 +26,7 @@ import netscape.javascript.JSObject;
import org.thdl.tib.text.*; import org.thdl.tib.text.*;
import org.thdl.util.ThdlActionListener; import org.thdl.util.ThdlActionListener;
import org.thdl.util.ThdlDebug;
/** /**
* A version of Jskad which can be embedded into * A version of Jskad which can be embedded into

View file

@ -68,7 +68,6 @@ public class Jskad4JavaScript extends JApplet {
public void setWylie(String wylie) { public void setWylie(String wylie) {
try { try {
DuffData[] dd = TibTextUtils.getTibetanMachineWeb(wylie);
TibetanDocument t_doc = (TibetanDocument)jskad.dp.getDocument(); TibetanDocument t_doc = (TibetanDocument)jskad.dp.getDocument();
if (t_doc.getLength() > 0) if (t_doc.getLength() > 0)
jskad.dp.newDocument(); // DLC FIXME: is it intended that t_doc is the new document? Because it is the old document at present. jskad.dp.newDocument(); // DLC FIXME: is it intended that t_doc is the new document? Because it is the old document at present.

View file

@ -172,7 +172,6 @@ public class AppletScannerFilter extends JApplet implements ActionListener, Focu
Object clicked = e.getSource(); Object clicked = e.getSource();
StringSelection ss; StringSelection ss;
String s = null; String s = null;
int start, end;
if (clicked==aboutItem) if (clicked==aboutItem)
{ {

View file

@ -101,7 +101,9 @@ public class BinaryFileGenerator extends LinkedList
{ {
final short newDefiniendum=1, halfDefiniendum=2, definition=3; final short newDefiniendum=1, halfDefiniendum=2, definition=3;
short status=newDefiniendum; short status=newDefiniendum;
int marker, len, marker2, n=0, total=0, currentPage=0, currentLine=1; int marker, len, marker2;
// int n=0;
int currentPage=0, currentLine=1;
char ch; char ch;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(archivo))); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(archivo)));
String entrada="", s1="", s2="", currentLetter="", temp="", lastWeirdDefiniendum=""; String entrada="", s1="", s2="", currentLetter="", temp="", lastWeirdDefiniendum="";
@ -383,7 +385,7 @@ public class BinaryFileGenerator extends LinkedList
Link link, newLink; Link link, newLink;
BinaryFileGenerator ultimo; BinaryFileGenerator ultimo;
String firstSillable; String firstSillable;
int pos, marker = word.indexOf(" "), comp; int marker = word.indexOf(" "), comp;
if (marker<0) if (marker<0)
firstSillable = word; firstSillable = word;

View file

@ -102,7 +102,7 @@ class ConsoleScannerFilter
public void run() throws Exception public void run() throws Exception
{ {
String inStr, outStr; String inStr;
while ((inStr=in.readLine())!=null) while ((inStr=in.readLine())!=null)
{ {

View file

@ -22,10 +22,12 @@ import javax.swing.*;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.text.*; import javax.swing.text.*;
import java.io.Serializable;
import org.thdl.tib.input.DuffPane; import org.thdl.tib.input.DuffPane;
import org.thdl.util.ThdlDebug;
import org.thdl.tib.text.*; import org.thdl.tib.text.*;
import org.thdl.tib.text.DuffData; import org.thdl.tib.text.DuffData;
import java.io.Serializable;
/** Used by DictionaryTable to display a Tibetan word or phrase /** Used by DictionaryTable to display a Tibetan word or phrase
(in either Roman or Tibetan script) in a single cell. (in either Roman or Tibetan script) in a single cell.

View file

@ -201,7 +201,6 @@ class LocalTibetanScanner implements TibetanScanner
{ {
boolean isDeclined =false; boolean isDeclined =false;
int len = sil.length(); int len = sil.length();
String dev;
if (len<3) return null; if (len<3) return null;
@ -223,7 +222,6 @@ class LocalTibetanScanner implements TibetanScanner
public void scanBody(String in) public void scanBody(String in)
{ {
Word word;
boolean hayMasLineas=true; boolean hayMasLineas=true;
if (in.equals("")) finishUp(); if (in.equals("")) finishUp();
@ -263,7 +261,7 @@ class LocalTibetanScanner implements TibetanScanner
public void scanLine(String linea) public void scanLine(String linea)
{ {
int init = 0, fin, i; int init = 0, fin;
char ch; char ch;
String sil; String sil;
boolean doNotFinishUp; boolean doNotFinishUp;
@ -349,7 +347,6 @@ outAHere:
{ {
int i=wordList.size(); int i=wordList.size();
Token token[] = new Token[i]; Token token[] = new Token[i];
Object obj;
ListIterator li = wordList.listIterator(); ListIterator li = wordList.listIterator();
while(li.hasNext()) while(li.hasNext())
token[--i] = (Token)li.next(); token[--i] = (Token)li.next();
@ -366,7 +363,6 @@ outAHere:
{ {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(archivo + ".dic"))); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(archivo + ".dic")));
LinkedList ll1 = new LinkedList(), ll2 = new LinkedList(); LinkedList ll1 = new LinkedList(), ll2 = new LinkedList();
int i;
String s; String s;
while ((s=br.readLine())!=null) while ((s=br.readLine())!=null)
{ {

View file

@ -272,7 +272,7 @@ public class Manipulate
{ {
sil = sil.toLowerCase(); sil = sil.toLowerCase();
int i=0, len=sil.length(); int i=0;
char ch, ch2; char ch, ch2;
while (!isVowel(sil.charAt(i))) i++; while (!isVowel(sil.charAt(i))) i++;

View file

@ -85,7 +85,7 @@ public class MemorySyllableListTree extends LinkedList implements SyllableListTr
{ {
MemorySyllableListTree prefijo; MemorySyllableListTree prefijo;
String firstSillable; String firstSillable;
int pos, marker = word.indexOf(" "); int marker = word.indexOf(" ");
if (marker<0) if (marker<0)
firstSillable = word; firstSillable = word;

View file

@ -46,7 +46,7 @@ public class OnLineScannerFilter extends HttpServlet {
String parrafo = request.getParameter("parrafo"), checkboxName, script; String parrafo = request.getParameter("parrafo"), checkboxName, script;
DictionarySource ds=null; DictionarySource ds=null;
boolean checkedDicts[], allUnchecked, wantsTibetan; boolean checkedDicts[], allUnchecked, wantsTibetan;
int percent=100; // int percent=100;
out.println("<html>"); out.println("<html>");
out.println("<head>"); out.println("<head>");
@ -176,7 +176,7 @@ public class OnLineScannerFilter extends HttpServlet {
synchronized public void desglosar(String in, PrintWriter pw, boolean tibetan) synchronized public void desglosar(String in, PrintWriter pw, boolean tibetan)
{ {
boolean hayMasLineas=true; //boolean hayMasLineas=true;
//int init = 0, fin; //int init = 0, fin;
//String linea; //String linea;
Object words[]; Object words[];

View file

@ -125,7 +125,6 @@ public class RemoteTibetanScanner implements TibetanScanner
BufferedReader br = new BufferedReader(new InputStreamReader(uC.getInputStream())); BufferedReader br = new BufferedReader(new InputStreamReader(uC.getInputStream()));
LinkedList ll1 = new LinkedList(), ll2 = new LinkedList(); LinkedList ll1 = new LinkedList(), ll2 = new LinkedList();
int i;
String s; String s;
while ((s=br.readLine())!=null) while ((s=br.readLine())!=null)
{ {

View file

@ -258,7 +258,6 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
Object clicked = e.getSource(); Object clicked = e.getSource();
StringSelection ss; StringSelection ss;
String s = null; String s = null;
int start, end;
if (clicked == mnuAbout) if (clicked == mnuAbout)
{ {

View file

@ -99,7 +99,8 @@ public class Word extends Token
public String getLink(boolean tibetan) public String getLink(boolean tibetan)
{ {
String localWord, result; String localWord;
// String result;
if (wordSinDec==null) localWord = super.token; if (wordSinDec==null) localWord = super.token;
else localWord = wordSinDec; else localWord = wordSinDec;
if (tibetan) localWord = TibetanHTML.getHTML(localWord + " "); if (tibetan) localWord = TibetanHTML.getHTML(localWord + " ");

View file

@ -929,9 +929,6 @@ public class TibTextUtils {
if (dcs.length == 0) if (dcs.length == 0)
return null; return null;
AttributeSet attr;
String fontName;
int fontNum;
char ch; char ch;
String wylie; String wylie;
@ -944,7 +941,7 @@ public class TibTextUtils {
for (int i=start; i<dcs.length; i++) { for (int i=start; i<dcs.length; i++) {
ch = dcs[i].character; ch = dcs[i].character;
int k = dcs[i].charNum; int k = dcs[i].charNum;
fontNum = dcs[i].fontNum; // int fontNum = dcs[i].fontNum;
if (k < 32) { if (k < 32) {
if (wylieBuffer.length() > 0 || !glyphList.isEmpty()) { if (wylieBuffer.length() > 0 || !glyphList.isEmpty()) {

View file

@ -295,7 +295,7 @@ public class TibetanMachineWeb {
System.out.println("reading "+fileName); System.out.println("reading "+fileName);
String line; String line;
boolean hashOn = false; boolean hashOn = false;
boolean isSanskrit = false; boolean isSanskrit = false; //FIXME: this is never read.
boolean ignore = false; boolean ignore = false;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {

View file

@ -67,7 +67,7 @@ public class ThdlLazyExceptionTest extends TestCase {
junit.textui.TestRunner.run(ThdlLazyExceptionTest.class); junit.textui.TestRunner.run(ThdlLazyExceptionTest.class);
} }
/* /**
* Test for void ThdlLazyException() * Test for void ThdlLazyException()
*/ */
public void testThdlLazyException() { public void testThdlLazyException() {
@ -81,7 +81,7 @@ public class ThdlLazyExceptionTest extends TestCase {
} /* don't catch anything else. */ } /* don't catch anything else. */
} }
/* /**
* Test for void ThdlLazyException(String) * Test for void ThdlLazyException(String)
*/ */
public void testThdlLazyExceptionString() { public void testThdlLazyExceptionString() {
@ -91,7 +91,7 @@ public class ThdlLazyExceptionTest extends TestCase {
assertTrue(null == e.getRealException()); assertTrue(null == e.getRealException());
} }
/* /**
* Test for void ThdlLazyException(String, Throwable) * Test for void ThdlLazyException(String, Throwable)
*/ */
public void testThdlLazyExceptionStringThrowable() { public void testThdlLazyExceptionStringThrowable() {
@ -103,7 +103,7 @@ public class ThdlLazyExceptionTest extends TestCase {
assertTrue("bah".equals(e.getRealException().getMessage())); assertTrue("bah".equals(e.getRealException().getMessage()));
} }
/* /**
* Test for void ThdlLazyException(Throwable) * Test for void ThdlLazyException(Throwable)
*/ */
public void testThdlLazyExceptionThrowable() { public void testThdlLazyExceptionThrowable() {

View file

@ -88,115 +88,161 @@ package org.thdl.util;
public class Trie public class Trie
{ {
/** Size of the m_nextChar array. */ /** Size of the m_nextChar array. */
public static final int ALPHA_SIZE = 128; public static final int ALPHA_SIZE = 128;
/** The root node of the tree. */ /** The root node of the tree. */
Node m_Root; Node m_Root;
/**
* Constructs a trie.
*/
public Trie()
{
m_Root = new Node();
}
/**
* Puts an object into the trie for lookup.
*
* @param key must be a 7-bit ASCII string
* @param value any java object.
*
* @return The old object that matched key, or null.
*/
public Object put(String key, Object value)
{
final int len = key.length();
Node node = m_Root;
for (int i = 0; i < len; i++)
{
Node nextNode = node.m_nextChar[Character.toUpperCase(key.charAt(i))];
if (nextNode != null)
{
node = nextNode;
}
else
{
for (; i < len; i++)
{
Node newNode = new Node();
node.m_nextChar[Character.toUpperCase(key.charAt(i))] = newNode;
node = newNode;
}
break;
}
}
Object ret = node.m_Value;
node.m_Value = value;
return ret;
}
/**
* Gets an object that matches the key.
*
* @param key must be a 7-bit ASCII string
*
* @return The object that matches the key, or null.
*/
public Object get(String key)
{
final int len = key.length();
Node node = m_Root;
for (int i = 0; i < len; i++)
{
try
{
node = node.m_nextChar[Character.toUpperCase(key.charAt(i))];
}
catch (ArrayIndexOutOfBoundsException e)
{
// the key is not 7-bit ASCII so we won't find it here
node = null;
}
if (node == null)
return null;
}
return node.m_Value;
}
/**
* The node representation for the trie.
*/
class Node
{
/** /**
* Constructor, creates a Node[ALPHA_SIZE]. * Constructs a trie.
*/ */
Node() public Trie()
{ {
m_nextChar = new Node[ALPHA_SIZE]; m_Root = new Node();
m_Value = null;
} }
/** The next nodes. */ /**
Node m_nextChar[]; * Puts an object into the trie for lookup.
*
* @param key must be a 7-bit ASCII string
* @param value any java object, but not null.
*
* @return The old object that matched key, or null.
* @throws NullPointerException if value is null or if key is null
*/
public Object put(String key, Object value)
{
if (null == value) throw new NullPointerException();
/** The value. */ final int len = key.length();
Object m_Value; Node node = m_Root;
}
for (int i = 0; i < len; i++)
{
Node nextNode = node.m_nextChar[Character.toUpperCase(key.charAt(i))];
if (nextNode != null)
{
node = nextNode;
}
else
{
for (; i < len; i++)
{
Node newNode = new Node();
node.m_nextChar[Character.toUpperCase(key.charAt(i))] = newNode;
node.m_isLeaf = false;
node = newNode;
}
break;
}
}
Object ret = node.m_Value;
node.m_Value = value;
return ret;
}
/**
* Gets an object that matches the key.
*
* @param key must be a 7-bit ASCII string
*
* @return The object that matches the key, or null.
*/
public Object get(String key)
{
final int len = key.length();
Node node = m_Root;
for (int i = 0; i < len; i++)
{
try
{
node = node.m_nextChar[Character.toUpperCase(key.charAt(i))];
}
catch (ArrayIndexOutOfBoundsException e)
{
// the key is not 7-bit ASCII so we won't find it here
node = null;
}
if (node == null)
return null;
}
return node.m_Value;
}
/**
* Returns true if and only if key is a prefix of another, distinct
* member of the trie. Note that key may be in the trie as well as
* a prefix of something in the trie, but not all keys in the trie
* are prefixes of other keys. (In the trie you might naturally
* construct for the extended Wylie keyboard, "t" is a prefix, as is
* "ts", but "tsh", though a member of the trie, is not a prefix
* because there is no string x such that x begins with "tsh" but is
* not equal to "tsh" that is in the trie.)
*
* @param key must be a 7-bit ASCII string
*
* @return The object that matches the key, or null. */
public boolean hasPrefix(String key)
{
final int len = key.length();
Node node = m_Root;
for (int i = 0; i < len; i++)
{
try
{
node = node.m_nextChar[Character.toUpperCase(key.charAt(i))];
}
catch (ArrayIndexOutOfBoundsException e)
{
// the key is not 7-bit ASCII so we won't find it here
node = null;
}
if (node == null)
return false;
}
return !node.m_isLeaf;
}
/**
* The node representation for the trie.
*/
class Node
{
/**
* Constructor, creates a Node[ALPHA_SIZE].
*/
Node()
{
m_nextChar = new Node[ALPHA_SIZE];
m_Value = null;
m_isLeaf = true;
}
/** The next nodes. */
Node m_nextChar[];
/** The value. */
Object m_Value;
/** True if and only if this node has no children. */
boolean m_isLeaf;
}
} }

View file

@ -0,0 +1,81 @@
package org.thdl.util;
import junit.framework.TestCase;
/**
* @author David Chandler
*
* Tests {@link org.thdl.util.Trie} at the unit level.
*/
public class TrieTest extends TestCase {
/**
* Constructor for TrieTest.
* @param arg0
*/
public TrieTest(String arg0) {
super(arg0);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(TrieTest.class);
}
/**
* Tests that the trie distinguishes between uppercase and
* lowercase. */
public void testCaseSupport() {
Trie t = new Trie();
t.put("S", "S value");
assertTrue(t.get("S").equals("S value"));
assertTrue(null == t.get("s"));
t.put("Sh", "Sh value");
assertTrue(t.get("Sh").equals("Sh value"));
assertTrue(t.get("S").equals("S value"));
assertTrue(null == t.get("s"));
assertTrue(null == t.get("sh"));
assertTrue(null == t.get("SH"));
assertTrue(null == t.get("sH"));
}
/**
* Test for put(String, Object)
*/
public void testReplacement() {
Trie t = new Trie();
t.put("S", "S value 1");
assertTrue(t.get("S").equals("S value 1"));
t.put("S", "S value 2");
assertTrue(t.get("S").equals("S value 2"));
}
/**
* Tests that put(*, null) throws a NullPointerException.
*/
public void testPuttingNull() {
Trie t = new Trie();
boolean threw = false;
try {
t.put("heya", null);
} catch (NullPointerException e) {
threw = true;
}
assertTrue(threw);
}
/**
* Test for put(String, Object)
*/
public void testPrefix() {
Trie t = new Trie();
t.put("t", "t value");
t.put("ts", "ts value");
t.put("tsh", "tsh value");
assertTrue(t.get("t").equals("t value"));
assertTrue(t.get("ts").equals("ts value"));
assertTrue(t.get("tsh").equals("tsh value"));
assertTrue(t.hasPrefix("t"));
assertTrue(t.hasPrefix("ts"));
assertTrue(!t.hasPrefix("tsh"));
}
}