org.foray.ps.encode
Class EncodingParser

java.lang.Object
  extended by org.foray.ps.encode.EncodingParser

public class EncodingParser
extends Object

An EncodingParser instance parses an encoding list, arranging its data for efficient use during processing.


Constructor Summary
EncodingParser(InputStream input, int columnNum, int radix, List<String> glyphLists)
          Create a new EncodingParser instance.
 
Method Summary
static String formatArrayIndex(int index)
          Formats the array index for java source code.
 char[] getCodePointIndexes()
          Returns the codepoint indexes.
 char[] getCodePoints()
          Returns the codepoints.
 char[] getGlyphIndexes()
          Returns the glyph indexes.
 List<org.axsl.ps.GlyphList> getGlyphListsToCheck()
          Returns the glyph lists to check.
 String[] getGlyphNames()
          Returns the glyph names.
static void main(String[] args)
          Main method useful for parsing an encoding list file from the command-line and generating the java code that encapsulates that encoding.
static String padSpaces(String string, int desiredColumn, int minimumPad)
          Pads spaces in the output to try to make it more readable.
 void parseList()
          Parses a glyph list.
 void writeAsJavaStatics(OutputStream out)
          Writes out the internal arrays that have been parsed into java source code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodingParser

public EncodingParser(InputStream input,
                      int columnNum,
                      int radix,
                      List<String> glyphLists)
Create a new EncodingParser instance.

Parameters:
input - The reader encapsulating the file to be parsed.
columnNum - The column number in the input file that should be read to get the encoded value for this encoding. Column number 1 is the first field after the glyph name, that is, field 2.
radix - The radix of the numbering system (10 for decimal, 8 for octal, etc.).
glyphLists - The list of glyph lists to be consulted when mapping glyph names to Unicode code points, listed in the order in which they should be checked. The Adobe Glyph List is always consulted, but only after any custom ones listed here.
Method Detail

parseList

public void parseList()
               throws IOException,
                      org.axsl.ps.PsException
Parses a glyph list.

Throws:
IOException - For I/O Errors.
org.axsl.ps.PsException - For errors parsing the input.

writeAsJavaStatics

public void writeAsJavaStatics(OutputStream out)
                        throws IOException
Writes out the internal arrays that have been parsed into java source code. This is useful in cases where you wish to permanently encapsulate an encoding.

Parameters:
out - The OutputStream to which the data structures should be written.
Throws:
IOException - For errors when writing to out.

padSpaces

public static String padSpaces(String string,
                               int desiredColumn,
                               int minimumPad)
Pads spaces in the output to try to make it more readable.

Parameters:
string - The pre-padded output line.
desiredColumn - The column number up to which padding should be added.
minimumPad - The minimum padding size that should be added.
Returns:
The padded String.

formatArrayIndex

public static String formatArrayIndex(int index)
Formats the array index for java source code.

Parameters:
index - The index to be formatted.
Returns:
The formatted array index.

getCodePointIndexes

public char[] getCodePointIndexes()
Returns the codepoint indexes.

Returns:
The codepoint indexes.

getCodePoints

public char[] getCodePoints()
Returns the codepoints.

Returns:
The codepoints.

getGlyphIndexes

public char[] getGlyphIndexes()
Returns the glyph indexes.

Returns:
The glyph indexes.

getGlyphNames

public String[] getGlyphNames()
Returns the glyph names.

Returns:
The glyph names.

getGlyphListsToCheck

public List<org.axsl.ps.GlyphList> getGlyphListsToCheck()
Returns the glyph lists to check.

Returns:
The glyph lists to check.

main

public static void main(String[] args)
Main method useful for parsing an encoding list file from the command-line and generating the java code that encapsulates that encoding.

Parameters:
args - Element 0 is the URL of the encoding list to be parsed. This file is a text file, one line per record, with at least two whitespace-delimited fields. The first field is always the glyph name. The second and any other (optional) fields contain the glyph index for that glyph name for a specific encoding. Thus multiple encodings for the same glyph list can be contained in the same file. Element 1 is the column-number to parse. Column number 1 is the first field after the glyph name, i.e. field 2. Element 2 is the radix of the numbering system (10 for decimal, 8 for octal, etc.). Element 3 is the URL of the file to which the java source code should be written. Element 4 is the (optional) list of already-registered glyph lists that should be consulted when searching for a glyph name. The Adobe Glyph List is always consulted, but only after any custom ones listed here.


Copyright © 2017. All rights reserved.