org.eclipse.jdt.internal.compiler.util
类 Util

java.lang.Object
  继承者 org.eclipse.jdt.internal.compiler.util.Util
所有已实现的接口:
SuffixConstants

public class Util
extends Object
implements SuffixConstants


嵌套类摘要
static interface Util.Displayable
           
 
字段摘要
static char C_ARRAY
          Character constant indicating an array type in a signature.
static char C_BOOLEAN
          Character constant indicating the primitive type boolean in a signature.
static char C_BYTE
          Character constant indicating the primitive type byte in a signature.
static char C_CAPTURE
          Character constant indicating a capture of a wildcard type in a signature.
static char C_CHAR
          Character constant indicating the primitive type char in a signature.
static char C_COLON
          Character constant indicating the colon in a signature.
static char C_DOLLAR
          Character constant indicating the dollar in a signature.
static char C_DOT
          Character constant indicating the dot in a signature.
static char C_DOUBLE
          Character constant indicating the primitive type double in a signature.
static char C_EXCEPTION_START
          Character constant indicating an exception in a signature.
static char C_EXTENDS
          Character constant indicating a bound wildcard type argument in a signature with extends clause.
static char C_FLOAT
          Character constant indicating the primitive type float in a signature.
static char C_GENERIC_END
          Character constant indicating the end of a generic type list in a signature.
static char C_GENERIC_START
          Character constant indicating the start of a formal type parameter (or type argument) list in a signature.
static char C_INT
          Character constant indicating the primitive type int in a signature.
static char C_LONG
          Character constant indicating the primitive type long in a signature.
static char C_NAME_END
          Character constant indicating the end of a named type in a signature.
static char C_PARAM_END
          Character constant indicating the end of a parameter type list in a signature.
static char C_PARAM_START
          Character constant indicating the start of a parameter type list in a signature.
static char C_RESOLVED
          Character constant indicating the start of a resolved, named type in a signature.
static char C_SEMICOLON
          Character constant indicating the semicolon in a signature.
static char C_SHORT
          Character constant indicating the primitive type short in a signature.
static char C_STAR
          Character constant indicating an unbound wildcard type argument in a signature.
static char C_SUPER
          Character constant indicating a bound wildcard type argument in a signature with super clause.
static char C_TYPE_VARIABLE
          Character constant indicating the start of a resolved type variable in a signature.
static char C_UNRESOLVED
          Character constant indicating the start of an unresolved, named type in a signature.
static char C_VOID
          Character constant indicating result type void in a signature.
static int[] EMPTY_INT_ARRAY
           
static String EMPTY_STRING
           
static String LINE_SEPARATOR
           
static String UTF_8
           
 
从接口 org.eclipse.jdt.internal.compiler.util.SuffixConstants 继承的字段
EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA
 
构造方法摘要
Util()
           
 
方法摘要
static String buildAllDirectoriesInto(String outputPath, String relativeFileName)
          Build all the directories and subdirectories corresponding to the packages names into the directory specified in parameters.
static char[] bytesToChar(byte[] bytes, String encoding)
          Returns the given bytes as a char array using a given encoding (null means platform default).
static void collectRunningVMBootclasspath(List bootclasspaths)
           
static int computeOuterMostVisibility(TypeDeclaration typeDeclaration, int visibility)
          Returns the outer most enclosing type's visibility for the given TypeDeclaration and visibility based on compiler options.
static String getExceptionSummary(Throwable exception)
          Returns a one line summary for an exception (extracted from its stacktrace: name + first frame)
static byte[] getFileByteContent(File file)
          Returns the contents of the given file as a byte array.
static char[] getFileCharContent(File file, String encoding)
          Returns the contents of the given file as a char array.
static byte[] getInputStreamAsByteArray(InputStream stream, int length)
          Returns the given input stream's contents as a byte array.
static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding)
          Returns the given input stream's contents as a character array.
static File getJavaHome()
           
static int getLineNumber(int position, int[] lineEnds, int g, int d)
           
static int getParameterCount(char[] methodSignature)
           
static byte[] getZipEntryByteContent(ZipEntry ze, ZipFile zip)
          Returns the contents of the given zip entry as a byte array.
