public static class ExpressionFactory.Functions extends java.lang.Object
Environment
(if needed). This is
automatically filled in by JOSM and the user only sees the remaining
arguments.
When one of the user supplied arguments cannot be converted the
expected type or is null, the function is not called and it returns null
immediately. Add the annotation ExpressionFactory.NullableArguments
to allow
null arguments.
Every method must be static.Constructor and Description |
---|
Functions() |
Modifier and Type | Method and Description |
---|---|
static float |
alpha(java.awt.Color c)
Get the value of the alpha channel in the rgba color model
|
static java.lang.Object |
any(java.lang.Object... args)
Returns the first non-null object.
|
static float |
blue(java.awt.Color c)
Get the value of the blue color channel in the rgb color model
|
static java.lang.String |
child_tag(Environment env,
java.lang.String key) |
static java.lang.Object |
coalesce(java.lang.Object... args)
Deprecated.
Deprecated in favour of
any(Object...) from the MapCSS standard. |
static java.lang.String |
color2html(java.awt.Color c)
Computes the HTML notation (
#rrggbb ) for a color value). |
static java.lang.String |
concat(java.lang.Object... args)
Assembles the strings to one.
|
static java.lang.Integer |
count(java.util.List<?> lst)
Returns the number of elements in a list.
|
static long |
CRC32_checksum(java.lang.String s)
Calculates the CRC32 checksum from a string (based on RFC 1952).
|
static java.lang.Float |
divided_by(float... args) |
static boolean |
equal(java.lang.Object a,
java.lang.Object b)
Determines if the objects
a and b are equal. |
static java.lang.Object |
eval(java.lang.Object o)
Identity function for compatibility with MapCSS specification.
|
static java.lang.Object |
get(java.util.List<?> lst,
float n)
Get the
n th element of the list lst (counting starts at 0). |
static boolean |
greater_equal(float a,
float b) |
static boolean |
greater(float a,
float b) |
static float |
green(java.awt.Color c)
Get the value of the green color channel in the rgb color model
|
static boolean |
has_tag_key(Environment env,
java.lang.String key)
Determines whether the object has a tag with the given key.
|
static java.awt.Color |
hsb_color(float h,
float s,
float b)
Create color from hsb color model.
|
static java.awt.Color |
html2color(java.lang.String html)
Creates a color value from an HTML notation, i.e.,
#rrggbb . |
static java.lang.Float |
index(Environment env)
Returns the index of node in parent way or member in parent relation.
|
static java.lang.Boolean |
is_prop_set(Environment env,
java.lang.String key)
Determines whether property
key is set. |
static java.lang.Boolean |
is_prop_set(Environment env,
java.lang.String key,
java.lang.String layer)
Determines whether property
key is set on layer layer . |
static boolean |
is_right_hand_traffic(Environment env)
check if there is right-hand traffic at the current location
|
static java.lang.String |
join(java.lang.String... args)
Assembles the strings to one, where the first entry is used as separator.
|
static java.lang.String |
JOSM_pref(java.lang.String key,
java.lang.String def)
|
static java.lang.Boolean |
JOSM_search(Environment env,
java.lang.String searchStr)
Determines whether the JOSM search with
searchStr applies to the object. |
static boolean |
less_equal(float a,
float b) |
static boolean |
less(float a,
float b) |
static java.util.List<java.lang.Object> |
list(java.lang.Object... args)
Creates a list of values, e.g., for the
dashes property. |
static java.lang.Float |
minus(float... args) |
static boolean |
not(boolean b) |
static int |
number_of_tags(Environment env)
Get the number of tags for the current primitive.
|
static long |
osm_id(Environment env)
Returns the OSM id of the current object.
|
static java.lang.String |
parent_tag(Environment env,
java.lang.String key)
Gets the first non-null value of the key
key from the object's parent(s). |
static float |
plus(float... args) |
static java.lang.Object |
print(java.lang.Object o)
Prints the object to the command line (for debugging purpose).
|
static java.lang.Object |
println(java.lang.Object o)
Prints the object to the command line, with new line at the end
(for debugging purpose).
|
static java.lang.Object |
prop(Environment env,
java.lang.String key)
Returns the value of the property
key , e.g., prop("width") . |
static java.lang.Object |
prop(Environment env,
java.lang.String key,
java.lang.String layer)
Returns the value of the property
key from layer layer . |
static float |
red(java.awt.Color c)
Get the value of the red color channel in the rgb color model
|
static java.util.List<java.lang.String> |
regexp_match(java.lang.String pattern,
java.lang.String target)
Tries to match string against pattern regexp and returns a list of capture groups in case of success.
|
static java.util.List<java.lang.String> |
regexp_match(java.lang.String pattern,
java.lang.String target,
java.lang.String flags)
Tries to match string against pattern regexp and returns a list of capture groups in case of success.
|
static boolean |
regexp_test(java.lang.String pattern,
java.lang.String target)
Tests if string
target matches pattern pattern |
static boolean |
regexp_test(java.lang.String pattern,
java.lang.String target,
java.lang.String flags)
Tests if string
target matches pattern pattern |
static java.lang.String |
replace(java.lang.String s,
java.lang.String target,
java.lang.String replacement)
Replaces in
s every target} substring by replacement . |
static java.awt.Color |
rgb(float r,
float g,
float b)
Creates a color value with the specified amounts of
r ed, g reen, b lue (arguments from 0.0 to 1.0) |
static java.awt.Color |
rgba(float r,
float g,
float b,
float alpha) |
static java.lang.String |
role(Environment env) |
static java.util.List<java.lang.String> |
split(java.lang.String sep,
java.lang.String toSplit)
Splits string
toSplit at occurrences of the separator string sep and returns a list of matches. |
static java.lang.String |
substring(java.lang.String s,
float begin)
Returns the substring of
s starting at index begin (inclusive, 0-indexed). |
static java.lang.String |
substring(java.lang.String s,
float begin,
float end)
Returns the substring of
s starting at index begin (inclusive)
and ending at index end , (exclusive, 0-indexed). |
static java.lang.String |
tag(Environment env,
java.lang.String key)
Gets the value of the key
key from the object in question. |
static float |
times(float... args) |
static java.lang.String |
tr(java.lang.String... args)
Translates some text for the current locale.
|
static java.lang.String |
URL_encode(java.lang.String s)
Percent-encode a string.
|
static java.lang.String |
XML_encode(java.lang.String s)
XML-encode a string.
|
public Functions()
public static java.lang.Object eval(java.lang.Object o)
o
- any objecto
unchangedpublic static float plus(float... args)
public static java.lang.Float minus(float... args)
public static float times(float... args)
public static java.lang.Float divided_by(float... args)
public static java.util.List<java.lang.Object> list(java.lang.Object... args)
dashes
property.Arrays.asList(Object[])
public static java.lang.Integer count(java.util.List<?> lst)
lst
- the list@Deprecated public static java.lang.Object coalesce(java.lang.Object... args)
any(Object...)
from the MapCSS standard.COALESCE
SQL function.public static java.lang.Object any(java.lang.Object... args)
coalesce(Object...)
,
Utils.firstNonNull(Object[])
public static java.lang.Object get(java.util.List<?> lst, float n)
n
th element of the list lst
(counting starts at 0).public static java.util.List<java.lang.String> split(java.lang.String sep, java.lang.String toSplit)
toSplit
at occurrences of the separator string sep
and returns a list of matches.String.split(String)
public static java.awt.Color rgb(float r, float g, float b)
r
ed, g
reen, b
lue (arguments from 0.0 to 1.0)Color.Color(float, float, float)
public static java.awt.Color rgba(float r, float g, float b, float alpha)
public static java.awt.Color hsb_color(float h, float s, float b)
h
- hues
- saturationb
- brightnesspublic static java.awt.Color html2color(java.lang.String html)
#rrggbb
.public static java.lang.String color2html(java.awt.Color c)
#rrggbb
) for a color value).public static float red(java.awt.Color c)
Color.getRed()
public static float green(java.awt.Color c)
Color.getGreen()
public static float blue(java.awt.Color c)
Color.getBlue()
public static float alpha(java.awt.Color c)
Color.getAlpha()
public static java.lang.String concat(java.lang.Object... args)
public static java.lang.String join(java.lang.String... args)
public static java.lang.Object prop(Environment env, java.lang.String key)
key
, e.g., prop("width")
.public static java.lang.Object prop(Environment env, java.lang.String key, java.lang.String layer)
key
from layer layer
.public static java.lang.Boolean is_prop_set(Environment env, java.lang.String key)
key
is set.public static java.lang.Boolean is_prop_set(Environment env, java.lang.String key, java.lang.String layer)
key
is set on layer layer
.public static java.lang.String tag(Environment env, java.lang.String key)
key
from the object in question.public static java.lang.String parent_tag(Environment env, java.lang.String key)
key
from the object's parent(s).public static java.lang.String child_tag(Environment env, java.lang.String key)
public static boolean has_tag_key(Environment env, java.lang.String key)
public static java.lang.Float index(Environment env)
public static java.lang.String role(Environment env)
public static boolean not(boolean b)
public static boolean greater_equal(float a, float b)
public static boolean less_equal(float a, float b)
public static boolean greater(float a, float b)
public static boolean less(float a, float b)
public static boolean equal(java.lang.Object a, java.lang.Object b)
a
and b
are equal.Object.equals(Object)
public static java.lang.Boolean JOSM_search(Environment env, java.lang.String searchStr)
searchStr
applies to the object.public static java.lang.String JOSM_pref(java.lang.String key, java.lang.String def)
Preferences.get(String, String)
public static boolean regexp_test(java.lang.String pattern, java.lang.String target)
target
matches pattern pattern
Pattern.matches(String, CharSequence)
public static boolean regexp_test(java.lang.String pattern, java.lang.String target, java.lang.String flags)
target
matches pattern pattern
flags
- a string that may contain "i" (case insensitive), "m" (multiline) and "s" ("dot all")public static java.util.List<java.lang.String> regexp_match(java.lang.String pattern, java.lang.String target, java.lang.String flags)
flags
- a string that may contain "i" (case insensitive), "m" (multiline) and "s" ("dot all")public static java.util.List<java.lang.String> regexp_match(java.lang.String pattern, java.lang.String target)
public static long osm_id(Environment env)
AbstractPrimitive.getUniqueId()
public static java.lang.String tr(java.lang.String... args)
{0}
, {1}
, …public static java.lang.String substring(java.lang.String s, float begin)
s
starting at index begin
(inclusive, 0-indexed).s
- The base stringbegin
- The start indexString.substring(int)
public static java.lang.String substring(java.lang.String s, float begin, float end)
s
starting at index begin
(inclusive)
and ending at index end
, (exclusive, 0-indexed).s
- The base stringbegin
- The start indexend
- The end indexString.substring(int, int)
public static java.lang.String replace(java.lang.String s, java.lang.String target, java.lang.String replacement)
s
every target} substring by replacement
.
* @see String#replace(CharSequence, CharSequence)public static java.lang.String URL_encode(java.lang.String s)
icon-image: concat("data:image/svg+xml,", URL_encode("<svg>...</svg>"));
s
- arbitrary stringpublic static java.lang.String XML_encode(java.lang.String s)
s
- arbitrary stringpublic static long CRC32_checksum(java.lang.String s)
s
- the stringpublic static boolean is_right_hand_traffic(Environment env)
env
- the environmentpublic static java.lang.Object print(java.lang.Object o)
o
- the objectpublic static java.lang.Object println(java.lang.Object o)
o
- the objectpublic static int number_of_tags(Environment env)
env
-