|
||||||||||
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(File source,
File destination)
Deprecated. since 3.1 this method is not used by Cayenne |
|
static boolean |
copy(URL from,
File to)
Deprecated. since 3.1 this method is not used by Cayenne. |
|
static void |
copyPipe(InputStream in,
OutputStream out,
int bufSizeHint)
Deprecated. since 3.1 this method is unused by Cayenne. |
|
static XMLReader |
createXmlReader()
Creates an XMLReader with default feature set. |
|
static boolean |
delete(String filePath,
boolean recursive)
Deprecated. since 3.1 this method is unused by Cayenne. |
|
static String |
encodeXmlAttribute(String string)
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,
char replaceWith)
Strips "\n", "\r\n", "\r" from the argument string, replacing them with a provided character. |
|
static String |
stripLineBreaks(String string,
String replaceWith)
Deprecated. since 3.1 in favor of stripLineBreaks(String, char) . |
|
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 File |
toFile(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 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 File toFile(URL url) throws IllegalArgumentException
IllegalArgumentException
if the URL is not a
"file://" URL.
IllegalArgumentException
public static String stringFromFile(File file) throws IOException
IOException
public static String stringFromFile(File file, String joinWith) throws IOException
IOException
@Deprecated public static boolean copy(File source, File destination)
@Deprecated public static boolean copy(URL from, File to)
@Deprecated public static void copyPipe(InputStream in, OutputStream out, int bufSizeHint) throws IOException
IOException
@Deprecated 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 <T extends Serializable> T cloneViaSerialization(T object) 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)
@Deprecated public static String stripLineBreaks(String string, String replaceWith)
stripLineBreaks(String, char)
.
public static String stripLineBreaks(String string, char replaceWith)
public static String encodeXmlAttribute(String string)
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 |