static int hashCode(Object[] array)
           
static boolean isClassFileName(char[] name)
          Returns true iff str.toLowerCase().endsWith(".class") implementation is not creating extra strings.
static boolean isClassFileName(String name)
          Returns true iff str.toLowerCase().endsWith(".class") implementation is not creating extra strings.
static boolean isExcluded(char[] path, char[][] inclusionPatterns, char[][] exclusionPatterns, boolean isFolderPath)
           
static boolean isJavaFileName(char[] name)
          Returns true iff str.toLowerCase().endsWith(".java") implementation is not creating extra strings.
static boolean isJavaFileName(String name)
          Returns true iff str.toLowerCase().endsWith(".java") implementation is not creating extra strings.
static boolean isPotentialZipArchive(String name)
          Returns whether the given name is potentially a zip archive file name (it has a file extension and it is not ".java" nor ".class")
static void recordNestedType(ClassFile classFile, TypeBinding typeBinding)
           
static void reverseQuickSort(char[][] list, int left, int right)
           
static void reverseQuickSort(char[][] list, int left, int right, int[] result)
           
static int scanArrayTypeSignature(char[] string, int start)
          Scans the given string for an array type signature starting at the given index and returns the index of the last character.
static int scanBaseTypeSignature(char[] string, int start)
          Scans the given string for a base type signature starting at the given index and returns the index of the last character.
static int scanCaptureTypeSignature(char[] string, int start)
          Scans the given string for a capture of a wildcard type signature starting at the given index and returns the index of the last character.
static int scanClassTypeSignature(char[] string, int start)
          Scans the given string for a class type signature starting at the given index and returns the index of the last character.
static int scanIdentifier(char[] string, int start)
          Scans the given string for an identifier starting at the given index and returns the index of the last character.
static int scanTypeArgumentSignature(char[] string, int start)
          Scans the given string for a type argument signature starting at the given index and returns the index of the last character.
static int scanTypeArgumentSignatures(char[] string, int start)
          Scans the given string for a list of type argument signatures starting at the given index and returns the index of the last character.
static int scanTypeBoundSignature(char[] string, int start)
          Scans the given string for a type bound signature starting at the given index and returns the index of the last character.
static int scanTypeSignature(char[] string, int start)
          Scans the given string for a type signature starting at the given index and returns the index of the last character.
static int scanTypeVariableSignature(char[] string, int start)
          Scans the given string for a type variable signature starting at the given index and returns the index of the last character.
static int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position)
          INTERNAL USE-ONLY Search the column number corresponding to a specific position
static Boolean toBoolean(boolean bool)
          Converts a boolean value into Boolean.
static String toString(Object[] objects)
          Converts an array of Objects into String.
static String toString(Object[] objects, Util.Displayable renderer)
          Converts an array of Objects into String.
static void writeToDisk(boolean generatePackagesStructure, String outputPath, String relativeFileName, ClassFile classFile)
          outputPath is formed like: c:\temp\ the last character is a file separator relativeFileName is formed like: java\lang\String.class
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

C_BOOLEAN

public static final char C_BOOLEAN
Character constant indicating the primitive type boolean in a signature. Value is 'Z'.

另请参见:
常量字段值

C_BYTE

public static final char C_BYTE
Character constant indicating the primitive type byte in a signature. Value is 'B'.

另请参见:
常量字段值

C_CHAR

public static final char C_CHAR
Character constant indicating the primitive type char in a signature. Value is 'C'.

另请参见:
常量字段值

C_DOUBLE

public static final char C_DOUBLE
Character constant indicating the primitive type double in a signature. Value is 'D'.

另请参见:
常量字段值

C_FLOAT

public static final char C_FLOAT
Character constant indicating the primitive type float in a signature. Value is 'F'.

另请参见:
常量字段值

C_INT

public static final char C_INT
Character constant indicating the primitive type int in a signature. Value is 'I'.

另请参见:
常量字段值

C_SEMICOLON

public static final char C_SEMICOLON
Character constant indicating the semicolon in a signature. Value is ';'.

另请参见:
常量字段值

C_COLON

public static final char C_COLON
Character constant indicating the colon in a signature. Value is ':'.

