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:
parent
d836b850e8
commit
a7a573020f
12 changed files with 65 additions and 50 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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--;
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
The contents of this file are subject to the AMP Open Community License
|
||||
Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License on the AMP web site
|
||||
(http://www.tibet.iteso.mx/Guatemala/).
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific terms governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Initial Developer of this software is Andres Montano Pellegrini. Portions
|
||||
created by Andres Montano Pellegrini are Copyright 2001 Andres Montano
|
||||
Pellegrini. All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
package org.thdl.tib.scanner;
|
||||
import java.io.*;
|
||||
|
||||
/** Used by {@link LinkedList} to provide the implementation of a
|
||||
simple dynamic link list.
|
||||
|
||||
@author Andrés Montano Pellegrini
|
||||
@see LinkedList
|
||||
@see ListIterator
|
||||
*/
|
||||
|
||||
public class Link
|
||||
{
|
||||
private Object obj;
|
||||
public Link siguiente;
|
||||
|
||||
public Link(Object obj)
|
||||
{
|
||||
this.obj = obj;
|
||||
siguiente = null;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
public Link createNext(Object obj)
|
||||
{
|
||||
return siguiente = new Link(obj);
|
||||
}
|
||||
|
||||
public Link createPrevious(Object obj)
|
||||
{
|
||||
Link l = new Link(obj);
|
||||
l.siguiente=this;
|
||||
return l;
|
||||
}
|
||||
|
||||
public Object get()
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
public Link next()
|
||||
{
|
||||
return this.siguiente;
|
||||
}
|
||||
public int size()
|
||||
{
|
||||
int n=0;
|
||||
Link actual = this;
|
||||
while (actual != null)
|
||||
{
|
||||
n++;
|
||||
actual = actual.next();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new Link(obj);
|
||||
}
|
||||
|
||||
public void insertSorted(Link link)
|
||||
{
|
||||
if (siguiente==null)
|
||||
siguiente = link;
|
||||
else
|
||||
if (link.toString().compareTo(siguiente.toString())<=0)
|
||||
{
|
||||
link.siguiente = siguiente;
|
||||
siguiente = link;
|
||||
}
|
||||
else siguiente.insertSorted(link);
|
||||
}
|
||||
|
||||
public Link sort()
|
||||
{
|
||||
Link newCabeza = (Link) clone(), next = next(), newLink;
|
||||
while (next!=null)
|
||||
{
|
||||
newLink = (Link) next.clone();
|
||||
if (newLink.toString().compareTo(newCabeza.toString())<=0)
|
||||
{
|
||||
newLink.siguiente = newCabeza;
|
||||
newCabeza = newLink;
|
||||
}
|
||||
else newCabeza.insertSorted(newLink);
|
||||
next = next.next();
|
||||
}
|
||||
return newCabeza;
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
The contents of this file are subject to the AMP Open Community License
|
||||
Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License on the AMP web site
|
||||
(http://www.tibet.iteso.mx/Guatemala/).
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific terms governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Initial Developer of this software is Andres Montano Pellegrini. Portions
|
||||
created by Andres Montano Pellegrini are Copyright 2001 Andres Montano
|
||||
Pellegrini. All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
package org.thdl.tib.scanner;
|
||||
import java.util.*;
|
||||
|
||||
/** Implementation of a simple dynamic link list. Be careful with word order!
|
||||
|
||||
@author Andrés Montano Pellegrini
|
||||
@see Link
|
||||
@see ListIterator
|
||||
*/
|
||||
public class LinkedList
|
||||
{
|
||||
protected Link cabeza;
|
||||
public LinkedList()
|
||||
{
|
||||
cabeza=null;
|
||||
}
|
||||
|
||||
private LinkedList(Link cabeza)
|
||||
{
|
||||
this.cabeza = cabeza;
|
||||
}
|
||||
|
||||
public void addLast(Object o)
|
||||
{
|
||||
if (cabeza==null)
|
||||
{
|
||||
cabeza = new Link(o);
|
||||
}
|
||||
else cabeza = cabeza.createPrevious(o);
|
||||
}
|
||||
|
||||
public Object getLast()
|
||||
{
|
||||
if (cabeza==null) return null;
|
||||
else return cabeza.get();
|
||||
}
|
||||
|
||||
public ListIterator listIterator()
|
||||
{
|
||||
return new ListIterator(cabeza);
|
||||
}
|
||||
|
||||
public ListIterator listIterator(int n)
|
||||
{
|
||||
return new ListIterator(cabeza, n);
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return cabeza==null;
|
||||
}
|
||||
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
Link current=cabeza;
|
||||
while (current!=null)
|
||||
{
|
||||
if (current.get().equals(o)) return true;
|
||||
current = current.next();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
if (cabeza==null) return 0;
|
||||
return cabeza.size();
|
||||
}
|
||||
|
||||
public LinkedList sort()
|
||||
{
|
||||
return new LinkedList(cabeza.sort());
|
||||
}
|
||||
|
||||
public Object[] toArray()
|
||||
{
|
||||
int n = size();
|
||||
if (n==0) return null;
|
||||
Object array[] = new Object[n];
|
||||
ListIterator li = listIterator();
|
||||
while (li.hasNext())
|
||||
{
|
||||
n--;
|
||||
array[n] = li.next();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public String[] toStringArray()
|
||||
{
|
||||
int n = size();
|
||||
if (n==0) return null;
|
||||
Object o;
|
||||
String array[] = new String[n];
|
||||
ListIterator li = listIterator();
|
||||
while (li.hasNext())
|
||||
{
|
||||
n--;
|
||||
o = li.next();
|
||||
if (o==null) array[n]=null;
|
||||
else array[n] = o.toString();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
The contents of this file are subject to the AMP Open Community License
|
||||
Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License on the AMP web site
|
||||
(http://www.tibet.iteso.mx/Guatemala/).
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific terms governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Initial Developer of this software is Andres Montano Pellegrini. Portions
|
||||
created by Andres Montano Pellegrini are Copyright 2001 Andres Montano
|
||||
Pellegrini. All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
package org.thdl.tib.scanner;
|
||||
import java.util.*;
|
||||
|
||||
/** Used by {@link LinkedList} to provide the implementation of a
|
||||
simple dynamic link list.
|
||||
|
||||
@author Andrés Montano Pellegrini
|
||||
@see LinkedList
|
||||
@see Link
|
||||
*/
|
||||
|
||||
public class ListIterator
|
||||
{
|
||||
Link current;
|
||||
|
||||
public ListIterator(Link current)
|
||||
{
|
||||
this.current=current;
|
||||
}
|
||||
|
||||
public ListIterator(Link current, int n)
|
||||
{
|
||||
this(current);
|
||||
int i;
|
||||
for (i=0; i<n; i++) current=current.next();
|
||||
}
|
||||
|
||||
public boolean hasNext()
|
||||
{
|
||||
return current!=null;
|
||||
}
|
||||
|
||||
public Object next()
|
||||
{
|
||||
Object o = current.get();
|
||||
current = current.next();
|
||||
return o;
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue