sinclair.basic
Class ZX81Translate

java.lang.Object
  extended bysinclair.basic.ZX81Translate

public class ZX81Translate
extends java.lang.Object

This class provides utilities to translate between ZX81 character set and ASCII.

Author:
hldswrth

Field Summary
static int TOKEN_NEWLINE
          The index of the new line token.
static int TOKEN_NUMBER
          The index of the number indicator token.
static int TOKEN_REM
          The index of the REM token.
 
Constructor Summary
ZX81Translate()
           
 
Method Summary
static boolean checkTranslatableToZX81(java.lang.String str)
          Check that the given string contains valid characters.
static java.lang.String expandZX81(int c)
          Expand the given ZX81 character into a string of ZX81 characters.
static void main(java.lang.String[] args)
          Main routine.
static int translateASCIIToZX81(char value)
          Translate an ASCII character to ZX81.
static void translateASCIIToZX81(java.lang.String value, java.lang.StringBuffer trans)
          Translate an ASCII string to ZX81.
static java.lang.String translateZX81ToASCII(java.io.InputStream is)
          Translate the bytes from the stream from ZX81 characters to ASCII.
static java.lang.String translateZX81ToASCII(int value)
          Translate a ZX81 character to ASCII.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOKEN_NUMBER

public static final int TOKEN_NUMBER
The index of the number indicator token.

See Also:
Constant Field Values

TOKEN_NEWLINE

public static final int TOKEN_NEWLINE
The index of the new line token.

See Also:
Constant Field Values

TOKEN_REM

public static final int TOKEN_REM
The index of the REM token.

See Also:
Constant Field Values
Constructor Detail

ZX81Translate

public ZX81Translate()
Method Detail

main

public static void main(java.lang.String[] args)
Main routine.

Translates a file and writes to standard output. Arguments:

 {-pFile|-p} fileName     The name of the .P file.
 

Parameters:
args - The arguments.

translateZX81ToASCII

public static java.lang.String translateZX81ToASCII(int value)
Translate a ZX81 character to ASCII.

Parameters:
value - The ZX81 character value.
Returns:
The ASCII string.

translateASCIIToZX81

public static int translateASCIIToZX81(char value)
Translate an ASCII character to ZX81.

This version translates a single character - i.e. it will not map keywords back to the ZX81 character.

Returns -1 if the character does not exist in the ZX81 set.

Parameters:
value - The ASCII character value.
Returns:
The ZX81 character.

translateASCIIToZX81

public static void translateASCIIToZX81(java.lang.String value,
                                        java.lang.StringBuffer trans)
Translate an ASCII string to ZX81.

This version translates each single character - i.e. it will not map keywords back to the ZX81 character.

Returns -1 if the character does not exist in the ZX81 set.

Parameters:
value - The ASCII string.
trans - A buffer to hold the translated string.

translateZX81ToASCII

public static java.lang.String translateZX81ToASCII(java.io.InputStream is)
                                             throws java.io.IOException
Translate the bytes from the stream from ZX81 characters to ASCII.

Parameters:
is - The input stream to be read.
Returns:
The translated ASCII represention of the bytes.
Throws:
java.io.IOException - An error occurred reading the stream.

expandZX81

public static java.lang.String expandZX81(int c)
Expand the given ZX81 character into a string of ZX81 characters.

Parameters:
c - The ZX81 character.
Returns:
The string.

checkTranslatableToZX81

public static boolean checkTranslatableToZX81(java.lang.String str)
Check that the given string contains valid characters.

Parameters:
str -
Returns:
Indicates whether the string consists of valid characters.