Package edu.umd.cs.findbugs.util
Class Util
- java.lang.Object
-
- edu.umd.cs.findbugs.util.Util
-
public class Util extends java.lang.Object- Author:
- William Pugh
-
-
Field Summary
Fields Modifier and Type Field Description static booleanLOGGING
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseSilently(java.io.InputStream in)static voidcloseSilently(java.io.OutputStream out)static voidcloseSilently(java.io.Reader in)static voidcloseSilently(java.sql.Connection c)static java.lang.StringcommonPrefix(java.lang.String s1, java.lang.String s2)static intcompare(int x, int y)return sign of x - ystatic intcompare(long x, long y)return sign of x - ystatic <T> java.util.Set<T>emptyOrNonnullSingleton(T t)static <E> Efirst(java.lang.Iterable<E> i)static java.lang.StringgetFileExtension(java.io.File f)static java.io.ReadergetFileReader(java.io.File filename)static java.io.ReadergetFileReader(java.lang.String filename)static java.io.WritergetFileWriter(java.lang.String filename)static java.io.ReadergetReader(java.io.InputStream in)static java.io.WritergetWriter(java.io.OutputStream out)static java.lang.StringgetXMLType(java.io.InputStream in)static <K,V>
java.util.Map<K,V>immutableMap(java.util.Map<K,V> map)static java.io.IOExceptionmakeIOException(java.lang.String msg, java.lang.Throwable cause)static <T extends java.lang.Comparable<? super T>>
intnullSafeCompareTo(T o1, T o2)static <T> booleannullSafeEquals(T o1, T o2)static intnullSafeHashcode(java.lang.Object o)static java.lang.Stringrepeat(java.lang.String s, int number)static voidrunLogAtShutdown(java.lang.Runnable r)static java.lang.Iterable<java.lang.Integer>setBitIteratable(java.util.BitSet b)static java.util.Iterator<java.lang.Integer>setBitIterator(java.util.BitSet b)static voidthrowIOException(java.lang.String msg, java.lang.Throwable cause)
-
-
-
Method Detail
-
compare
public static int compare(int x, int y)return sign of x - y- Parameters:
x-y-- Returns:
-
compare
public static int compare(long x, long y)return sign of x - y- Parameters:
x-y-- Returns:
-
setBitIteratable
public static java.lang.Iterable<java.lang.Integer> setBitIteratable(java.util.BitSet b)
-
setBitIterator
public static java.util.Iterator<java.lang.Integer> setBitIterator(java.util.BitSet b)
-
repeat
public static java.lang.String repeat(java.lang.String s, int number)
-
runLogAtShutdown
public static void runLogAtShutdown(java.lang.Runnable r)
-
emptyOrNonnullSingleton
public static <T> java.util.Set<T> emptyOrNonnullSingleton(T t)
-
immutableMap
public static <K,V> java.util.Map<K,V> immutableMap(java.util.Map<K,V> map)
-
nullSafeHashcode
public static int nullSafeHashcode(@CheckForNull java.lang.Object o)
-
nullSafeEquals
public static <T> boolean nullSafeEquals(@CheckForNull T o1, @CheckForNull T o2)
-
nullSafeCompareTo
public static <T extends java.lang.Comparable<? super T>> int nullSafeCompareTo(@CheckForNull T o1, @CheckForNull T o2)
-
getReader
public static java.io.Reader getReader(@WillCloseWhenClosed java.io.InputStream in) throws java.io.UnsupportedEncodingException- Throws:
java.io.UnsupportedEncodingException
-
getFileReader
public static java.io.Reader getFileReader(java.lang.String filename) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException- Throws:
java.io.UnsupportedEncodingExceptionjava.io.FileNotFoundException
-
getFileReader
public static java.io.Reader getFileReader(java.io.File filename) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException- Throws:
java.io.UnsupportedEncodingExceptionjava.io.FileNotFoundException
-
getWriter
public static java.io.Writer getWriter(@WillCloseWhenClosed java.io.OutputStream out) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException- Throws:
java.io.UnsupportedEncodingExceptionjava.io.FileNotFoundException
-
getFileWriter
public static java.io.Writer getFileWriter(java.lang.String filename) throws java.io.UnsupportedEncodingException, java.io.FileNotFoundException- Throws:
java.io.UnsupportedEncodingExceptionjava.io.FileNotFoundException
-
closeSilently
public static void closeSilently(@WillClose java.sql.Connection c)
-
closeSilently
public static void closeSilently(@WillClose java.io.InputStream in)
-
closeSilently
public static void closeSilently(@WillClose java.io.Reader in)
-
closeSilently
public static void closeSilently(@WillClose java.io.OutputStream out)
-
getXMLType
public static java.lang.String getXMLType(@WillNotClose java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
makeIOException
public static java.io.IOException makeIOException(java.lang.String msg, java.lang.Throwable cause)
-
getFileExtension
public static java.lang.String getFileExtension(java.io.File f)
-
throwIOException
public static void throwIOException(java.lang.String msg, java.lang.Throwable cause) throws java.io.IOException- Throws:
java.io.IOException
-
first
public static <E> E first(java.lang.Iterable<E> i)
- Parameters:
i- the Iterable whose first element is to be retrieved- Returns:
- first element of iterable
-
commonPrefix
public static java.lang.String commonPrefix(java.lang.String s1, java.lang.String s2)
-
-