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

## oracle.ifs.utils.io
Class SymbolCommuter

    java.lang.Object
      oracle.ifs.utils.io.SymbolCommuter

All Implemented Interfaces:
  StringProcessor

    public class SymbolCommuter

extends java.lang.Object
implements StringProcessor

The SymbolCommuter class commutes, or substitutes, values for symbols.

Symbols can be inserted into text as a placeholder for variables. SymbolCommuter will replace the symbols with values defined by a key/value pair mapping.

Symbols are denoted by a name and one or two tokens that either preceed or surround the symbol. The SymbolType class represents types of symbols that can be inserted into text as a placeholder for a value.

This class implements the StringProcessor interface so that it can be used with LineFilterReader to process a stream.

Modified:
  dlong 01/25/2005 change handleItem to return boolean, lsaenz 03/03/2000 Added support for processing files in a directory., lsaenz 02/10/2000 Fixed getSymbolsInString to return an Enumeration rather than a Vector., lsaenz 11/20/1999 Fixed NullPointerException bug in findSymbol() when clients pass in a null Hashtable to the constructor., lsaenz 11/12/1999 Added methods getSymbolsInFile() and getSymbolsInString()., lsaenz 11/11/1999 Fixed circular reference bug., lsaenz 11/07/1999 Added processFile()., lsaenz 11/02/1999 Created.

Field Summary
`static int` | `RAISE_EXCEPTION` Raise exceptions when symbols are undefined.
`static int` | `REMOVE_SYMBOL` Remove symbols that are undefined
`static int` | `SKIP` Skip symbols that are undefined.

Constructor Summary
`SymbolCommuter(java.util.Hashtable symbolTable)` Creates a new SymbolCommuter with default settings.
`SymbolCommuter(java.util.Hashtable symbolTable, SymbolType type)` Creates a new SymbolCommuter given a SymbolType to search for.

Method Summary
`void` | `addSymbolType(SymbolType type)` Adds a SymbolType to search for when substituting values for symbols.
`java.util.Vector` | `getSymbolsInFile(java.lang.String inputFile)` Returns all the symbols in a file, even if they are not mapped to values in this SymbolCommuter's table of key/value pairs.
`java.util.Vector` | `getSymbolsInString(java.lang.String str)` Returns all the symbols in a String, even if they are not mapped to values in this SymbolCommuter's table of key/value pairs.
`java.util.Enumeration` | `getSymbolTypes()` Returns an Enumeration of the SymbolTypes in use.
`void` | `processDirectory(java.lang.String sourceDir)` Replaces symbols in all text files in a given directory.
`void` | `processDirectory(java.lang.String sourceDir, java.lang.String destDir)` Replaces symbols in all text files in a given directory.
`void` | `processFile(java.lang.String inputFile)` Replaces symbols with values in a text file.
`void` | `processFile(java.lang.String inputFile, java.lang.String outputFile)` Replaces symbols with values in a text file.
`java.lang.String` | `processString(java.lang.String input)` Replaces all symbols in the input String with values from this SymbolCommuter's symbol table.
`void` | `removeSymbolType(SymbolType type)` Removes a SymbolType to look for when substituting values for symbols.
`void` | `setUndefinedAction(int action)` Sets the action to take when an undefined symbol is found.

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

Field Detail

### SKIP

    public static final int SKIP

  Description copied from class: `SymbolCommuter`
  Skip symbols that are undefined.

  See Also:
    Constant Field Values

### RAISE_EXCEPTION

    public static final int RAISE_EXCEPTION

  Description copied from class: `SymbolCommuter`
  Raise exceptions when symbols are undefined.

  See Also:
    Constant Field Values

### REMOVE_SYMBOL

    public static final int REMOVE_SYMBOL

  Description copied from class: `SymbolCommuter`
  Remove symbols that are undefined

  See Also:
    Constant Field Values

Constructor Detail

### SymbolCommuter

    public SymbolCommuter(java.util.Hashtable symbolTable)

  Creates a new SymbolCommuter with default settings. All default symbol types are searched and undefined symbols are skipped. The default symbol types are: SymbolType.DOS, SymbolType.UNIX, and SymbolType.SQL

  Parameters:
    `symbolTable` - a Hashtable mapping symbol names to values.

### SymbolCommuter

    public SymbolCommuter(java.util.Hashtable symbolTable,
                          SymbolType type)

  Creates a new SymbolCommuter given a SymbolType to search for. Undefined symbols are skipped.

  Parameters:
    `symbolTable` - a Hashtable mapping symbol names to values.
    `type` - the SymbolType to search for when processing Strings.

Method Detail

### setUndefinedAction

    public void setUndefinedAction(int action)

  Description copied from class: `SymbolCommuter`
  Sets the action to take when an undefined symbol is found.

  Parameters:
    `action` - the action to take: SKIP, RAISE_EXCEPTION, or REMOVE_SYMBOL.

### addSymbolType

    public void addSymbolType(SymbolType type)

  Description copied from class: `SymbolCommuter`
  Adds a SymbolType to search for when substituting values for symbols.

  Parameters:
    `type` - the SymbolType to add.

### removeSymbolType

    public void removeSymbolType(SymbolType type)

  Description copied from class: `SymbolCommuter`
  Removes a SymbolType to look for when substituting values for symbols.

  Parameters:
    `type` - the SymbolType to remove.

### getSymbolTypes

    public java.util.Enumeration getSymbolTypes()

  Description copied from class: `SymbolCommuter`
  Returns an Enumeration of the SymbolTypes in use.

### processString

    public java.lang.String processString(java.lang.String input)

  Description copied from class: `SymbolCommuter`
  Replaces all symbols in the input String with values from this SymbolCommuter's symbol table.

  Specified by:
    `processString` in interface `StringProcessor`
  Parameters:
    `input` - the input String.
  Returns:
    the processed output String with values in place of the symbols in the input String.

### processFile

    public void processFile(java.lang.String inputFile)
                     throws java.io.IOException,
                            java.io.FileNotFoundException

  Description copied from class: `SymbolCommuter`
  Replaces symbols with values in a text file. Modifies the given file in place (a temporary file is used).

  Parameters:
    `inputFile` - the file to process.
  Throws:
    `java.io.IOException`
    `java.io.FileNotFoundException`

### processFile

    public void processFile(java.lang.String inputFile,
                            java.lang.String outputFile)
                     throws java.io.IOException,
                            java.io.FileNotFoundException

  Description copied from class: `SymbolCommuter`
  Replaces symbols with values in a text file.

  Parameters:
    `inputFile` - the file to process.
    `outputFile` - the file to save changes into.
  Throws:
    `java.io.IOException`
    `java.io.FileNotFoundException`

### processDirectory

    public void processDirectory(java.lang.String sourceDir)
                          throws DirectoryItemHandlerException

  Description copied from class: `SymbolCommuter`
  Replaces symbols in all text files in a given directory. Modifies each file in place (a temporary file is used).

  Parameters:
    `sourceDir` - the directory to process.
  Throws:
    `DirectoryItemHandlerException`

### processDirectory

    public void processDirectory(java.lang.String sourceDir,
                                 java.lang.String destDir)
                          throws DirectoryItemHandlerException

  Description copied from class: `SymbolCommuter`
  Replaces symbols in all text files in a given directory. Saves each processed file to the given destination directory.

  Parameters:
    `sourceDir` - the directory to process.
    `destDir` - the directory to save processed files to.
  Throws:
    `DirectoryItemHandlerException`

### getSymbolsInFile

    public java.util.Vector getSymbolsInFile(java.lang.String inputFile)
                                      throws java.io.IOException,
                                             java.io.FileNotFoundException

  Description copied from class: `SymbolCommuter`
  Returns all the symbols in a file, even if they are not mapped to values in this SymbolCommuter's table of key/value pairs.

  Returns:
    a Vector containing Strings that represent symbol names. The Vector contains every symbol that occurs in the given file, without the symbol characters.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `java.io.FileNotFoundException` - if the file could not be found.

### getSymbolsInString

    public java.util.Vector getSymbolsInString(java.lang.String str)

  Description copied from class: `SymbolCommuter`
  Returns all the symbols in a String, even if they are not mapped to values in this SymbolCommuter's table of key/value pairs.

  Returns:
    a Vector containing Strings representing symbol names. The Enumeration contains every symbol that occurs in the given string, without the symbol characters. i.e. given the string "Hello %FOO% $BAR" this method would return a Vector containing the Strings "FOO" and "BAR". The symbols are returned in the order that they occur, without regard to symbol type; however, only symbol types that are specified when this class is created are returned.

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