replace value by range()

This function searches properties file b for the key a and returns its value.

The keys are interpreted as two values separated by a slash defining a from/to range. If a is within that range (including the boundaries), the search is considered successful. If nothing is found, the default value c will be returned.

The type of the comparison is controlled in parameter d. The following values can be specified.


Compare type

Meaning

withcase

The comparison will be lexical and case-sensitive. a is therefore greater than A (Unicode value).

nocase

The comparison will be lexical and case-insensitive. a is therefore equal to A.

numeric

The comparison will be numeric, i.e. only numbers will be compared. 10 is therefore greater than 2. Note: Non-numeric values are interpreted as 0.

Important note: The order the comparison will take place is coincidental, i.e. the ranges should not overlap.

Parameters


Parameter

Description

a

Key to be searched for in b.

b

Name of the properties file.

c

Default value if the key is not found.

d

(optional) Type of comparison. Default: withcase.


Examples


Note: Please note, in general, with regard to escape characters, the structure of a properties file.


The following properties files are defined.

./conf/withalpha.properties
aaaa/zzzz=lower alpha
AAAA/ZZZZ=upper alpha
0/9=below ten

./conf/noalpha.properties
AAAA/ZZZZ=alphas
0/9=below ten

./conf/numbers.properties
0/9=below ten


Parameter a

Parameter b

Parameter c

Parameter d

Result

aaaa

./conf/withalpha.properties

unknown


lower alpha

abcd

./conf/withalpha.properties

unknown


lower alpha

zzzz

./conf/withalpha.properties

unknown


lower alpha

ABCD

./conf/withalpha.properties

unknown


upper alpha

AbCd

./conf/withalpha.properties

unknown


upper alpha

10

./conf/withalpha.properties

unknown


below ten

$

./conf/withalpha.properties

unknown


unknown

abcd

./conf/noalpha.properties

unknown

nocase

alphas

ABCD

./conf/noalpha.properties

unknown

nocase

alphas

AbCd

./conf/noalpha.properties

unknown

nocase

alphas

10

./conf/noalpha.properties

unknown

nocase

below ten

0

./conf/numbers.properties

unknown

numeric

below ten

9

./conf/numbers.properties

unknown

numeric

below ten

10

./conf/numbers.properties

unknown

numeric

unknown