org.jscience.linguistics.braille.util
Class MakerBraille

java.lang.Object
  extended by org.jscience.linguistics.braille.util.MakerBraille
Direct Known Subclasses:
MakeBrailleLanguageUnicode

public class MakerBraille
extends java.lang.Object

Provides functions and constants for the Make programs that produce formatted machine-readable language files from their corresponding human-editable data files.

Copyright 1999, 2004 Alasdair King. This program is free software under the terms of the GNU General Public License.

See Also:
org.jscience.linguistics.braille.Language

Field Summary
static int DISK_ERROR
          Error code for a failure to complete a program caused by a I/O fault.
static int ESCAPE_CHARACTER_1
          Character indicating the start of an escape character for encoding characters of values 128 - 255 in ASCII language files.
static int ESCAPE_CHARACTER_2
          Character indicating the second part of an escape character for encoding characters of values 128 - 255 in ASCII language files.
static int LANGUAGE_ERROR
          Error code for a failure using a Language.
static int SUCCESS
          Error code for successful completion of a MakerBraille program.
static char TABLE_DELIMITER
          The ASCII character indicating the end of the translation rules.
 
Method Summary
static int[] getEscapedCharacter(java.io.BufferedInputStream inFile)
          If a '\x' character is encountered in a language human file it might be an escape sequence for a 256-character set value.
static int skipComments(java.io.BufferedInputStream fileIn)
          Skips over comment lines in the language files.
static java.lang.String skipComments(java.io.BufferedReader fileIn)
          Skips over comment lines in the language files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ESCAPE_CHARACTER_1

public static final int ESCAPE_CHARACTER_1
Character indicating the start of an escape character for encoding characters of values 128 - 255 in ASCII language files.

See Also:
Constant Field Values

ESCAPE_CHARACTER_2

public static final int ESCAPE_CHARACTER_2
Character indicating the second part of an escape character for encoding characters of values 128 - 255 in ASCII language files.

See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
Error code for successful completion of a MakerBraille program.

See Also:
Constant Field Values

DISK_ERROR

public static final int DISK_ERROR
Error code for a failure to complete a program caused by a I/O fault.

See Also:
Constant Field Values

LANGUAGE_ERROR

public static final int LANGUAGE_ERROR
Error code for a failure using a Language.

See Also:
Constant Field Values

TABLE_DELIMITER

public static final char TABLE_DELIMITER
The ASCII character indicating the end of the translation rules.

See Also:
Constant Field Values
Method Detail

skipComments

public static int skipComments(java.io.BufferedInputStream fileIn)
Skips over comment lines in the language files. The human-readable files can have comment lines, indicated by the ':' colon character, or the COMMENT constant in MakeLanguage256. This should return first non-comment character of the first non-comment line as an int.

To be explicit: the method halts only when one of the following is met:

  1. A carriage return is followed by a non-comment non-linefeed character or
  2. A linefeed followed by a non-comment non-carriage return character.
In both cases, the ASCII/Unicode characters for CR, LF are used. This should work for Apple Macintosh, Windows and Unix systems.

Parameters:
fileIn - BufferedInputStream to the file being read from.
Returns:
readBuffer[1] An int, the first character of the next non-comment line.

skipComments

public static java.lang.String skipComments(java.io.BufferedReader fileIn)
Skips over comment lines in the language files. The human-readable files can have comment lines, indicated by the ':' colon character, or the COMMENT constant in MakeLanguage256. This should return first non-comment character of the first non-comment line as an int.

Parameters:
fileIn - BufferedInputStream for the file being read.
Returns:
toReturn String containing the first non-comment line.

getEscapedCharacter

public static int[] getEscapedCharacter(java.io.BufferedInputStream inFile)
If a '\x' character is encountered in a language human file it might be an escape sequence for a 256-character set value. This iteratively processes the values and returns as an array of integers the values of the possible escape character OR escape characters AND the next non-escape character. If the potential escape character is not in fact an escape character it is returned instead.

Parameters:
inFile - The file being read from.
Returns:
The sequence of characters, escaped or not, and the next character.