|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.tools.Utils
public class Utils
Basic utils, that can be useful in different parts of the program.
Nested Class Summary | |
---|---|
static interface |
Utils.Function<A,B>
Represents a function that can be applied to objects of A and
returns objects of B . |
Field Summary | |
---|---|
private static double |
EPSILION
|
Constructor Summary | |
---|---|
Utils()
|
Method Summary | ||
---|---|---|
static void |
close(java.io.InputStream is)
Utility method for closing an input stream. |
|
static void |
close(java.io.OutputStream os)
Utility method for closing an output stream. |
|
static void |
close(java.io.Reader reader)
Utility method for closing a reader. |
|
static java.lang.Integer |
color_float2int(java.lang.Float val)
convert float range 0 <= x <= 1 to integer range 0..255 when dealing with colors and color alpha value |
|
static java.lang.Float |
color_int2float(java.lang.Integer val)
convert back |
|
static java.awt.Color |
complement(java.awt.Color clr)
|
|
static int |
copyStream(java.io.InputStream source,
java.io.OutputStream destination)
|
|
static boolean |
copyToClipboard(java.lang.String s)
Copies the string s to system clipboard. |
|
static boolean |
deleteDirectory(java.io.File path)
|
|
static void |
ensure(boolean condition,
java.lang.String message,
java.lang.Object... data)
|
|
static
|
equal(T a,
T b)
for convenience: test whether 2 objects are either both null or a.equals(b) |
|
static boolean |
equalsEpsilon(double a,
double b)
|
|
static
|
exists(java.lang.Iterable<? extends T> collection,
Predicate<? super T> predicate)
|
|
static
|
exists(java.lang.Iterable<T> collection,
java.lang.Class<? extends T> klass)
|
|
static
|
filter(java.util.Collection<? extends T> collection,
Predicate<? super T> predicate)
|
|
static
|
filteredCollection(java.util.Collection<S> collection,
java.lang.Class<T> klass)
Filter a collection by (sub)class. |
|
static
|
find(java.lang.Iterable<? extends T> collection,
Predicate<? super T> predicate)
|
|
static
|
find(java.lang.Iterable<? super T> collection,
java.lang.Class<? extends T> klass)
|
|
static
|
firstNonNull(T... items)
|
|
static java.lang.String |
getClipboardContent()
Extracts clipboard content as string. |
|
static
|
indexOf(java.lang.Iterable<? extends T> collection,
Predicate<? super T> predicate)
|
|
static java.lang.String |
join(java.lang.String sep,
java.util.Collection<?> values)
Joins a list of strings (or objects that can be converted to string via Object.toString()) into a single string with fields separated by sep. |
|
static java.lang.String |
joinAsHtmlUnorderedList(java.util.Collection<?> values)
|
|
static int |
max(int a,
int b,
int c,
int d)
|
|
static java.lang.String |
md5Hex(java.lang.String data)
Calculate MD5 hash of a string and output in hexadecimal format. |
|
static int |
min(int a,
int b,
int c)
Get minimum of 3 values |
|
static int |
mod(int a,
int n)
return the modulus in the range [0, n) |
|
static java.lang.String |
toHexString(byte[] bytes)
Converts a byte array to a string of hexadecimal characters. |
|
static
|
topologicalSort(MultiMap<T,T> dependencies)
Topological sort. |
|
static java.lang.String |
toString(java.awt.Color c)
convert Color to String (Color.toString() omits alpha value) |
|
static
|
transform(java.util.Collection<? extends A> c,
Utils.Function<A,B> f)
Transforms the collection c into an unmodifiable collection and
applies the Utils.Function f on each element upon access. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final double EPSILION
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static <T> boolean exists(java.lang.Iterable<? extends T> collection, Predicate<? super T> predicate)
public static <T> boolean exists(java.lang.Iterable<T> collection, java.lang.Class<? extends T> klass)
public static <T> T find(java.lang.Iterable<? extends T> collection, Predicate<? super T> predicate)
public static <T> T find(java.lang.Iterable<? super T> collection, java.lang.Class<? extends T> klass)
public static <T> java.util.Collection<T> filter(java.util.Collection<? extends T> collection, Predicate<? super T> predicate)
public static <T> T firstNonNull(T... items)
public static <S,T extends S> SubclassFilteredCollection<S,T> filteredCollection(java.util.Collection<S> collection, java.lang.Class<T> klass)
public static <T> int indexOf(java.lang.Iterable<? extends T> collection, Predicate<? super T> predicate)
public static int min(int a, int b, int c)
public static int max(int a, int b, int c, int d)
public static <T> boolean equal(T a, T b)
public static void ensure(boolean condition, java.lang.String message, java.lang.Object... data)
public static int mod(int a, int n)
public static java.lang.String join(java.lang.String sep, java.util.Collection<?> values)
sep
- the separatorvalues
- collection of objects, null is converted to the
empty string
public static java.lang.String joinAsHtmlUnorderedList(java.util.Collection<?> values)
public static java.lang.String toString(java.awt.Color c)
public static java.lang.Integer color_float2int(java.lang.Float val)
public static java.lang.Float color_int2float(java.lang.Integer val)
public static java.awt.Color complement(java.awt.Color clr)
public static int copyStream(java.io.InputStream source, java.io.OutputStream destination) throws java.io.IOException
java.io.IOException
public static boolean deleteDirectory(java.io.File path)
public static void close(java.io.InputStream is)
Utility method for closing an input stream.
is
- the input stream. May be null.public static void close(java.io.OutputStream os)
Utility method for closing an output stream.
os
- the output stream. May be null.public static void close(java.io.Reader reader)
Utility method for closing a reader.
reader
- the reader. May be null.public static boolean equalsEpsilon(double a, double b)
public static boolean copyToClipboard(java.lang.String s)
s
to system clipboard.
s
- string to be copied to clipboard.
public static java.lang.String getClipboardContent()
null
otherwise.public static java.lang.String md5Hex(java.lang.String data)
public static java.lang.String toHexString(byte[] bytes)
public static <T> java.util.List<T> topologicalSort(MultiMap<T,T> dependencies)
dependencies
- contains mappings (key -> value). In the final list of sorted objects, the key will come
after the value. (In other words, the key depends on the value(s).)
There must not be cyclic dependencies.
public static <A,B> java.util.Collection<B> transform(java.util.Collection<? extends A> c, Utils.Function<A,B> f)
c
into an unmodifiable collection and
applies the Utils.Function
f
on each element upon access.
A
- class of input collectionB
- class of transformed collectionc
- a collectionf
- a function that transforms objects of A
to objects of B
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |