public class Util extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static <T extends Serializable> |
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 String |
join(List<String> strings,
String separator) |
static <T> int |
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 <T> Iterator<T> |
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 <K,V> Map<K,V> |
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.
|
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
public static String join(List<String> strings, String separator)
strings
- The list of strings to join.separator
- The separator between the strings.@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
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
Copyright © 2001–2014 Apache Cayenne. All rights reserved.