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 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_jar, EXTENSION_JAR, EXTENSION_java, EXTENSION_JAVA, EXTENSION_zip, EXTENSION_ZIP, SUFFIX_class, SUFFIX_CLASS, SUFFIX_jar, SUFFIX_JAR, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_jar, SUFFIX_STRING_JAR, SUFFIX_STRING_java, SUFFIX_STRING_JAVA, SUFFIX_STRING_zip, SUFFIX_STRING_ZIP, SUFFIX_zip, SUFFIX_ZIP
 
Constructor Summary
Util()
           
 
Method Summary
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 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 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 isArchiveFileName(java.lang.String name)
          Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip") implementation is not creating extra strings.
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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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 java.lang.String LINE_SEPARATOR
Constructor Detail

Util

public Util()
Method Detail

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

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.

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.

isArchiveFileName

public static final boolean isArchiveFileName(java.lang.String name)
Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip") implementation is not creating extra strings.


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.


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.