|
||||||||||
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
|
cloneViaSerialization(T object)
Creates Serializable object copy using serialization/deserialization. |
|
static boolean |
copy(java.io.File source,
java.io.File destination)
Deprecated. since 3.1 this method is not used by Cayenne |
|
static boolean |
copy(java.net.URL from,
java.io.File to)
Deprecated. since 3.1 this method is not used by Cayenne. |
|
static void |
copyPipe(java.io.InputStream in,
java.io.OutputStream out,
int bufSizeHint)
Deprecated. since 3.1 this method is unused by Cayenne. |
|
static org.xml.sax.XMLReader |
createXmlReader()
Creates an XMLReader with default feature set. |
|
static boolean |
delete(java.lang.String filePath,
boolean recursive)
Deprecated. since 3.1 this method is unused by Cayenne. |
|
static java.lang.String |
encodeXmlAttribute(java.lang.String string)
Encodes a string so that it can be used as an attribute value in an XML document. |
|
static java.lang.String |
extractFileExtension(java.lang.String fileName)
Extracts extension from the file name. |
|
static java.lang.Class<?> |
getJavaClass(java.lang.String className)
Creates a Java class, handling regular class names as well as single-dimensional arrays and primitive types. |
|
static java.lang.String |
getPackagePath(java.lang.String className)
Returns package name for the Java class as a path separated with forward slash ("/"). |
|
static int |
hashCode(java.util.Collection<?> c)
Builds a hashCode of Collection. |
|
static boolean |
isAccessible(java.lang.reflect.Member member)
Returns true if a Member is accessible via reflection under normal Java access controls. |
|
static boolean |
isEmptyString(java.lang.String string)
Returns true, if the String is null or an empty string. |
|
static
|
nullSafeCompare(boolean nullsFirst,
java.lang.Comparable<T> o1,
T o2)
Compares two objects similar to "Comparable.compareTo(Object)". |
|
static boolean |
nullSafeEquals(java.lang.Object o1,
java.lang.Object o2)
Compares two objects similar to "Object.equals(Object)". |
|
static java.lang.String |
prettyTrim(java.lang.String str,
int maxLength)
Trims long strings substituting middle part with "...". |
|
static
|
sortedIterator(java.util.Iterator<T> it,
java.util.Comparator<T> comparator)
Returns a sorted iterator from an unsorted one. |
|
static java.util.regex.Pattern |
sqlPatternToPattern(java.lang.String pattern,
boolean ignoreCase)
|
|
static java.lang.String |
stringFromFile(java.io.File file)
Reads file contents, returning it as a String, using System default line separator. |
|
static java.lang.String |
stringFromFile(java.io.File file,
java.lang.String joinWith)
Reads file contents, returning it as a String, joining lines with provided separator. |
|
static java.lang.String |
stripFileExtension(java.lang.String fileName)
Strips extension from the file name. |
|
static java.lang.String |
stripLineBreaks(java.lang.String string,
char replaceWith)
Strips "\n", "\r\n", "\r" from the argument string, replacing them with a provided character. |
|
static java.lang.String |
stripLineBreaks(java.lang.String string,
java.lang.String replaceWith)
Deprecated. since 3.1 in favor of stripLineBreaks(String, char) . |
|
static java.lang.String |
stripPackageName(java.lang.String className)
Returns an unqualified class name for the fully qualified name. |
|
static java.lang.String |
substBackslashes(java.lang.String string)
Replaces all backslashes "\" with forward slashes "/". |
|
static java.io.File |
toFile(java.net.URL url)
Converts URL to file. |
|
static
|
toMap(K[] keys,
V[] values)
Creates a mutable map out of two arrays with keys and values. |
|
static java.lang.Throwable |
unwindException(java.lang.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 java.io.File toFile(java.net.URL url) throws java.lang.IllegalArgumentException
IllegalArgumentException
if the URL is not a
"file://" URL.
java.lang.IllegalArgumentException
public static java.lang.String stringFromFile(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.lang.String stringFromFile(java.io.File file, java.lang.String joinWith) throws java.io.IOException
java.io.IOException
public static boolean copy(java.io.File source, java.io.File destination)
public static boolean copy(java.net.URL from, java.io.File to)
public static void copyPipe(java.io.InputStream in, java.io.OutputStream out, int bufSizeHint) throws java.io.IOException
java.io.IOException
public static boolean delete(java.lang.String filePath, boolean recursive)
public static java.lang.String substBackslashes(java.lang.String string)
public static java.lang.Throwable unwindException(java.lang.Throwable th)
public static boolean nullSafeEquals(java.lang.Object o1, java.lang.Object o2)
public static <T> int nullSafeCompare(boolean nullsFirst, java.lang.Comparable<T> o1, T o2)
public static boolean isEmptyString(java.lang.String string)
public static <T extends java.io.Serializable> T cloneViaSerialization(T object) throws java.lang.Exception
java.lang.Exception
public static org.xml.sax.XMLReader createXmlReader() throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public static java.lang.String getPackagePath(java.lang.String className)
public static java.lang.String stripPackageName(java.lang.String className)
public static <K,V> java.util.Map<K,V> toMap(K[] keys, V[] values)
public static java.lang.String extractFileExtension(java.lang.String fileName)
public static java.lang.String stripFileExtension(java.lang.String fileName)
@Deprecated public static java.lang.String stripLineBreaks(java.lang.String string, java.lang.String replaceWith)
stripLineBreaks(String, char)
.
public static java.lang.String stripLineBreaks(java.lang.String string, char replaceWith)
public static java.lang.String encodeXmlAttribute(java.lang.String string)
public static java.lang.String prettyTrim(java.lang.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> java.util.Iterator<T> sortedIterator(java.util.Iterator<T> it, java.util.Comparator<T> comparator)
public static int hashCode(java.util.Collection<?> c)
public static java.util.regex.Pattern sqlPatternToPattern(java.lang.String pattern, boolean ignoreCase)
public static boolean isAccessible(java.lang.reflect.Member member)
public static java.lang.Class<?> getJavaClass(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |