dasher
Class CAlphIO

java.lang.Object
  extended by dasher.CAlphIO

public class CAlphIO
extends java.lang.Object

Responsible for reading a given list of XML files, extracting alphabet information, and creating a list of AlphInfo objects for each.

Further, after doing so, responsible for returning an AlphInfo object corresponding to a given alphabet name, and of giving a full list of available alphabets.


Nested Class Summary
(package private) static class CAlphIO.AlphInfo
          Simple struct representing an alphabet.
(package private) static class CAlphIO.character
          Simple struct representing a character in an alphabet.
 
Field Summary
protected  java.util.HashMap<java.lang.String,CAlphIO.AlphInfo> Alphabets
          Map from Strings to AlphInfo objects, used in getting an alphabet by name.
protected  java.util.ArrayList<java.lang.String> Filenames
          List of filenames to parse.
 boolean LoadMutable
          Whether the loaded alphabet may be altered.
 CDasherInterfaceBase m_Interface
          Pointer to the DasherInterfaceBase which requested this enumeration.
protected  javax.xml.parsers.SAXParser parser
          Parser to be used to import XML data.
 java.util.HashMap<java.lang.String,java.lang.Integer> StoT
          Map from String alphabet types to enumerated constants (members of Opts.AlphabetTypes).
protected  java.lang.String SystemLocation
          Path of system resource files, used in the course of locating DTD files where necessary.
 java.util.HashMap<java.lang.Integer,java.lang.String> TtoS
          Map from Opts.AlphabetTypes constants to their String names.
protected  java.lang.String UserLocation
          Path of user resource files, used in the course of locating DTD files where necessary.
 
Constructor Summary
CAlphIO(java.lang.String SysLoc, java.lang.String UserLoc, java.util.ArrayList<java.lang.String> Fnames, CDasherInterfaceBase Interface)
          Sole constructor.
 
Method Summary
protected  void CreateDefault()
          Creates the default alphabet and stores as an available alphabet.
 void Delete(java.lang.String AlphID)
          Removes a given alphabet; it will no longer appear in enumerations of alphabets.
 void GetAlphabets(java.util.Collection<java.lang.String> AlphabetList)
          Fills the passed Collection with the names of all available alphabets.
 java.lang.String GetDefault()
          Retrieves the name of the default alphabet.
 CAlphIO.AlphInfo GetInfo(java.lang.String AlphID)
          Returns an AlphInfo object representing the alphabet with a given name.
 void ParseFile(java.lang.String filename)
          Parse a given XML file for alphabets.
 void Save(java.lang.String AlphID)
          Stub.
 void SetInfo(CAlphIO.AlphInfo NewInfo)
          Registers a new AlphInfo object as a valid alphabet, which will henceforth be included in enumerations of available alphabets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Interface

public CDasherInterfaceBase m_Interface
Pointer to the DasherInterfaceBase which requested this enumeration. This is only used for the purposes of trying Applet-style resource retrieval, and may safely be set to null if this is not required.


SystemLocation

protected java.lang.String SystemLocation
Path of system resource files, used in the course of locating DTD files where necessary.


UserLocation

protected java.lang.String UserLocation
Path of user resource files, used in the course of locating DTD files where necessary.


Alphabets

protected java.util.HashMap<java.lang.String,CAlphIO.AlphInfo> Alphabets
Map from Strings to AlphInfo objects, used in getting an alphabet by name.


Filenames

protected java.util.ArrayList<java.lang.String> Filenames
List of filenames to parse.


StoT

public java.util.HashMap<java.lang.String,java.lang.Integer> StoT
Map from String alphabet types to enumerated constants (members of Opts.AlphabetTypes).


TtoS

public java.util.HashMap<java.lang.Integer,java.lang.String> TtoS
Map from Opts.AlphabetTypes constants to their String names.


LoadMutable

public boolean LoadMutable
Whether the loaded alphabet may be altered.


parser

protected javax.xml.parsers.SAXParser parser
Parser to be used to import XML data.

Constructor Detail

CAlphIO

public CAlphIO(java.lang.String SysLoc,
               java.lang.String UserLoc,
               java.util.ArrayList<java.lang.String> Fnames,
               CDasherInterfaceBase Interface)
Sole constructor. This will parse the list of files given in Fnames by attempting both ordinary file I/O and applet-style web retrieval. Once the constructor terminates, all XML files have been read and the object is ready to be queried for alphabet names.

Parameters:
SysLoc - System data location, for retrieval of DTD files. Optional; if not supplied, this location will not be considered for DTD location.
UserLoc - User data location, for retrieval of DTD files. Optional; if not supplied, this location will not be considered for DTD location.
Fnames - Filenames to parse; these may be relative or absolute.
Interface - Reference to the InterfaceBase parent class for applet-style IO. Optional; if not supplied, applet-style IO will fail.
Method Detail

ParseFile

public void ParseFile(java.lang.String filename)
Parse a given XML file for alphabets. Any resulting alphabets will be added to the internal buffer ready for retrieval using GetInfo or GetAlphabets.

Parameters:
filename - File to parse

GetAlphabets

public void GetAlphabets(java.util.Collection<java.lang.String> AlphabetList)
Fills the passed Collection with the names of all available alphabets.

Parameters:
AlphabetList - Collection to be filled.

GetDefault

public java.lang.String GetDefault()
Retrieves the name of the default alphabet. At present this will return English with limited punctuation if available, or Default if not.

Returns:
Name of a reasonable default alphabet.

GetInfo

public CAlphIO.AlphInfo GetInfo(java.lang.String AlphID)
Returns an AlphInfo object representing the alphabet with a given name. In the event that it could not be found, the Default alphabet is returned instead. To ensure that this is not the case, check the available alphabets first using GetAlphabets().

Parameters:
AlphID - Name of the alphabet to be retrieved.
Returns:
Either the asked alphabet, or the default.

SetInfo

public void SetInfo(CAlphIO.AlphInfo NewInfo)
Registers a new AlphInfo object as a valid alphabet, which will henceforth be included in enumerations of available alphabets.

Parameters:
NewInfo - New alphabet

Delete

public void Delete(java.lang.String AlphID)
Removes a given alphabet; it will no longer appear in enumerations of alphabets. If it does not exist, this method will return without error.

Parameters:
AlphID -

Save

public void Save(java.lang.String AlphID)
Stub. At present Dasher does not permit users to specify their own alphabets, but in the case that this were introduced, this method would write out an XML document for the new alphabet.

Parameters:
AlphID - Name of alphabet to save.

CreateDefault

protected void CreateDefault()
Creates the default alphabet and stores as an available alphabet. This will be returned in the case that a requested alphabet cannot be retrieved; at present it is essentially lower-case english with no punctuation or numerals.

The constructor calls this method prior to attempting to read XML files; it should not need to be called more than once unless the Default is deleted.