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 |
---|
ExpressionFactory.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)
Gets the value of the key
key from the object's child. |
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)
Function associated to the numeric "/" operator.
|
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)
Function associated to the logical ">=" operator.
|
static boolean |
greater(float a,
float b)
Function associated to the logical ">" operator.
|
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)
Function associated to the logical "<=" operator.
|
static boolean |
less(float a,
float b)
Function associated to the logical "<" operator.
|
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)
Function associated to the numeric "-" operator.
|
static boolean |
not(boolean b)
Function associated to the logical "!" operator.
|
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)
Function associated to the numeric "+" operator.
|
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)
Creates a color value with the specified amounts of
r ed, g reen, b lue, alpha (arguments from 0.0 to 1.0) |
static java.lang.String |
role(Environment env)
Returns the role of current object in parent relation, or role of child if current object is a relation.
|
static java.lang.Object |
setting(Environment env,
java.lang.String key)
Get value of a setting.
|
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)
Function associated to the numeric "*" operator.
|
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 ExpressionFactory.Functions()
public static java.lang.Object eval(java.lang.Object o)
o
- any objecto
unchangedpublic static float plus(float... args)
args
- argumentspublic static java.lang.Float minus(float... args)
args
- argumentspublic static float times(float... args)
args
- argumentspublic static java.lang.Float divided_by(float... args)
args
- argumentspublic static java.util.List<java.lang.Object> list(java.lang.Object... args)
dashes
property.args
- The values to put in a listArrays.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.args
- argumentspublic static java.lang.Object any(java.lang.Object... args)
args
- argumentscoalesce(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).lst
- listn
- indexn
th element of the list, or null
if index out of rangepublic 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.sep
- separator stringtoSplit
- string to splitString.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)r
- the red componentg
- the green componentb
- the blue componentColor.Color(float, float, float)
public static java.awt.Color rgba(float r, float g, float b, float alpha)
r
ed, g
reen, b
lue, alpha
(arguments from 0.0 to 1.0)r
- the red componentg
- the green componentb
- the blue componentalpha
- the alpha componentColor.Color(float, float, float, float)
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
.html
- HTML notationpublic static java.lang.String color2html(java.awt.Color c)
#rrggbb
) for a color value).c
- colorpublic static float red(java.awt.Color c)
c
- colorColor.getRed()
public static float green(java.awt.Color c)
c
- colorColor.getGreen()
public static float blue(java.awt.Color c)
c
- colorColor.getBlue()
public static float alpha(java.awt.Color c)
c
- colorColor.getAlpha()
public static java.lang.String concat(java.lang.Object... args)
args
- argumentsUtils.join(java.lang.String, java.util.Collection<?>)
public static java.lang.String join(java.lang.String... args)
args
- arguments. First one is used as separatorUtils.join(java.lang.String, java.util.Collection<?>)
public static java.lang.Object prop(Environment env, java.lang.String key)
key
, e.g., prop("width")
.env
- the environmentkey
- the property keypublic static java.lang.Object prop(Environment env, java.lang.String key, java.lang.String layer)
key
from layer layer
.env
- the environmentkey
- the property keypublic static java.lang.Boolean is_prop_set(Environment env, java.lang.String key)
key
is set.env
- the environmentkey
- the property keytrue
if the property is set, false
otherwisepublic static java.lang.Boolean is_prop_set(Environment env, java.lang.String key, java.lang.String layer)
key
is set on layer layer
.env
- the environmentkey
- the property keytrue
if the property is set, false
otherwisepublic static java.lang.String tag(Environment env, java.lang.String key)
key
from the object in question.env
- the environmentkey
- the OSM keypublic static java.lang.String parent_tag(Environment env, java.lang.String key)
key
from the object's parent(s).env
- the environmentkey
- the OSM keykey
from the object's parent(s)public static java.lang.String child_tag(Environment env, java.lang.String key)
key
from the object's child.env
- the environmentkey
- the OSM keykey
from the object's child, or null
if there is no childpublic static boolean has_tag_key(Environment env, java.lang.String key)
env
- the environmentkey
- the OSM keytrue
if the object has a tag with the given key, false
otherwisepublic static java.lang.Float index(Environment env)
env
- the environmentpublic static java.lang.String role(Environment env)
env
- the environmentEnvironment.getRole()
public static boolean not(boolean b)
b
- boolean valuetrue
if !b
public static boolean greater_equal(float a, float b)
a
- first valueb
- second valuetrue
if a >= b
public static boolean less_equal(float a, float b)
a
- first valueb
- second valuetrue
if a <= b
public static boolean greater(float a, float b)
a
- first valueb
- second valuetrue
if a > b
public static boolean less(float a, float b)
a
- first valueb
- second valuetrue
if a < b
public static boolean equal(java.lang.Object a, java.lang.Object b)
a
and b
are equal.a
- First objectb
- Second objecttrue
if objects are equal, false
otherwiseObject.equals(Object)
public static java.lang.Boolean JOSM_search(Environment env, java.lang.String searchStr)
searchStr
applies to the object.env
- the environmentsearchStr
- the search stringtrue
if the JOSM search with searchStr
applies to the objectSearchCompiler
public static java.lang.String JOSM_pref(java.lang.String key, java.lang.String def)
key
- Key in JOSM preferencedef
- Default valuePreferences.get(String, String)
public static boolean regexp_test(java.lang.String pattern, java.lang.String target)
target
matches pattern pattern
pattern
- The regex expressiontarget
- The character sequence to be matchedtrue
if, and only if, the entire region sequence matches the patternPattern.matches(String, CharSequence)
public static boolean regexp_test(java.lang.String pattern, java.lang.String target, java.lang.String flags)
target
matches pattern pattern
pattern
- The regex expressiontarget
- The character sequence to be matchedflags
- a string that may contain "i" (case insensitive), "m" (multiline) and "s" ("dot all")true
if, and only if, the entire region sequence matches the patternPattern.CASE_INSENSITIVE
,
Pattern.DOTALL
,
Pattern.MULTILINE
public static java.util.List<java.lang.String> regexp_match(java.lang.String pattern, java.lang.String target, java.lang.String flags)
pattern
- The regex expressiontarget
- The character sequence to be matchedflags
- a string that may contain "i" (case insensitive), "m" (multiline) and "s" ("dot all")Matcher.matches()
, or null
.Pattern.CASE_INSENSITIVE
,
Pattern.DOTALL
,
Pattern.MULTILINE
public static java.util.List<java.lang.String> regexp_match(java.lang.String pattern, java.lang.String target)
pattern
- The regex expressiontarget
- The character sequence to be matchedMatcher.matches()
, or null
.public static long osm_id(Environment env)
env
- the environmentAbstractPrimitive.getUniqueId()
public static java.lang.String tr(java.lang.String... args)
{0}
, {1}
, …args
- argumentspublic 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
.s
- The source stringtarget
- The sequence of char values to be replacedreplacement
- The replacement sequence of char valuesString.replace(CharSequence, CharSequence)
public static java.lang.String URL_encode(java.lang.String s)
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
- the environmentpublic static java.lang.Object setting(Environment env, java.lang.String key)
env
- the environmentkey
- setting key (given as layer identifier, e.g. setting::mykey {...})