Modifier and Type | Field and Description |
---|---|
private static Pattern |
blankPattern |
private static int |
DOLLAR
.
|
private static Iterator |
EMPTY_ITERATOR
.
|
private static int |
ESCAPE
.
|
private static int |
EVALUATING
.
|
private static Pattern |
FOO |
private static Pattern |
p
.
|
private static int |
SCANNING
.
|
static Charset |
UTF_8
.
|
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static List<String> |
chunks(CharSequence s) |
static Exception |
close(Closeable closeable)
Close the closeable and catch any exception thrown.
|
static Exception |
close(Connection connection)
Close the connection and catch any exception thrown.
|
static Exception |
close(Context context)
Close the context and catch any exception thrown.
|
static Exception |
close(ResultSet rs)
Close the result set and catch any exception thrown.
|
static Exception |
close(Socket socket)
<<<<<<< HEAD
Close the socket and catch any exception thrown.
|
static Exception |
close(Statement statement)
Close the statement and catch any exception thrown.
|
static void |
copy(InputStream in,
OutputStream out) |
static boolean |
equals(Object o1,
Object o2) |
static String |
findLongestCommonPrefix(CharSequence... seqs) |
static String |
findLongestCommonPrefix(Iterable<? extends CharSequence> seqs)
Find the longest possible common prefix of the provided char sequence.
|
static <E> E |
first(Iterable<E> elements) |
static Exception |
flush(Flushable flushable)
Flush the flushable and catch any exception thrown.
|
private static String[] |
foo(CharSequence s,
char separator,
int count,
int from,
int rightPadding) |
static File |
getCurrentDirectory() |
static String |
globexToRegex(String globex)
Create a pattern that transforms a glob expression into a regular expression, the following task are supported
* : Match any number of unknown characters
? : Match one unknown character
[characters] : Match a character as part of a group of characters
\ : Escape character
|
static int |
indexOf(CharSequence s,
int off,
char c) |
static boolean |
instanceOf(Class c,
List<String> types) |
static boolean |
instanceOf(Class c,
String type) |
static String |
interpolate(String interpolated,
Map<?,?> context)
Interpolate a string and replace the occurence from a context map, the syntax for a variable
is
${} and it can accept a default value used when the variable cannot be resolved
with the :- separator:
{} + "foo" => "foo"
{} + "${foo}" => ""
{} + "\\${foo}" => "${foo}"
{foo:bar} + "${foo}" => "bar"
{} + "${foo:-bar}" => "bar"
|
static <E> Iterator<E> |
iterator() |
static <E> Iterator<E> |
iterator(E element) |
static String |
join(Iterable<String> strings,
String separator) |
static <E> List<E> |
list(E... elements) |
static <E> List<E> |
list(Iterable<E> iterable) |
static <E> List<E> |
list(Iterator<E> iterator) |
static <K,V> HashMap<K,V> |
map(K key,
V value) |
static <K,V,M extends Map<K,V>> |
map(M map,
K key,
V value) |
static boolean |
notBlank(String s) |
static boolean |
notEquals(Object o1,
Object o2) |
static int |
notNegative(int value)
Return the value when it is positive otherwise return 0.
|
static <E> E |
notNull(E e1,
E e2) |
private static ByteArrayOutputStream |
read(InputStream in) |
static byte[] |
readAsBytes(InputStream in) |
static String |
readAsUTF8(InputStream in) |
static Type |
resolve(Type implementation,
Class<?> type,
int parameterIndex)
A simplistic implementation, it may not handle all cases but it should handle enough.
|
static Class |
resolveToClass(Type type) |
static Class<?> |
resolveToClass(Type implementation,
Class<?> type,
int parameterIndex) |
static <T extends Throwable> |
rethrow(Class<T> throwableClass,
Throwable cause) |
static <E> HashSet<E> |
set(E... elements) |
static String[] |
split(CharSequence s,
char separator) |
static String[] |
split(CharSequence s,
char separator,
int rightPadding) |
static File |
toFile(URL url) |
static String |
trimLeft(String s) |
private static final Iterator EMPTY_ITERATOR
private static final Pattern blankPattern
private static final int ESCAPE
private static final int SCANNING
private static final int DOLLAR
private static final int EVALUATING
public Utils()
public static int indexOf(CharSequence s, int off, char c)
public static <E> E notNull(E e1, E e2)
public static int notNegative(int value)
value
- the valuepublic static String globexToRegex(String globex) throws NullPointerException
globex
- the glob expressionNullPointerException
- when the globex argument is nullpublic static Exception close(Socket socket)
socket
- the socket to closeclose
operationpublic static Exception close(Closeable closeable)
closeable
- the closeable to closeclose
operationpublic static Exception close(Connection connection)
connection
- the socket to closeclose
operationpublic static Exception close(Statement statement)
statement
- the statement to closeclose
operationpublic static Exception close(ResultSet rs)
rs
- the result set to closeclose
operationpublic static Exception close(Context context)
context
- the context to closeclose
operationpublic static <T extends Throwable> void rethrow(Class<T> throwableClass, Throwable cause) throws T extends Throwable
T extends Throwable
public static Exception flush(Flushable flushable)
flushable
- the flushable to flushflush
operationpublic static List<String> chunks(CharSequence s)
public static String[] split(CharSequence s, char separator)
public static String[] split(CharSequence s, char separator, int rightPadding)
private static String[] foo(CharSequence s, char separator, int count, int from, int rightPadding)
public static String findLongestCommonPrefix(CharSequence... seqs)
findLongestCommonPrefix(Iterable)
public static String findLongestCommonPrefix(Iterable<? extends CharSequence> seqs)
seqs
- the sequencespublic static byte[] readAsBytes(InputStream in) throws IOException
IOException
public static String readAsUTF8(InputStream in)
public static void copy(InputStream in, OutputStream out) throws IOException
IOException
private static ByteArrayOutputStream read(InputStream in) throws IOException
IOException
public static File toFile(URL url) throws IllegalArgumentException, NullPointerException
public static Class<?> resolveToClass(Type implementation, Class<?> type, int parameterIndex)
public static Class resolveToClass(Type type)
public static Type resolve(Type implementation, Class<?> type, int parameterIndex)
implementation
- the type for which the parameter requires a resolutiontype
- the type that owns the parameterparameterIndex
- the parameter indexpublic static boolean instanceOf(Class c, List<String> types)
public static boolean instanceOf(Class c, String type)
public static String interpolate(String interpolated, Map<?,?> context) throws NullPointerException
${}
and it can accept a default value used when the variable cannot be resolved
with the :-
separator:
{}
+ "foo" => "foo"{}
+ "${foo}" => ""{}
+ "\\${foo}" => "${foo}"{foo:bar}
+ "${foo}" => "bar"{}
+ "${foo:-bar}" => "bar"interpolated
- the value to interpolatecontext
- the contextNullPointerException
- if the interpolated argument is nullpublic static File getCurrentDirectory()
Copyright © 2015 eXo Platform SAS. All Rights Reserved.