|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.util.Util
public class Util
Contains various unorganized static utility methods used across Cayenne.
Constructor Summary | |
---|---|
Util()
|
Method Summary | ||
---|---|---|
static Object |
cloneViaSerialization(Serializable obj)
Creates Serializable object copy using serialization/deserialization. |
|
static boolean |
copy(File source,
File destination)
Copies file contents from source to destination. |
|
static boolean |
copy(URL from,
File to)
Save URL contents to a file. |
|
static void |
copyPipe(InputStream in,
OutputStream out,
int bufSizeHint)
Reads data from the input and writes it to the output, until the end of the input stream. |
|
static XMLReader |
createXmlReader()
Creates an XMLReader with default feature set. |
|
static boolean |
delete(String filePath,
boolean recursive)
Deletes a file or directory, allowing recursive directory deletion. |
|
static String |
encodeXmlAttribute(String str)
Encodes a string so that it can be used as an attribute value in an XML document. |
|
static String |
extractFileExtension(String fileName)
Extracts extension from the file name. |
|
static Class<?> |
getJavaClass(String className)
Creates a Java class, handling regular class names as well as single-dimensional arrays and primitive types. |
|
static String |
getPackagePath(String className)
Returns package name for the Java class as a path separated with forward slash ("/"). |
|
static int |
hashCode(Collection<?> c)
Builds a hashCode of Collection. |
|
static boolean |
isAccessible(Member member)
Returns true if a Member is accessible via reflection under normal Java access controls. |
|
static boolean |
isEmptyString(String string)
Returns true, if the String is null or an empty string. |
|
static
|
nullSafeCompare(boolean nullsFirst,
Comparable<T> o1,
T o2)
Compares two objects similar to "Comparable.compareTo(Object)". |
|
static boolean |
nullSafeEquals(Object o1,
Object o2)
Compares two objects similar to "Object.equals(Object)". |
|
static String |
prettyTrim(String str,
int maxLength)
Trims long strings substituting middle part with "...". |
|
static
|
sortedIterator(Iterator<T> it,
Comparator<T> comparator)
Returns a sorted iterator from an unsorted one. |
|
static Pattern |
sqlPatternToPattern(String pattern,
boolean ignoreCase)
|
|
static String |
stringFromFile(File file)
Reads file contents, returning it as a String, using System default line separator. |
|
static String |
stringFromFile(File file,
String joinWith)
Reads file contents, returning it as a String, joining lines with provided separator. |
|
static String |
stripFileExtension(String fileName)
Strips extension from the file name. |
|
static String |
stripLineBreaks(String string,
String replaceWith)
Strips "\n", "\r\n", "\r" from the argument string. |
|
static String |
stripPackageName(String className)
Returns an unqualified class name for the fully qualified name. |
|
static String |
substBackslashes(String string)
Replaces all backslashes "\" with forward slashes "/". |
|
static
|
toMap(K[] keys,
V[] values)
Creates a mutable map out of two arrays with keys and values. |
|
static Throwable |
unwindException(Throwable th)
Looks up and returns the root cause of an exception. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static String stringFromFile(File file) throws IOException
IOException
public static String stringFromFile(File file, String joinWith) throws IOException
IOException
public static boolean copy(File source, File destination)
public static boolean copy(URL from, File to)
public static void copyPipe(InputStream in, OutputStream out, int bufSizeHint) throws IOException
in
- out
- bufSizeHint
-
IOException
public static boolean delete(String filePath, boolean recursive)
public static String substBackslashes(String string)
public static Throwable unwindException(Throwable th)
public static boolean nullSafeEquals(Object o1, Object o2)
public static <T> int nullSafeCompare(boolean nullsFirst, Comparable<T> o1, T o2)
public static boolean isEmptyString(String string)
public static Object cloneViaSerialization(Serializable obj) throws Exception
Exception
public static XMLReader createXmlReader() throws SAXException, ParserConfigurationException
SAXException
ParserConfigurationException
public static String getPackagePath(String className)
public static String stripPackageName(String className)
public static <K,V> Map<K,V> toMap(K[] keys, V[] values)
public static String extractFileExtension(String fileName)
public static String stripFileExtension(String fileName)
public static String stripLineBreaks(String string, String replaceWith)
public static String encodeXmlAttribute(String str)
public static String prettyTrim(String str, int maxLength)
str
- String to trim.maxLength
- maximum allowable length. Must be at least 5, or an
IllegalArgumentException is thrown.
public static <T> Iterator<T> sortedIterator(Iterator<T> it, Comparator<T> comparator)
public static int hashCode(Collection<?> c)
public static Pattern sqlPatternToPattern(String pattern, boolean ignoreCase)
public static boolean isAccessible(Member member)
public static Class<?> getJavaClass(String className) throws ClassNotFoundException
ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |