Klasse ToolFactory

java.lang.Object
org.aspectj.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.

Seit:
2.0
  • Felddetails

  • Konstruktordetails

    • ToolFactory

      public ToolFactory()
  • Methodendetails

    • createCodeFormatter

      public static ICodeFormatter createCodeFormatter()
      Veraltet.
      The extension point has been deprecated, use createCodeFormatter(Map) instead.
      Create an instance of a code formatter. A code formatter implementation can be contributed via the extension point "org.aspectj.org.eclipse.jdt.core.codeFormatter". If unable to find a registered extension, the factory will default to using the default code formatter.
      Gibt zurück:
      an instance of a code formatter
      Siehe auch:
    • createCodeFormatter

      public static CodeFormatter createCodeFormatter(Map options)
      Create an instance of the built-in code formatter.

      The given options should at least provide the source level (JavaCore.COMPILER_SOURCE), the compiler compliance level (JavaCore.COMPILER_COMPLIANCE) and the target platform (JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM). Without these options, it is not possible for the code formatter to know what kind of source it needs to format.

      Note this is equivalent to createCodeFormatter(options, M_FORMAT_NEW). Thus some code formatter options may be ignored. See @{link M_FORMAT_NEW for more details.

      Parameter:
      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.
      Gibt zurück:
      an instance of the built-in code formatter
      Seit:
      3.0
      Siehe auch:
    • createCodeFormatter

      public static CodeFormatter createCodeFormatter(Map options, int mode)
      Creates an instance of a code formatter. A code formatter implementation can be contributed via the extension point "org.aspectj.org.eclipse.jdt.core.javaFormatter". The formatter id specified in the "org.aspectj.org.eclipse.jdt.core.javaFormatter" is instantiated. If unable to find a registered extension, the factory will default to using the default code formatter.

      The given options should at least provide the source level (JavaCore.COMPILER_SOURCE), the compiler compliance level (JavaCore.COMPILER_COMPLIANCE) and the target platform (JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM). Without these options, it is not possible for the code formatter to know what kind of source it needs to format.

      The given mode determines what options should be enabled when formatting the code. It can have the following values: M_FORMAT_NEW, M_FORMAT_EXISTING, but other values may be added in the future.

      Parameter:
      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.
      mode - the given mode to modify the given options.
      Gibt zurück:
      an instance of the built-in code formatter
      Seit:
      3.3
      Siehe auch:
    • createDefaultClassFileBytesDisassembler

      public static ClassFileBytesDisassembler createDefaultClassFileBytesDisassembler()
      Create a classfile bytecode disassembler, able to produce a String representation of a given classfile.
      Gibt zurück:
      a classfile bytecode disassembler
      Seit:
      2.1
      Siehe auch:
    • createDefaultClassFileDisassembler

      public static IClassFileDisassembler createDefaultClassFileDisassembler()
      Create a classfile bytecode disassembler, able to produce a String representation of a given classfile.
      Gibt zurück:
      a classfile bytecode disassembler
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.core.util.IClassFileDisassembler
    • 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.
      Parameter:
      classfile - the classfile element to introspect
      decodingFlag - the flag used to decode the class file reader.
      Gibt zurück:
      a default classfile reader
      Siehe auch:
    • createDefaultClassFileReader

      public static IClassFileReader createDefaultClassFileReader(InputStream stream, 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 input stream contents cannot be retrieved The decoding flags are described in IClassFileReader.
      Parameter:
      stream - the given input stream to read
      decodingFlag - the flag used to decode the class file reader.
      Gibt zurück:
      a default classfile reader
      Seit:
      3.2
      Siehe auch:
    • 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.
      Parameter:
      fileName - the name of the file to be read
      decodingFlag - the flag used to decode the class file reader.
      Gibt zurück:
      a default classfile reader
      Siehe auch:
    • 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.
      Parameter:
      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.
      Gibt zurück:
      a default classfile reader
      Siehe auch:
    • createDefaultCodeFormatter

      public static ICodeFormatter createDefaultCodeFormatter(Map options)
      Veraltet.
      Use createCodeFormatter(Map) instead but note the different options
      Create an instance of the default code formatter.
      Parameter:
      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.
      Gibt zurück:
      an instance of the built-in code formatter
      Siehe auch:
    • 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()));
         }
       
       

      By default the compliance used to create the scanner is the workspace's compliance when running inside the IDE or 1.4 if running from outside of a headless eclipse.

      Parameter:
      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.
      Gibt zurück:
      a scanner
      Siehe auch:
    • 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()));
         }
       
       

      By default the compliance used to create the scanner is the workspace's compliance when running inside the IDE or 1.4 if running from outside of a headless eclipse.

      Parameter:
      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.
      Gibt zurück:
      a scanner
      Seit:
      3.0
      Siehe auch:
    • createScanner

      public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator, String sourceLevel, String complianceLevel)
      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()));
         }
       
       
      Parameter:
      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.
      complianceLevel - This is used to support the Unicode 4.0 character sets. if set to 1.5 or above, the Unicode 4.0 is supported, otherwise Unicode 3.0 is supported.
      Gibt zurück:
      a scanner
      Seit:
      3.1
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.core.compiler.IScanner
    • createScanner

      public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator, String sourceLevel, String complianceLevel, boolean enablePreview)
      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()));
         }
       
       
      Parameter:
      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.
      complianceLevel - This is used to support the Unicode 4.0 character sets. if set to 1.5 or above, the Unicode 4.0 is supported, otherwise Unicode 3.0 is supported.
      enablePreview - specify whether the scanner should look for preview language features for the specified compliance level
      Gibt zurück:
      a scanner
      Seit:
      3.20
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.core.compiler.IScanner