Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.enhydra.xml.io
Class MkEncodingsTable  view MkEncodingsTable download MkEncodingsTable.java

java.lang.Object
  extended byorg.enhydra.xml.io.MkEncodingsTable

public final class MkEncodingsTable
extends java.lang.Object

Generate a file contain character encodings by parsing the IANA Charset Registry, obtained from:
ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets
This is a development-time tool, with special hacks to make up for various java encoding names not in the table. The resulting file has the format:

 name bits mime-name alias1 alias2 ...
 
Where bits is 7, 8 or 16 and mime-name can be "null" if there is none defined. This file will be converted to XML in a future release.


Field Summary
private  java.lang.String CHAR_SET_REGISTRY
          Resource name of IANA Charset Registry file.
private  java.lang.String CHAR_SET_TABLE
          Character set table that is created
private static java.lang.String[] ENCODINGS_7BIT
          7 bit encoding names.
private static java.lang.String[] ENCODINGS_8BIT
          8 bit encoding names.
private static java.lang.String[] EXTRA_ENTRIES
          Extra entries to output, with no other hacks available to get them.
private static java.util.HashSet f7BitEncodings
          Tables of known 7 & 8 bit encodings.
private static java.util.HashSet f8BitEncodings
           
private static java.lang.String[][] HACKED_ALIASES
          Table of aliases to add.
private static java.lang.String[][] HACKED_PREFIXES
          Table of prefix conversions.
private  java.lang.String REG_ALIAS_FIELD
           
private static java.lang.String REG_MIME_PREFERRED
          Pattern indicating the preferred MIME name.
private  java.lang.String REG_NAME_FIELD
          Labels in registry file.
 
Constructor Summary
MkEncodingsTable()
           
 
Method Summary
private  void addAlias(java.util.ArrayList aliases, java.lang.String alias)
          Add a alias to the list of aliases, if its not null or not already there.
private  int getCharSize(java.lang.String encoding)
          Get the encoding size.
private  void ianaParseError(java.lang.String msg, java.lang.String line)
          Generate an error about parsing a line in registry.
private  boolean isMimePreferredEntry(java.lang.String line)
          Determine if a line contains the preferred MIME encoding.
static void main(java.lang.String[] args)
          Entry
private  void makeHackedAliases(java.util.ArrayList aliases, java.lang.String name)
          Do special hacked mapping of name/aliases to other aliases.
private  boolean parseCharSetEntry(java.io.BufferedReader in, java.io.PrintWriter out)
          Scan the input stream for the next encoding entry and parse that entry and write a record.
private  void parseIanaRegistry()
          Parse the registry file.
private  void parseIanaRegistry(java.io.BufferedReader in, java.io.PrintWriter out)
          Parse the registry file.
private  java.lang.String parseName(java.lang.String line)
          Extract a encoding name out of a Name: or Alias: line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_SET_REGISTRY

private final java.lang.String CHAR_SET_REGISTRY
Resource name of IANA Charset Registry file.

See Also:
Constant Field Values

CHAR_SET_TABLE

private final java.lang.String CHAR_SET_TABLE
Character set table that is created

See Also:
Constant Field Values

REG_NAME_FIELD

private final java.lang.String REG_NAME_FIELD
Labels in registry file.

See Also:
Constant Field Values

REG_ALIAS_FIELD

private final java.lang.String REG_ALIAS_FIELD
See Also:
Constant Field Values

ENCODINGS_7BIT

private static final java.lang.String[] ENCODINGS_7BIT
7 bit encoding names.


ENCODINGS_8BIT

private static final java.lang.String[] ENCODINGS_8BIT
8 bit encoding names.


f7BitEncodings

private static final java.util.HashSet f7BitEncodings
Tables of known 7 & 8 bit encodings.


f8BitEncodings

private static final java.util.HashSet f8BitEncodings

REG_MIME_PREFERRED

private static final java.lang.String REG_MIME_PREFERRED
Pattern indicating the preferred MIME name.

See Also:
Constant Field Values

HACKED_ALIASES

private static final java.lang.String[][] HACKED_ALIASES
Table of aliases to add.


HACKED_PREFIXES

private static final java.lang.String[][] HACKED_PREFIXES
Table of prefix conversions. An alias is created for names/aliases that match the first prefix, with the second subsitutued.


EXTRA_ENTRIES

private static java.lang.String[] EXTRA_ENTRIES
Extra entries to output, with no other hacks available to get them.

Constructor Detail

MkEncodingsTable

public MkEncodingsTable()
Method Detail

ianaParseError

private void ianaParseError(java.lang.String msg,
                            java.lang.String line)
Generate an error about parsing a line in registry.


getCharSize

private int getCharSize(java.lang.String encoding)
Get the encoding size. Returning 7, 8, or 16. This makes a guess based on some encoded knowledge. If not known, returns 16.


parseName

private java.lang.String parseName(java.lang.String line)
Extract a encoding name out of a Name: or Alias: line. Returns null if empty.


isMimePreferredEntry

private boolean isMimePreferredEntry(java.lang.String line)
Determine if a line contains the preferred MIME encoding.


addAlias

private void addAlias(java.util.ArrayList aliases,
                      java.lang.String alias)
Add a alias to the list of aliases, if its not null or not already there.


makeHackedAliases

private void makeHackedAliases(java.util.ArrayList aliases,
                               java.lang.String name)
Do special hacked mapping of name/aliases to other aliases. This handles alisas not in registry


parseCharSetEntry

private boolean parseCharSetEntry(java.io.BufferedReader in,
                                  java.io.PrintWriter out)
                           throws java.io.IOException
Scan the input stream for the next encoding entry and parse that entry and write a record.


parseIanaRegistry

private void parseIanaRegistry(java.io.BufferedReader in,
                               java.io.PrintWriter out)
                        throws java.io.IOException
Parse the registry file.


parseIanaRegistry

private void parseIanaRegistry()
                        throws java.io.IOException
Parse the registry file.


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Entry