从以下版本开始:
3.0
另请参见:
常量字段值

C_LONG

public static final char C_LONG
Character constant indicating the primitive type long in a signature. Value is 'J'.

另请参见:
常量字段值

C_SHORT

public static final char C_SHORT
Character constant indicating the primitive type short in a signature. Value is 'S'.

另请参见:
常量字段值

C_VOID

public static final char C_VOID
Character constant indicating result type void in a signature. Value is 'V'.

另请参见:
常量字段值

C_TYPE_VARIABLE

public static final char C_TYPE_VARIABLE
Character constant indicating the start of a resolved type variable in a signature. Value is 'T'.

从以下版本开始:
3.0
另请参见:
常量字段值

C_STAR

public static final char C_STAR
Character constant indicating an unbound wildcard type argument in a signature. Value is '*'.

从以下版本开始:
3.0
另请参见:
常量字段值

C_EXCEPTION_START

public static final char C_EXCEPTION_START
Character constant indicating an exception in a signature. Value is '^'.

从以下版本开始:
3.1
另请参见:
常量字段值

C_EXTENDS

public static final char C_EXTENDS
Character constant indicating a bound wildcard type argument in a signature with extends clause. Value is '+'.

从以下版本开始:
3.1
另请参见:
常量字段值

C_SUPER

public static final char C_SUPER
Character constant indicating a bound wildcard type argument in a signature with super clause. Value is '-'.

从以下版本开始:
3.1
另请参见:
常量字段值

C_DOT

public static final char C_DOT
Character constant indicating the dot in a signature. Value is '.'.

另请参见:
常量字段值

C_DOLLAR

public static final char C_DOLLAR
Character constant indicating the dollar in a signature. Value is '$'.

另请参见:
常量字段值

C_ARRAY

public static final char C_ARRAY
Character constant indicating an array type in a signature. Value is '['.

另请参见:
常量字段值

C_RESOLVED

public static final char C_RESOLVED
Character constant indicating the start of a resolved, named type in a signature. Value is 'L'.

另请参见:
常量字段值

C_UNRESOLVED

public static final char C_UNRESOLVED
Character constant indicating the start of an unresolved, named type in a signature. Value is 'Q'.

另请参见:
常量字段值

C_NAME_END

public static final char C_NAME_END
Character constant indicating the end of a named type in a signature. Value is ';'.

另请参见:
常量字段值

C_PARAM_START

public static final char C_PARAM_START
Character constant indicating the start of a parameter type list in a signature. Value is '('.

另请参见:
常量字段值

C_PARAM_END

public static final char C_PARAM_END
Character constant indicating the end of a parameter type list in a signature. Value is ')'.

另请参见:
常量字段值

C_GENERIC_START

public static final char C_GENERIC_START
Character constant indicating the start of a formal type parameter (or type argument) list in a signature. Value is '<'.

从以下版本开始:
3.0
另请参见:
常量字段值

C_GENERIC_END

public static final char C_GENERIC_END
Character constant indicating the end of a generic type list in a signature. Value is '>'.

从以下版本开始:
3.0
另请参见:
常量字段值

C_CAPTURE

public static final char C_CAPTURE
Character constant indicating a capture of a wildcard type in a signature. Value is '!'.

从以下版本开始:
3.1
另请参见:
常量字段值

UTF_8

public static final String UTF_8
另请参见:
常量字段值

LINE_SEPARATOR

public static final String LINE_SEPARATOR

EMPTY_STRING

public static final String EMPTY_STRING

EMPTY_INT_ARRAY

public static final int[] EMPTY_INT_ARRAY
构造方法详细信息

Util

public Util()
方法详细信息

buildAllDirectoriesInto

public static String buildAllDirectoriesInto(String outputPath,
                                             String relativeFileName)
                                      throws IOException
Build all the directories and subdirectories corresponding to the packages names into the directory specified in parameters. outputPath is formed like: c:\temp\ the last character is a file separator relativeFileName is formed like: java\lang\String.class *

参数:
outputPath - java.lang.String
relativeFileName - java.lang.String
返回:
java.lang.String
抛出:
IOException

bytesToChar

public static char[] bytesToChar(byte[] bytes,
                                 String encoding)
                          throws IOException
