Top Description Inners Fields Constructors Methods
org.apache.commons.lang3.text

public abstract Class StrLookup<V>

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.lang3.text.StrLookup.MapStrLookup, org.apache.commons.lang3.text.StrLookup.SystemPropertiesStrLookup
Annotations
@Deprecated
Type Parameters
<V>
Unused.
Imports
java.util.Map, .Objects, org.apache.commons.lang3.SystemProperties

Deprecated

As of 3.6, use Apache Commons Text StringLookupFactory.

Lookup a String key to a String value.

This class represents the simplest form of a string to string map. It has a benefit over a map in that it can create the result on demand based on the key.

This class comes complete with various factory methods. If these do not suffice, you can subclass and implement your own matcher.

For example, it would be possible to implement a lookup that used the key as a primary key, and looked up the value on demand from the database.

Since
2.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
StrLookup.MapStrLookup<
the type of mapped values.
V
>

References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.
Lookup implementation that uses a Map.
private static class
StrLookup.SystemPropertiesStrLookup

References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.
Lookup implementation based on system properties.

Field Summary

Modifier and TypeField and Description
private static final StrLookup<String>
NONE_LOOKUP

References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.
Lookup that always returns null.
private static final StrLookup<String>
SYSTEM_PROPERTIES_LOOKUP

References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.
Lookup based on system properties.

Constructor Summary

AccessConstructor and Description
protected
StrLookup()

Constructs a new instance.

Method Summary

Modifier and TypeMethod and Description
public abstract String

Returns:

the matching value, null if no match.
lookup
(String
the key to be looked up, may be null.
key
)

Looks up a String key to a String value.

public static <
the type of the values supported by the lookup.
V
>
StrLookup<V>

Returns:

a lookup using the map, not null.
mapLookup
(final Map<String, V>
the map of keys to values, may be null.
map
)
References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

Returns a lookup which looks up values using a map.

public static StrLookup<?>

Returns:

a lookup that always returns null, not null.
noneLookup
()
References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

Returns a lookup which always returns null.

public static StrLookup<String>

Returns:

a lookup using system properties, not null.
systemPropertiesLookup
()
References Deprecated StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

Returns a new lookup which uses a copy of the current System properties.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NONE_LOOKUPback to summary
private static final StrLookup<String> NONE_LOOKUP

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Lookup that always returns null.

SYSTEM_PROPERTIES_LOOKUPback to summary
private static final StrLookup<String> SYSTEM_PROPERTIES_LOOKUP

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Lookup based on system properties.

Constructor Detail

StrLookupback to summary
protected StrLookup()

Constructs a new instance.

Method Detail

lookupback to summary
public abstract String lookup(String key)

Looks up a String key to a String value.

The internal implementation may use any mechanism to return the value. The simplest implementation is to use a Map. However, virtually any implementation is possible.

For example, it would be possible to implement a lookup that used the key as a primary key, and looked up the value on demand from the database Or, a numeric based implementation could be created that treats the key as an integer, increments the value and return the result as a string - converting 1 to 2, 15 to 16 etc.

The lookup(String) method always returns a String, regardless of the underlying data, by converting it as necessary. For example:

Map<String, Object> map = new HashMap<String, Object>();
map.put("number", Integer.valueOf(2));
assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
Parameters
key:String

the key to be looked up, may be null.

Returns:String

the matching value, null if no match.

mapLookupback to summary
public static <V> StrLookup<V> mapLookup(final Map<String, V> map)

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns a lookup which looks up values using a map.

If the map is null, then null will be returned from every lookup. The map result object is converted to a string using toString().

Parameters
<V>
the type of the values supported by the lookup.
map:Map<String, V>

the map of keys to values, may be null.

Returns:StrLookup<V>

a lookup using the map, not null.

noneLookupback to summary
public static StrLookup<?> noneLookup()

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns a lookup which always returns null.

Returns:StrLookup<?>

a lookup that always returns null, not null.

systemPropertiesLookupback to summary
public static StrLookup<String> systemPropertiesLookup()

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns a new lookup which uses a copy of the current System properties.

If a security manager blocked access to system properties, then null will be returned from every lookup.

If a null key is used, this lookup will throw a NullPointerException.

Returns:StrLookup<String>

a lookup using system properties, not null.

org.apache.commons.lang3.text back to summary

private final Class StrLookup.MapStrLookup<V>

extends StrLookup<V>
Class Inheritance
Type Parameters
<V>
the type of mapped values.

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Lookup implementation that uses a Map.

Field Summary

Modifier and TypeField and Description
private final Map<String, V>
map

Map keys are variable names and value.

Constructor Summary

AccessConstructor and Description
pack-priv
MapStrLookup(final Map<String, V>
the map of keys to values, may be null.
map
)

Creates a new instance backed by a Map.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the matching value, null if no match.
lookup
(final String
the key to be looked up, may be null.
key
)

Implements abstract org.apache.commons.lang3.text.StrLookup.lookup.

Looks up a String key to a String value using the map.

Inherited from org.apache.commons.lang3.text.StrLookup:
mapLookupnoneLookupsystemPropertiesLookup

Field Detail

mapback to summary
private final Map<String, V> map

Map keys are variable names and value.

Constructor Detail

MapStrLookupback to summary
pack-priv MapStrLookup(final Map<String, V> map)

Creates a new instance backed by a Map.

Parameters
map:Map<String, V>

the map of keys to values, may be null.

Method Detail

lookupback to summary
public String lookup(final String key)

Implements abstract org.apache.commons.lang3.text.StrLookup.lookup.

Looks up a String key to a String value using the map.

If the map is null, then null is returned. The map result object is converted to a string using toString().

Parameters
key:String

the key to be looked up, may be null.

Returns:String

the matching value, null if no match.

Annotations
@Override
org.apache.commons.lang3.text back to summary

private final Class StrLookup.SystemPropertiesStrLookup

extends StrLookup<String>
Class Inheritance

References Deprecated

StrLookup is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Lookup implementation based on system properties.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
lookup(final String key)

Implements abstract org.apache.commons.lang3.text.StrLookup.lookup.

Looks up a String key to a String value.

Inherited from org.apache.commons.lang3.text.StrLookup:
mapLookupnoneLookupsystemPropertiesLookup

Constructor Detail

SystemPropertiesStrLookupback to summary
private SystemPropertiesStrLookup()

Method Detail

lookupback to summary
public String lookup(final String key)

Implements abstract org.apache.commons.lang3.text.StrLookup.lookup.

Doc from org.apache.commons.lang3.text.StrLookup.lookup.

Looks up a String key to a String value.

The internal implementation may use any mechanism to return the value. The simplest implementation is to use a Map. However, virtually any implementation is possible.

For example, it would be possible to implement a lookup that used the key as a primary key, and looked up the value on demand from the database Or, a numeric based implementation could be created that treats the key as an integer, increments the value and return the result as a string - converting 1 to 2, 15 to 16 etc.

The lookup(String) method always returns a String, regardless of the underlying data, by converting it as necessary. For example:

Map<String, Object> map = new HashMap<String, Object>();
map.put("number", Integer.valueOf(2));
assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
This implementation directly accesses system properties.
Annotations
@Override