Renamed LinkedList to SimplifiedLinkList and moved it from org.thdl.tib.scanner to org.thdl.util. This linked list was implemented because the VM running on handhelds does not include java.util.LinkedList.

This commit is contained in:
amontano 2003-04-01 13:08:38 +00:00
parent d836b850e8
commit a7a573020f
12 changed files with 65 additions and 50 deletions

View file

@ -18,6 +18,10 @@ Contributor(s): ______________________________________.
package org.thdl.tib.scanner;
import java.io.*;
import org.thdl.util.SimplifiedLinkedList;
import org.thdl.util.SimplifiedListIterator;
import org.thdl.util.Link;
/** Converts Tibetan dictionaries stored in text files
into a binary file tree structure format, to be used
@ -144,7 +148,7 @@ myglossary_uma.txt</i> in the transliteration format explained above.<br>
@see FileSyllableListTree
@see CachedSyllableListTree
*/
public class BinaryFileGenerator extends LinkedList
public class BinaryFileGenerator extends SimplifiedLinkedList
{
private long posHijos;
private String sil, def[];
@ -628,7 +632,8 @@ public class BinaryFileGenerator extends LinkedList
private void print() throws Exception
{
long pos;
ListIterator i = listIterator();
SimplifiedListIterator i = listIterator();
BinaryFileGenerator silHijos;
boolean hasNext;

View file

@ -18,6 +18,7 @@ Contributor(s): ______________________________________.
package org.thdl.tib.scanner;
import java.io.*;
import org.thdl.util.*;
/** Provides recommended implementation of the {@link SyllableListTree}
(currently most efficient memory-speed combination) loading
@ -43,7 +44,7 @@ public class CachedSyllableListTree implements SyllableListTree
int i;
FileSyllableListTree.openFiles(archivo);
long posLista = FileSyllableListTree.wordRaf.length() - 4;
LinkedList syllables = new LinkedList();
SimplifiedLinkedList syllables = new SimplifiedLinkedList();
FileSyllableListTree.wordRaf.seek(posLista);
posLista = (long) FileSyllableListTree.wordRaf.readInt();
@ -67,7 +68,7 @@ public class CachedSyllableListTree implements SyllableListTree
int n = syllables.size();
this.syllables = new SyllableListTree[n];
ListIterator li = syllables.listIterator();
SimplifiedListIterator li = syllables.listIterator();
while (li.hasNext())
{
n--;

View file

@ -17,9 +17,10 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import org.thdl.util.*;
import java.io.*;
import java.net.*;
import java.util.*;
/** Inputs a Tibetan text and displays the words with their
definitions through the console over a shell. Use when no
@ -94,8 +95,8 @@ public class ConsoleScannerFilter
public void printWords()
{
LinkedList words = scanner.getTokenLinkedList();
ListIterator i = words.listIterator();
SimplifiedLinkedList words = scanner.getTokenLinkedList();
SimplifiedListIterator i = words.listIterator();
Token token;
while (i.hasNext())
{

View file

@ -17,8 +17,10 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import java.util.*;
import org.thdl.util.*;
import java.io.*;
import java.util.Vector;
import java.util.Enumeration;
/** Loads dictionary stored in tree format and searches for words recursively.
How the the dictionary is loaded depends on which implementation of
@ -33,7 +35,7 @@ public class LocalTibetanScanner implements TibetanScanner
private SyllableListTree raiz, silActual, lastCompSil, silAnterior;
private String wordActual, lastCompWord;
private Vector floatingSil;
private LinkedList wordList;
private SimplifiedLinkedList wordList;
private static String endOfParagraphMarks = "/;|!:[]^@#$%=<>(){}";
private static String endOfSyllableMarks = " _\t";
@ -44,7 +46,7 @@ public class LocalTibetanScanner implements TibetanScanner
public void clearTokens()
{
wordList = new LinkedList();
wordList = new SimplifiedLinkedList();
}
public DictionarySource getDictionarySource()
@ -60,7 +62,7 @@ public class LocalTibetanScanner implements TibetanScanner
// raiz = new FileSyllableListTree(archivo);
raiz = new CachedSyllableListTree(archivo);
floatingSil = new Vector();
wordList = new LinkedList();
wordList = new SimplifiedLinkedList();
resetAll();
}
@ -375,7 +377,7 @@ outAHere:
}
}
public LinkedList getTokenLinkedList()
public SimplifiedLinkedList getTokenLinkedList()
{
return wordList;
}
@ -384,7 +386,7 @@ outAHere:
{
int i=wordList.size();
Token token[] = new Token[i];
ListIterator li = wordList.listIterator();
SimplifiedListIterator li = wordList.listIterator();
while(li.hasNext())
token[--i] = (Token)li.next();
return token;
@ -399,7 +401,7 @@ outAHere:
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(archivo + ".dic")));
LinkedList ll1 = new LinkedList(), ll2 = new LinkedList();
SimplifiedLinkedList ll1 = new SimplifiedLinkedList(), ll2 = new SimplifiedLinkedList();
String s;
while ((s=br.readLine())!=null)
{

View file

@ -17,6 +17,8 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import org.thdl.util.*;
import java.util.*;
import java.io.*;
@ -34,7 +36,7 @@ import java.io.*;
@see BinaryFileGenerator
*/
public class MemorySyllableListTree extends LinkedList implements SyllableListTree
public class MemorySyllableListTree extends SimplifiedLinkedList implements SyllableListTree
{
protected String sil, def;
@ -171,7 +173,7 @@ public class MemorySyllableListTree extends LinkedList implements SyllableListTr
}
MemorySyllableListTree silHijos;
ListIterator i = listIterator();
SimplifiedListIterator i = listIterator();
while (i.hasNext())
{
silHijos = (MemorySyllableListTree) i.next();
@ -182,7 +184,7 @@ public class MemorySyllableListTree extends LinkedList implements SyllableListTr
public SyllableListTree lookUp(String silStr)
{
MemorySyllableListTree sil;
ListIterator i = listIterator();
SimplifiedListIterator i = listIterator();
while (i.hasNext())
{
sil = (MemorySyllableListTree) i.next();

View file

@ -17,14 +17,15 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import org.thdl.util.*;
import org.thdl.tib.text.TibetanHTML;
import java.util.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.thdl.tib.text.TibetanHTML;
import org.thdl.util.ThdlOptions;
/** Interfase to provide access to an on-line dictionary through a form in html;
Inputs Tibetan text (Roman script only) and displays the
@ -267,7 +268,7 @@ public class OnLineScannerFilter extends HttpServlet {
public void printAllDefs(PrintWriter pw, Object words[], boolean tibetan)
{
LinkedList temp = new LinkedList();
SimplifiedLinkedList temp = new SimplifiedLinkedList();
int i;
Word word;
Definitions defs;
@ -283,7 +284,7 @@ public class OnLineScannerFilter extends HttpServlet {
}
}
ListIterator li = temp.listIterator();
SimplifiedListIterator li = temp.listIterator();
String tag;
pw.println("<table border=\"1\" width=\"100%\">");
while (li.hasNext())

View file

@ -17,6 +17,7 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import org.thdl.util.*;
import java.util.*;
import java.io.*;
import java.text.*;
@ -47,7 +48,7 @@ public class RemoteScannerFilter extends GenericServlet
{
BufferedReader br;
res.setContentType ("text/plain");
LinkedList words;
SimplifiedLinkedList words;
Word word;
PrintWriter out = res.getWriter();
int i;
@ -86,7 +87,7 @@ public class RemoteScannerFilter extends GenericServlet
words = scanner.getTokenLinkedList();
Token token;
ListIterator li = words.listIterator();
SimplifiedListIterator li = words.listIterator();
while (li.hasNext())
{

View file

@ -17,6 +17,7 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import org.thdl.util.*;
import java.net.*;
import java.io.*;
@ -30,14 +31,14 @@ import java.io.*;
public class RemoteTibetanScanner implements TibetanScanner
{
private String url;
private LinkedList wordList;
private SimplifiedLinkedList wordList;
private DictionarySource defSourcesWanted;
public RemoteTibetanScanner(String url) throws Exception
{
defSourcesWanted = DictionarySource.getAllDictionaries();
this.url = url;
wordList = new LinkedList();
wordList = new SimplifiedLinkedList();
}
/** dont use */
@ -89,21 +90,21 @@ public class RemoteTibetanScanner implements TibetanScanner
}
}
public LinkedList getTokenLinkedList()
public SimplifiedLinkedList getTokenLinkedList()
{
return wordList;
}
public void clearTokens()
{
wordList = new LinkedList();
wordList = new SimplifiedLinkedList();
}
public Token[] getTokenArray()
{
int i=0;
Token token[] = new Token[wordList.size()];
ListIterator li = wordList.listIterator();
SimplifiedListIterator li = wordList.listIterator();
while(li.hasNext())
token[i++] = (Token)li.next();
return token;
@ -131,7 +132,7 @@ public class RemoteTibetanScanner implements TibetanScanner
uC.setRequestProperty("Content-type", "text/plain");
BufferedReader br = new BufferedReader(new InputStreamReader(uC.getInputStream()));
LinkedList ll1 = new LinkedList(), ll2 = new LinkedList();
SimplifiedLinkedList ll1 = new SimplifiedLinkedList(), ll2 = new SimplifiedLinkedList();
String s;
while ((s=br.readLine())!=null)
{

View file

@ -17,8 +17,7 @@ Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
import java.util.*;
import org.thdl.util.ThdlVersion;
import org.thdl.util.*;
/** Defines the core methods required to provide access to a dictionary; local or remote.
@ -41,7 +40,7 @@ public interface TibetanScanner
public void scanLine(String linea);
public void scanBody(String linea);
public void finishUp();
public LinkedList getTokenLinkedList();
public SimplifiedLinkedList getTokenLinkedList();
public Token[] getTokenArray();
public void clearTokens();
public DictionarySource getDictionarySource();

View file

@ -16,7 +16,7 @@ Pellegrini. All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
package org.thdl.util;
import java.io.*;
/** Used by {@link LinkedList} to provide the implementation of a

View file

@ -16,24 +16,26 @@ Pellegrini. All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
package org.thdl.util;
import java.util.*;
/** Implementation of a simple dynamic link list. Be careful with word order!
Why not just use java.util.LinkedList? It is not supported for the
handheld's virtual machine.
@author Andr&eacute;s Montano Pellegrini
@see Link
@see ListIterator
@see SimplifiedListIterator
*/
public class LinkedList
public class SimplifiedLinkedList
{
protected Link cabeza;
public LinkedList()
public SimplifiedLinkedList()
{
cabeza=null;
}
private LinkedList(Link cabeza)
private SimplifiedLinkedList(Link cabeza)
{
this.cabeza = cabeza;
}
@ -53,14 +55,14 @@ public class LinkedList
else return cabeza.get();
}
public ListIterator listIterator()
public SimplifiedListIterator listIterator()
{
return new ListIterator(cabeza);
return new SimplifiedListIterator(cabeza);
}
public ListIterator listIterator(int n)
public SimplifiedListIterator listIterator(int n)
{
return new ListIterator(cabeza, n);
return new SimplifiedListIterator(cabeza, n);
}
public boolean isEmpty()
@ -85,9 +87,9 @@ public class LinkedList
return cabeza.size();
}
public LinkedList sort()
public SimplifiedLinkedList sort()
{
return new LinkedList(cabeza.sort());
return new SimplifiedLinkedList(cabeza.sort());
}
public Object[] toArray()
@ -95,7 +97,7 @@ public class LinkedList
int n = size();
if (n==0) return null;
Object array[] = new Object[n];
ListIterator li = listIterator();
SimplifiedListIterator li = listIterator();
while (li.hasNext())
{
n--;
@ -110,7 +112,7 @@ public class LinkedList
if (n==0) return null;
Object o;
String array[] = new String[n];
ListIterator li = listIterator();
SimplifiedListIterator li = listIterator();
while (li.hasNext())
{
n--;

View file

@ -16,7 +16,7 @@ Pellegrini. All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.tib.scanner;
package org.thdl.util;
import java.util.*;
/** Used by {@link LinkedList} to provide the implementation of a
@ -27,16 +27,16 @@ import java.util.*;
@see Link
*/
public class ListIterator
public class SimplifiedListIterator
{
Link current;
public ListIterator(Link current)
public SimplifiedListIterator(Link current)
{
this.current=current;
}
public ListIterator(Link current, int n)
public SimplifiedListIterator(Link current, int n)
{
this(current);
int i;