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

java.lang.Object
  extended by org.eclipse.jdt.internal.compiler.util.Util
All Implemented Interfaces:
SuffixConstants

public class Util
extends java.lang.Object
implements SuffixConstants


Nested Class Summary
static interface Util.Displayable
           
 
Field Summary
static int[] EMPTY_INT_ARRAY
           
static java.lang.String EMPTY_STRING
           
static java.lang.String LINE_SEPARATOR
           
static java.lang.String UTF_8
           
 
Fields inherited from interface 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
 
Constructor Summary
Util()
           
 
Method Summary
static java.lang.String buildAllDirectoriesInto(java.lang.String outputPath, java.lang.String relativeFileName)
          Build all the directories and subdirectories corresponding to the packages names into the directory specified in parameters.
static char[] bytesToChar(byte[] bytes, java.lang.String encoding)
          Returns the given bytes as a char array using a given encoding (null means platform default).
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 byte[] getFileByteContent(java.io.File file)
          Returns the contents of the given file as a byte array.
static char[] getFileCharContent(java.io.File file, java.lang.String encoding)
          Returns the contents of the given file as a char array.
static byte[] getInputStreamAsByteArray(java.io.InputStream stream, int length)
          Returns the given input stream's contents as a byte array.
static char[] getInputStreamAsCharArray(java.io.InputStream stream, int length, java.lang.String encoding)
          Returns the given input stream's contents as a character array.
static int getLineNumber(int position, int[] lineEnds, int g, int d)
           
static byte[] getZipEntryByteContent(java.util.zip.ZipEntry ze, java.util.zip.ZipFile zip)
          Returns the contents of the given zip entry as a byte array.
static boolean isClassFileName(char[] name)
          Returns true iff str.toLowerCase().endsWith(".class") implementation is not creating extra strings.
static boolean isClassFileName(java.lang.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(java.lang.String name)
          Returns true iff str.toLowerCase().endsWith(".java") implementation is not creating extra strings.
static boolean isPotentialZipArchive(java.lang.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 reverseQuickSort(char[][] list, int left, int right)
           
static void reverseQuickSort(char[][] list, int left, int right, int[] result)
           
static int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position)
          INTERNAL USE-ONLY Search the column number corresponding to a specific position
static java.lang.Boolean toBoolean(boolean bool)
          Converts a boolean value into Boolean.
static java.lang.String toString(java.lang.Object[] objects)
          Converts an array of Objects into String.
static java.lang.String toString(java.lang.Object[] objects, Util.Displayable renderer)
          Converts an array of Objects into String.
static void writeToDisk(boolean generatePackagesStructure, java.lang.String outputPath, java.lang.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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF_8

public static final java.lang.String UTF_8
See Also:
Constant Field Values

LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR

EMPTY_STRING

public static final java.lang.String EMPTY_STRING

EMPTY_INT_ARRAY

public static final int[] EMPTY_INT_ARRAY
Constructor Detail

Util

public Util()
Method Detail

buildAllDirectoriesInto

public static java.lang.String buildAllDirectoriesInto(java.lang.String outputPath,
                                                       java.lang.String relativeFileName)
                                                throws java.io.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 *

Parameters:
outputPath - java.lang.String
relativeFileName - java.lang.String
Returns:
java.lang.String
Throws:
java.io.IOException

bytesToChar

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

Throws:
java.io.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(java.io.File file)
                                 throws java.io.IOException
Returns the contents of the given file as a byte array.

Throws:
java.io.IOException - if a problem occured reading the file.

getFileCharContent

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

Throws:
java.io.IOException - if a problem occured reading the file.

getInputStreamAsByteArray

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

Throws:
java.io.IOException - if a problem occured reading the stream.

getInputStreamAsCharArray

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

Throws:
java.io.IOException - if a problem occured reading the stream.

getLineNumber

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

getZipEntryByteContent

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

Throws:
java.io.IOException - if a problem occured reading the zip entry.

isPotentialZipArchive

public static final boolean isPotentialZipArchive(java.lang.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(java.lang.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(java.lang.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 java.lang.Boolean toBoolean(boolean bool)
Converts a boolean value into Boolean.

Parameters:
bool - The boolean to convert
Returns:
The corresponding Boolean object (TRUE or FALSE).

toString

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


toString

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


writeToDisk

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

Parameters:
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
Throws:
java.io.IOException