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

## org.eclipse.jdt.core
Class ToolFactory

    java.lang.Object
      org.eclipse.jdt.core.ToolFactory

public class ToolFactory
extends Object

Factory for creating various compiler tools, such as scanners, parsers and compilers.

This class provides static methods only; it is not intended to be instantiated or subclassed by clients.

Since:
  2.0

Constructor Summary
`ToolFactory()`

Method Summary
`static ICodeFormatter` | `createCodeFormatter()` Deprecated. - should use #createCodeFormatter(Map) instead. Extension point is discontinued
`static CodeFormatter` | `createCodeFormatter(Map options)` Create an instance of the built-in code formatter.
`static ClassFileBytesDisassembler` | `createDefaultClassFileBytesDisassembler()` Create a classfile bytecode disassembler, able to produce a String representation of a given classfile.
`static IClassFileDisassembler` | `createDefaultClassFileDisassembler()` Deprecated. - should use factory method creating ClassFileBytesDisassembler instead
`static IClassFileReader` | `createDefaultClassFileReader(IClassFile classfile, int decodingFlag)` Create a classfile reader onto a classfile Java element.
`static IClassFileReader` | `createDefaultClassFileReader(String fileName, int decodingFlag)` Create a default classfile reader, able to expose the internal representation of a given classfile according to the decoding flag used to initialize the reader.
`static IClassFileReader` | `createDefaultClassFileReader(String zipFileName, String zipEntryName, int decodingFlag)` Create a default classfile reader, able to expose the internal representation of a given classfile according to the decoding flag used to initialize the reader.
`static ICodeFormatter` | `createDefaultCodeFormatter(Map options)` Deprecated. - use #createCodeFormatter(Map) instead
`static IScanner` | `createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator)` Create a scanner, indicating the level of detail requested for tokenizing.
`static IScanner` | `createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator, String sourceLevel)` Create a scanner, indicating the level of detail requested for tokenizing.

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

Constructor Detail

### ToolFactory

    public ToolFactory()

Method Detail

### createCodeFormatter

    public static ICodeFormatter createCodeFormatter()

  Deprecated. - should use #createCodeFormatter(Map) instead. Extension point is discontinued

  Create an instance of a code formatter. A code formatter implementation can be contributed via the extension point "org.eclipse.jdt.core.codeFormatter". If unable to find a registered extension, the factory will default to using the default code formatter.

  Returns:
    an instance of a code formatter
  See Also:
    `ICodeFormatter`, `createDefaultCodeFormatter(Map)`

### createCodeFormatter

    public static CodeFormatter createCodeFormatter(Map options)

  Create an instance of the built-in code formatter.

  Parameters:
    `options` - - the options map to use for formatting with the default code formatter. Recognized options are documented on `JavaCore#getDefaultOptions()`. If set to `null`, then use the current settings from `JavaCore#getOptions`.
  Returns:
    an instance of the built-in code formatter
  Since:
    3.0
  See Also:
    `CodeFormatter`, `JavaCore.getOptions()`

### createDefaultCodeFormatter

    public static ICodeFormatter createDefaultCodeFormatter(Map options)

  Deprecated. - use #createCodeFormatter(Map) instead

  Create an instance of the built-in code formatter. A code formatter implementation can be contributed via the extension point "org.eclipse.jdt.core.codeFormatter". If unable to find a registered extension, the factory will default to using the default code formatter.

  Parameters:
    `options` - - the options map to use for formatting with the default code formatter. Recognized options are documented on `JavaCore#getDefaultOptions()`. If set to `null`, then use the current settings from `JavaCore#getOptions`.
  Returns:
    an instance of the built-in code formatter
  See Also:
    `ICodeFormatter`, `createCodeFormatter()`, `JavaCore.getOptions()`

### createDefaultClassFileDisassembler

    public static IClassFileDisassembler createDefaultClassFileDisassembler()

  Deprecated. - should use factory method creating ClassFileBytesDisassembler instead

  Create a classfile bytecode disassembler, able to produce a String representation of a given classfile.

  Returns:
    a classfile bytecode disassembler
  See Also:
    `IClassFileDisassembler`

### createDefaultClassFileBytesDisassembler

    public static ClassFileBytesDisassembler createDefaultClassFileBytesDisassembler()

  Create a classfile bytecode disassembler, able to produce a String representation of a given classfile.

  Returns:
    a classfile bytecode disassembler
  Since:
    2.1
  See Also:
    `ClassFileBytesDisassembler`

### createDefaultClassFileReader

    public static IClassFileReader createDefaultClassFileReader(String fileName,
                                                                int decodingFlag)

  Create a default classfile reader, able to expose the internal representation of a given classfile according to the decoding flag used to initialize the reader. Answer null if the file named fileName doesn't represent a valid .class file. The fileName has to be an absolute OS path to the given .class file. The decoding flags are described in IClassFileReader.

  Parameters:
    `fileName` - the name of the file to be read
    `decodingFlag` - the flag used to decode the class file reader.
  Returns:
    a default classfile reader
  See Also:
    `IClassFileReader`

