|
|||||||||
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 java.lang.Object |
cloneViaSerialization(java.io.Serializable obj)
Creates Serializable object copy using serialization/deserialization. |
static boolean |
copy(java.io.File source,
java.io.File destination)
Copies file contents from source to destination. |
static boolean |
copy(java.net.URL from,
java.io.File to)
Save URL contents to a file. |
static void |
copyPipe(java.io.InputStream in,
java.io.OutputStream out,
int bufSizeHint)
Reads data from the input and writes it to the output, until the end of the input stream. |
static org.xml.sax.XMLReader |
createXmlReader()
Creates an XMLReader with default feature set. |
static boolean |
delete(java.lang.String filePath,
boolean recursive)
Deletes a file or directory, allowing recursive directory deletion. |
static java.lang.String |
encodeXmlAttribute(java.lang.String str)
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 int |
nullSafeCompare(boolean nullsFirst,
java.lang.Comparable o1,
java.lang.Object 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 java.util.Iterator |
sortedIterator(java.util.Iterator it,
java.util.Comparator 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 |
sqlPatternToRegex(java.lang.String pattern,
boolean ignoreCase)
Deprecated. since 1.2 use "sqlPatternToPattern". |
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,
java.lang.String replaceWith)
Strips "\n", "\r\n", "\r" from the argument string. |
static java.lang.String |
substBackslashes(java.lang.String string)
Replaces all backslashes "\" with forward slashes "/". |
static java.util.Map |
toMap(java.lang.Object[] keys,
java.lang.Object[] 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.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
in
- out
- bufSizeHint
-
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 int nullSafeCompare(boolean nullsFirst, java.lang.Comparable o1, java.lang.Object o2)
public static boolean isEmptyString(java.lang.String string)
public static java.lang.Object cloneViaSerialization(java.io.Serializable obj) 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.util.Map toMap(java.lang.Object[] keys, java.lang.Object[] values)
public static java.lang.String extractFileExtension(java.lang.String fileName)
public static java.lang.String stripFileExtension(java.lang.String fileName)
public static java.lang.String stripLineBreaks(java.lang.String string, java.lang.String replaceWith)
public static java.lang.String encodeXmlAttribute(java.lang.String str)
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 java.util.Iterator sortedIterator(java.util.Iterator it, java.util.Comparator comparator)
public static int hashCode(java.util.Collection c)
public static java.lang.String sqlPatternToRegex(java.lang.String pattern, boolean ignoreCase)
"billing_%"
will become /^billing_.*$/
"user?"
will become /^user.?$/
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 |