Returns the given bytes as a char array using a given encoding (null means platform default).

抛出:
IOException

computeOuterMostVisibility

public static int computeOuterMostVisibility(TypeDeclaration typeDeclaration,
                                             int visibility)
Returns the outer most enclosing type's visibility for the given TypeDeclaration and visibility based on compiler options.


getFileByteContent

public static byte[] getFileByteContent(File file)
                                 throws IOException
Returns the contents of the given file as a byte array.

抛出:
IOException - if a problem occured reading the file.

getFileCharContent

public static char[] getFileCharContent(File file,
                                        String encoding)
                                 throws IOException
Returns the contents of the given file as a char array. When encoding is null, then the platform default one is used

抛出:
IOException - if a problem occured reading the file.

getInputStreamAsByteArray

public static byte[] getInputStreamAsByteArray(InputStream stream,
                                               int length)
                                        throws IOException
Returns the given input stream's contents as a byte array. If a length is specified (i.e. if length != -1), only length bytes are returned. Otherwise all bytes in the stream are returned. Note this doesn't close the stream.

抛出:
IOException - if a problem occured reading the stream.

getInputStreamAsCharArray

public static char[] getInputStreamAsCharArray(InputStream stream,
                                               int length,
                                               String encoding)
                                        throws IOException
Returns the given input stream's contents as a character array. If a length is specified (i.e. if length != -1), this represents the number of bytes in the stream. Note this doesn't close the stream.

抛出:
IOException - if a problem occured reading the stream.

getExceptionSummary

public static String getExceptionSummary(Throwable exception)
Returns a one line summary for an exception (extracted from its stacktrace: name + first frame)

参数:
exception -
返回:
one line summary for an exception

getLineNumber

public static int getLineNumber(int position,
                                int[] lineEnds,
                                int g,
                                int d)

getZipEntryByteContent

public static byte[] getZipEntryByteContent(ZipEntry ze,
                                            ZipFile zip)
                                     throws IOException
Returns the contents of the given zip entry as a byte array.

抛出:
IOException - if a problem occured reading the zip entry.

hashCode

public static int hashCode(Object[] array)

isPotentialZipArchive

public static final boolean isPotentialZipArchive(String name)
Returns whether the given name is potentially a zip archive file name (it has a file extension and it is not ".java" nor ".class")


isClassFileName

public static final boolean isClassFileName(char[] name)
Returns true iff str.toLowerCase().endsWith(".class") implementation is not creating extra strings.


isClassFileName

public static final boolean isClassFileName(String name)
Returns true iff str.toLowerCase().endsWith(".class") implementation is not creating extra strings.


isExcluded

public static final boolean isExcluded(char[] path,
                                       char[][] inclusionPatterns,
                                       char[][] exclusionPatterns,
                                       boolean isFolderPath)

isJavaFileName

public static final boolean isJavaFileName(char[] name)
Returns true iff str.toLowerCase().endsWith(".java") implementation is not creating extra strings.


isJavaFileName

public static final boolean isJavaFileName(String name)
Returns true iff str.toLowerCase().endsWith(".java") implementation is not creating extra strings.


reverseQuickSort

public static void reverseQuickSort(char[][] list,
                                    int left,
                                    int right)

reverseQuickSort

public static void reverseQuickSort(char[][] list,
                                    int left,
                                    int right,
                                    int[] result)

searchColumnNumber

public static final int searchColumnNumber(int[] startLineIndexes,
                                           int lineNumber,
                                           int position)
INTERNAL USE-ONLY Search the column number corresponding to a specific position


toBoolean

public static Boolean toBoolean(boolean bool)
Converts a boolean value into Boolean.

参数:
bool - The boolean to convert
返回:
The corresponding Boolean object (TRUE or FALSE).

toString

public static String toString(Object[] objects)
Converts an array of Objects into String.


toString

public static String toString(Object[] objects,
                              Util.Displayable renderer)
Converts an array of Objects into String.


writeToDisk

public static void writeToDisk(boolean generatePackagesStructure,
                               String outputPath,
                               String relativeFileName,
                               ClassFile classFile)
                        throws IOException