### createDefaultClassFileReader

    public static IClassFileReader createDefaultClassFileReader(IClassFile classfile,
                                                                int decodingFlag)

  Create a classfile reader onto a classfile Java element. Create a default classfile reader, able to expose the internal representation of a given classfile according to the decoding flag used to initialize the reader. Answer null if the file named fileName doesn't represent a valid .class file. The decoding flags are described in IClassFileReader.

  Parameters:
    `classfile` - the classfile element to introspect
    `decodingFlag` - the flag used to decode the class file reader.
  Returns:
    a default classfile reader
  See Also:
    `IClassFileReader`

### createDefaultClassFileReader

    public static IClassFileReader createDefaultClassFileReader(String zipFileName,
                                                                String zipEntryName,
                                                                int decodingFlag)

  Create a default classfile reader, able to expose the internal representation of a given classfile according to the decoding flag used to initialize the reader. Answer null if the file named zipFileName doesn't represent a valid zip file or if the zipEntryName is not a valid entry name for the specified zip file or if the bytes don't represent a valid .class file according to the JVM specifications. The decoding flags are described in IClassFileReader.

  Parameters:
    `zipFileName` - the name of the zip file
    `zipEntryName` - the name of the entry in the zip file to be read
    `decodingFlag` - the flag used to decode the class file reader.
  Returns:
    a default classfile reader
  See Also:
    `IClassFileReader`

### createScanner

    public static IScanner createScanner(boolean tokenizeComments,
                                         boolean tokenizeWhiteSpace,
                                         boolean assertMode,
                                         boolean recordLineSeparator)

  Create a scanner, indicating the level of detail requested for tokenizing. The scanner can then be used to tokenize some source in a Java aware way. Here is a typical scanning loop: `

         IScanner scanner = ToolFactory.createScanner(false, false, false, false);
         scanner.setSource("int i = 0;".toCharArray());
         while (true) {
           int token = scanner.getNextToken();
           if (token == ITerminalSymbols.TokenNameEOF) break;
           System.out.println(token + " : " + new String(scanner.getCurrentTokenSource()));
         }

  `

  The returned scanner will tolerate unterminated line comments (missing line separator). It can be made stricter by using API with extra boolean parameter (`strictCommentMode`).

  Parameters:
    `tokenizeComments` - if set to `false`, comments will be silently consumed
    `tokenizeWhiteSpace` - if set to `false`, white spaces will be silently consumed,
    `assertMode` - if set to `false`, occurrences of 'assert' will be reported as identifiers (`ITerminalSymbols#TokenNameIdentifier`), whereas if set to `true`, it would report assert keywords (`ITerminalSymbols#TokenNameassert`). Java 1.4 has introduced a new 'assert' keyword.
    `recordLineSeparator` - if set to `true`, the scanner will record positions of encountered line separator ends. In case of multi-character line separators, the last character position is considered. These positions can then be extracted using `IScanner#getLineEnds`. Only non-unicode escape sequences are considered as valid line separators.
  Returns:
    a scanner
  See Also:
    `IScanner`

### createScanner

    public static IScanner createScanner(boolean tokenizeComments,
                                         boolean tokenizeWhiteSpace,
                                         boolean recordLineSeparator,
                                         String sourceLevel)

  Create a scanner, indicating the level of detail requested for tokenizing. The scanner can then be used to tokenize some source in a Java aware way. Here is a typical scanning loop: `

         IScanner scanner = ToolFactory.createScanner(false, false, false, false);
         scanner.setSource("int i = 0;".toCharArray());
         while (true) {
           int token = scanner.getNextToken();
           if (token == ITerminalSymbols.TokenNameEOF) break;
           System.out.println(token + " : " + new String(scanner.getCurrentTokenSource()));
         }

  `

  The returned scanner will tolerate unterminated line comments (missing line separator). It can be made stricter by using API with extra boolean parameter (`strictCommentMode`).

  Parameters:
    `tokenizeComments` - if set to `false`, comments will be silently consumed
    `tokenizeWhiteSpace` - if set to `false`, white spaces will be silently consumed,
    `recordLineSeparator` - if set to `true`, the scanner will record positions of encountered line separator ends. In case of multi-character line separators, the last character position is considered. These positions can then be extracted using `IScanner#getLineEnds`. Only non-unicode escape sequences are considered as valid line separators.
    `sourceLevel` - if set to `"1.3"` or `null`, occurrences of 'assert' will be reported as identifiers (`ITerminalSymbols#TokenNameIdentifier`), whereas if set to `"1.4"`, it would report assert keywords (`ITerminalSymbols#TokenNameassert`). Java 1.4 has introduced a new 'assert' keyword.
  Returns:
    a scanner
  Since:
    3.0
  See Also:
    `IScanner`

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

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.