| java.lang.Object com.google.gwt.dev.util.Util
Util | final public class Util (Code) | | A smattering of useful methods. Methods in this class are candidates for
being moved to
com.google.gwt.util.tools.Utility if they would be
generally useful to tool writers, and don't involve TreeLogger.
|
Method Summary | |
public static void | addAll(Collection<T> c, T[] a) | public static byte[] | append(byte[] xs, byte x) | public static T[] | append(T[] xs, T x) | public static T[] | append(T[] appendToThis, T[] these) | public static String | computeStrongName(byte[] content) Computes the MD5 hash for the specified byte array. | public static boolean | copy(TreeLogger logger, File in, File out) | public static void | copy(TreeLogger logger, InputStream is, File out) | public static void | copy(TreeLogger logger, InputStream is, OutputStream os) | public static boolean | copy(TreeLogger logger, URL in, File out) | public static Reader | createReader(TreeLogger logger, URL url) | public static void | deleteFilesInDirectory(File dir) | public static void | deleteFilesStartingWith(File dir, String prefix) Deletes all files have the same base name as the specified file. | public static String | escapeXml(String unescaped) Escapes '&', '<', '>', '"', and '\'' to their XML entity equivalents. | public static String | findFileName(String location) Converts a URL "jar:file:aaa.jar!bbb" to the filename "aaa.jar". | public static URL | findSourceInClassPath(ClassLoader cl, String sourceTypeName) | public static String | getClassName(Class> cls) Parameters: cls - A class whose name you want. | public static String | getClassName(String className) Parameters: className - A fully-qualified class name whose name you want. | public static String | getFileFromInstallPath(String relativePath) Gets the contents of a file. | public static void | hex4(char c, StringBuffer sb) A 4-digit hex result. | public static void | invokeInaccessableMethod(Class> targetClass, String methodName, Class>[] argumentTypes, TypeOracle target, Object[] arguments) This method invokes an inaccessible method in another class. | public static boolean | isCompilationUnitOnDisk(String loc) | public static boolean | isValidJavaIdent(String token) | public static void | logMissingTypeErrorWithHints(TreeLogger logger, String missingType) | public static File | makeRelativeFile(File from, File to) Attempts to make a path relative to a particular directory. | public static String | makeRelativePath(File from, File to) | public static String | makeRelativePath(File from, String to) | public static String | maybeDumpSource(TreeLogger logger, String location, char[] source, String optionalTypeName) Give the developer a chance to see the in-memory source that failed. | public static byte[] | readFileAsBytes(File file) | public static char[] | readFileAsChars(File file) | public static String | readFileAsString(File file) | public static String | readNextLine(BufferedReader br) Reads the next non-empty line. | public static byte[] | readURLAsBytes(URL url) | public static char[] | readURLAsChars(URL url) | public static void | recursiveDelete(File file, boolean childrenOnly) Deletes a file or recursively deletes a directory. | public static File | removeExtension(File file) | public static T[] | removeNulls(T[] a) | public static String | slashify(String path) Parameters: path - The path to slashify. | public static T[] | toArray(Class<? super T> componentType, Collection<? extends T> coll) Creates an array from a collection of the specified component type and
size. | public static T[] | toArrayReversed(Class<? super T> componentType, Collection<? extends T> coll) Like
Util.toArray(Class,Collection) , but the option of having the
array reversed. | public static String | toHexString(byte[] bytes) Returns a string representation of the byte array as a series of
hexadecimal characters. | public static String[] | toStringArray(Collection<String> coll) Creates a string array from the contents of a collection. | public static URL | toURL(File f) | public static URL | toURL(URL jarUrl, JarEntry jarEntry) | public static URL | toURL(URL jarUrl, String path) | public static String | toXml(Document doc) | public static byte[] | toXmlUtf8(Document doc) | public static File | tryCombine(File parentMaybeIgnored, File childMaybeAbsolute) | public static File | tryCombine(File parentMaybeIgnored, String childMaybeAbsolute) | public static File | tryMakeCanonical(File file) Attempts to find the canonical form of a file path. | public static void | writeBytesToFile(TreeLogger logger, File where, byte[] what) | public static void | writeBytesToFile(TreeLogger logger, File where, byte[][] what) Gathering write. | public static void | writeCharsAsFile(TreeLogger logger, File file, char[] chars) | public static boolean | writeStringAsFile(File file, String string) |
EMPTY_ARRAY_FILE | final public static File[] EMPTY_ARRAY_FILE(Code) | | |
EMPTY_ARRAY_STRING | final public static String[] EMPTY_ARRAY_STRING(Code) | | |
HEX_CHARS | public static char[] HEX_CHARS(Code) | | |
append | public static byte[] append(byte[] xs, byte x)(Code) | | |
append | public static T[] append(T[] xs, T x)(Code) | | |
append | public static T[] append(T[] appendToThis, T[] these)(Code) | | |
computeStrongName | public static String computeStrongName(byte[] content)(Code) | | Computes the MD5 hash for the specified byte array.
a big fat string encoding of the MD5 for the content, suitablyformatted for use as a file name |
deleteFilesInDirectory | public static void deleteFilesInDirectory(File dir)(Code) | | |
deleteFilesStartingWith | public static void deleteFilesStartingWith(File dir, String prefix)(Code) | | Deletes all files have the same base name as the specified file.
|
escapeXml | public static String escapeXml(String unescaped)(Code) | | Escapes '&', '<', '>', '"', and '\'' to their XML entity equivalents.
|
findFileName | public static String findFileName(String location)(Code) | | Converts a URL "jar:file:aaa.jar!bbb" to the filename "aaa.jar". This also
does URLDecoding if needed.
Parameters: location - the URL pointing at a jar location the path to the jar file |
getClassName | public static String getClassName(Class> cls)(Code) | | Parameters: cls - A class whose name you want. The base name for the specified class. |
getClassName | public static String getClassName(String className)(Code) | | Parameters: className - A fully-qualified class name whose name you want. The base name for the specified class. |
getFileFromInstallPath | public static String getFileFromInstallPath(String relativePath)(Code) | | Gets the contents of a file.
Parameters: relativePath - relative path within the install directory the contents of the file, or null if an error occurred |
invokeInaccessableMethod | public static void invokeInaccessableMethod(Class> targetClass, String methodName, Class>[] argumentTypes, TypeOracle target, Object[] arguments)(Code) | | This method invokes an inaccessible method in another class.
Parameters: targetClass - the class owning the method Parameters: methodName - the name of the method Parameters: argumentTypes - the types of the parameters to the method call Parameters: target - the receiver of the method call Parameters: arguments - the parameters to the method call |
isCompilationUnitOnDisk | public static boolean isCompilationUnitOnDisk(String loc)(Code) | | |
isValidJavaIdent | public static boolean isValidJavaIdent(String token)(Code) | | |
logMissingTypeErrorWithHints | public static void logMissingTypeErrorWithHints(TreeLogger logger, String missingType)(Code) | | |
makeRelativeFile | public static File makeRelativeFile(File from, File to)(Code) | | Attempts to make a path relative to a particular directory.
Parameters: from - the directory from which 'to' should be relative Parameters: to - an absolute path which will be returned so that it is relative to'from' the relative path, if possible; null otherwise |
maybeDumpSource | public static String maybeDumpSource(TreeLogger logger, String location, char[] source, String optionalTypeName)(Code) | | Give the developer a chance to see the in-memory source that failed.
|
readFileAsBytes | public static byte[] readFileAsBytes(File file)(Code) | | |
readFileAsChars | public static char[] readFileAsChars(File file)(Code) | | |
readNextLine | public static String readNextLine(BufferedReader br)(Code) | | Reads the next non-empty line.
a non-empty string that has been trimmed or null if the reader isexhausted |
readURLAsBytes | public static byte[] readURLAsBytes(URL url)(Code) | | null if the file could not be read |
readURLAsChars | public static char[] readURLAsChars(URL url)(Code) | | null if the file could not be read |
recursiveDelete | public static void recursiveDelete(File file, boolean childrenOnly)(Code) | | Deletes a file or recursively deletes a directory.
Parameters: file - the file to delete, or if this is a directory, the directorythat serves as the root of a recursive deletion Parameters: childrenOnly - if true , only the children of adirectory are recursively deleted but the specified directoryitself is spared; if false , the specifieddirectory is also deleted; ignored if file is not adirectory |
removeNulls | public static T[] removeNulls(T[] a)(Code) | | |
slashify | public static String slashify(String path)(Code) | | Parameters: path - The path to slashify. The path with any directory separators replaced with '/'. |
toArray | public static T[] toArray(Class<? super T> componentType, Collection<? extends T> coll)(Code) | | Creates an array from a collection of the specified component type and
size. You can definitely downcast the result to T[] if T is the specified
component type.
Class super T> is used to allow creation of generic types, such as
Map.Entry since we can only pass in Map.Entry.class.
|
toHexString | public static String toHexString(byte[] bytes)(Code) | | Returns a string representation of the byte array as a series of
hexadecimal characters.
Parameters: bytes - byte array to convert a string representation of the byte array as a series ofhexadecimal characters |
tryCombine | public static File tryCombine(File parentMaybeIgnored, File childMaybeAbsolute)(Code) | | |
tryMakeCanonical | public static File tryMakeCanonical(File file)(Code) | | Attempts to find the canonical form of a file path.
the canonical version of the file path, if it could be computed;otherwise, the original file is returned unmodified |
writeStringAsFile | public static boolean writeStringAsFile(File file, String string)(Code) | | |
|
|