outputPath is formed like: c:\temp\ the last character is a file separator relativeFileName is formed like: java\lang\String.class

参数:
generatePackagesStructure - a flag to know if the packages structure has to be generated.
outputPath - the given output directory
relativeFileName - the given relative file name
classFile - the given classFile to write
抛出:
IOException

recordNestedType

public static void recordNestedType(ClassFile classFile,
                                    TypeBinding typeBinding)

getJavaHome

public static File getJavaHome()

collectRunningVMBootclasspath

public static void collectRunningVMBootclasspath(List bootclasspaths)

getParameterCount

public static int getParameterCount(char[] methodSignature)

scanTypeSignature

public static int scanTypeSignature(char[] string,
                                    int start)
Scans the given string for a type signature starting at the given index and returns the index of the last character.
 TypeSignature:
  |  BaseTypeSignature
  |  ArrayTypeSignature
  |  ClassTypeSignature
  |  TypeVariableSignature
 

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a type signature

scanBaseTypeSignature

public static int scanBaseTypeSignature(char[] string,
                                        int start)
Scans the given string for a base type signature starting at the given index and returns the index of the last character.
 BaseTypeSignature:
     B | C | D | F | I
   | J | S | V | Z
 
Note that although the base type "V" is only allowed in method return types, there is no syntactic ambiguity. This method will accept them anywhere without complaint.

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a base type signature

scanArrayTypeSignature

public static int scanArrayTypeSignature(char[] string,
                                         int start)
Scans the given string for an array type signature starting at the given index and returns the index of the last character.
 ArrayTypeSignature:
     [ TypeSignature
 

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not an array type signature

scanCaptureTypeSignature

public static int scanCaptureTypeSignature(char[] string,
                                           int start)
Scans the given string for a capture of a wildcard type signature starting at the given index and returns the index of the last character.
 CaptureTypeSignature:
     ! TypeBoundSignature
 

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a capture type signature

scanTypeVariableSignature

public static int scanTypeVariableSignature(char[] string,
                                            int start)
Scans the given string for a type variable signature starting at the given index and returns the index of the last character.
 TypeVariableSignature:
     T Identifier ;
 

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a type variable signature

scanIdentifier

public static int scanIdentifier(char[] string,
                                 int start)
Scans the given string for an identifier starting at the given index and returns the index of the last character. Stop characters are: ";", ":", "<", ">", "/", ".".

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not an identifier

scanClassTypeSignature

public static int scanClassTypeSignature(char[] string,
                                         int start)
Scans the given string for a class type signature starting at the given index and returns the index of the last character.
 ClassTypeSignature:
     { L | Q } Identifier
           { { / | . Identifier [ < TypeArgumentSignature* > ] }
           ;
 
Note that although all "/"-identifiers most come before "."-identifiers, there is no syntactic ambiguity. This method will accept them without complaint.

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a class type signature

scanTypeBoundSignature

public static int scanTypeBoundSignature(char[] string,
                                         int start)
Scans the given string for a type bound signature starting at the given index and returns the index of the last character.
 TypeBoundSignature:
     [-+] TypeSignature ;
     *
 

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a type variable signature

scanTypeArgumentSignatures

public static int scanTypeArgumentSignatures(char[] string,
                                             int start)
Scans the given string for a list of type argument signatures starting at the given index and returns the index of the last character.
 TypeArgumentSignatures:
     < TypeArgumentSignature* >
 
Note that although there is supposed to be at least one type argument, there is no syntactic ambiguity if there are none. This method will accept zero type argument signatures without complaint.

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a list of type arguments signatures

scanTypeArgumentSignature

public static int scanTypeArgumentSignature(char[] string,
                                            int start)
Scans the given string for a type argument signature starting at the given index and returns the index of the last character.
 TypeArgumentSignature:
     *
  |  + TypeSignature
  |  - TypeSignature
  |  TypeSignature
 
Note that although base types are not allowed in type arguments, there is no syntactic ambiguity. This method will accept them without complaint.

参数:
string - the signature string
start - the 0-based character index of the first character
返回:
the 0-based character index of the last character
抛出:
IllegalArgumentException - if this is not a type argument signature


Copyright © 2013. All Rights Reserved.