Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.olafpanz.translationtable
Class CodeGenerator

    java.lang.Object
      de.olafpanz.translationtable.CodeGenerator

    final class CodeGenerator

extends java.lang.Object

This represents one translation table read from ots file.

Author:
  Olaf Panz

Field Summary
`private TranslationDocument` | `doc` Document to create source for.
`private static java.lang.String` | `ENCODING` File encoding.
`private TranslationTableParameters` | `param` Code creation parameters.
`private static java.util.Comparator<TranslationEntry>` | `SORT_BY_TYPE_COMPARATOR` Compare translation entries by its type
`private java.util.Set<TranslationDataType>` | `usedTypes` This structure is filled with types in use.

Constructor Summary
`CodeGenerator(TranslationDocument doc, TranslationTableParameters param)` Create a translation table with all meta information, without data.

Method Summary
`private void` | `create14AccessMethod(java.io.PrintWriter writer, java.lang.String objectType, java.lang.String dataType)` Create an access method for param.getJdk() 1.4
`private void` | `create15AccessMethod(java.io.PrintWriter writer, TranslationDataType type, java.lang.String dataType, java.lang.String interfaceName)` Create an access method for param.getJdk() 1.5
`private void` | `createEmumMethods(java.io.PrintWriter writer, TranslationDataType currType)` Create helper methods of an key-enumeration
`private java.lang.String` | `createEnumInterface(java.io.File targetDir)` Create interface with keys for all translations
`void` | `createFiles()` Create all necessary files.
`private java.lang.String` | `createKeyInterface(java.io.File targetDir)` Create interface with keys for all translations
`private void` | `createManager(java.io.File targetDir, java.lang.String interfaceName)` Create the translation manager for the specified environment.
`private void` | `createMapLocaleMethod(java.io.PrintWriter writer)` Create code that evaluates the right resource bundle.
`private void` | `createPluginProperties(int localeIndex)` Do create plugin property files.
`private void` | `createResourceFile(java.io.File targetDir, int localeIndex, java.lang.String infName)` Create resource file for one language

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ENCODING

    private static final java.lang.String ENCODING

  File encoding.

  See Also:
    Constant Field Values

### doc

    private final TranslationDocument doc

  Document to create source for.

### param

    private final TranslationTableParameters param

  Code creation parameters.

### usedTypes

    private final java.util.Set<TranslationDataType> usedTypes

  This structure is filled with types in use. Filled by `createKeyInterface(File)`

### SORT_BY_TYPE_COMPARATOR

    private static final java.util.Comparator<TranslationEntry> SORT_BY_TYPE_COMPARATOR

  Compare translation entries by its type

Constructor Detail

### CodeGenerator

    public CodeGenerator(TranslationDocument doc,
                         TranslationTableParameters param)

  Create a translation table with all meta information, without data.

  Parameters:
    `doc` - Document to generate code for.
    `param` - Defines how to generate code.

Method Detail

### createFiles

    public void createFiles()
                     throws java.io.IOException

  Create all necessary files.

  Throws:
    `java.io.IOException` - Error in file creation

### createManager

    private final void createManager(java.io.File targetDir,
                                     java.lang.String interfaceName)
                              throws java.io.IOException

  Create the translation manager for the specified environment.

  Parameters:
    `targetDir` - The target dir
    `interfaceName` - Name of interface that defines keys.
  Throws:
    `java.io.IOException` - Error in file creation

### createMapLocaleMethod

    private final void createMapLocaleMethod(java.io.PrintWriter writer)

  Create code that evaluates the right resource bundle. Locale assignment algorithm: (1) Search for exact match considering language, country, variant

  (2) Search for exact match considering language, country

  (3) Search for exact match considering language

  (4) Use default locale

  Parameters:
    `writer` - Write code to this writer

### create15AccessMethod

    private void create15AccessMethod(java.io.PrintWriter writer,
                                      TranslationDataType type,
                                      java.lang.String dataType,
                                      java.lang.String interfaceName)

  Create an access method for param.getJdk() 1.5

  Parameters:
    `writer` - Writer to write code to
    `type` - Type of requested element
    `dataType` - Java data type of element
    `interfaceName` - Name of enum-interface

### create14AccessMethod

    private void create14AccessMethod(java.io.PrintWriter writer,
                                      java.lang.String objectType,
                                      java.lang.String dataType)

  Create an access method for param.getJdk() 1.4

  Parameters:
    `writer` - Writer to write source to.
    `objectType` - Name of object type, is used to create method name
    `dataType` - Name of java data type

### createKeyInterface

    private final java.lang.String createKeyInterface(java.io.File targetDir)
                                               throws java.io.IOException

  Create interface with keys for all translations

  Parameters:
    `targetDir` - Directory of target.
  Returns:
    Name of the interface class
  Throws:
    `java.io.IOException` - Writing might fail

### createEnumInterface

    private final java.lang.String createEnumInterface(java.io.File targetDir)
                                                throws java.io.IOException

  Create interface with keys for all translations

  Parameters:
    `targetDir` - Directory of target.
  Returns:
    Name of the interface class
  Throws:
    `java.io.IOException` - Writing might fail

### createEmumMethods

    private void createEmumMethods(java.io.PrintWriter writer,
                                   TranslationDataType currType)

  Create helper methods of an key-enumeration

  Parameters:
    `writer` - Writer code to this writen; null is not allowed
    `currType` - Current enum type

### createResourceFile

    private final void createResourceFile(java.io.File targetDir,
                                          int localeIndex,
                                          java.lang.String infName)
                                   throws java.io.IOException

  Create resource file for one language

  Parameters:
    `targetDir` - Directory of target.
    `localeIndex` - Index of locale to write
    `infName` - Name of the created interface
  Throws:
    `java.io.IOException` - Writing might fail

### createPluginProperties

    private void createPluginProperties(int localeIndex)
                                 throws java.io.IOException

  Do create plugin property files.

  Parameters:
    `localeIndex` - Index to the file to create.
  Throws:
    `java.io.IOException` - Writing might fail
  Since:
    1.0

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD