public class ResourceResolverDecorator extends Object implements ResourceResolver
REF_KEY_END, REF_KEY_START
Constructor and Description |
---|
ResourceResolverDecorator(ResourceResolver delegate) |
Modifier and Type | Method and Description |
---|---|
protected <T> T |
convertValue(Object value,
Class<T> type) |
String |
formatResource(String resource,
List<?> args)
Formats the given resource using supplied args to substitute placeholders.
|
String |
formatResource(String resource,
Map<String,Object> args)
Formats the given resource using supplied args to substitute placeholders.
|
String |
formatResource(String resource,
Object[] args)
Formats the given resource using supplied args to substitute placeholders.
|
protected ResourceResolver |
getDelegate() |
Object |
resolveResource(String key)
Try to resolve the resource.
|
Object |
resolveResource(String key,
List<?> args)
Try to resolve the resource.
|
Object |
resolveResource(String key,
List<?> args,
Locale locale)
Try to resolve the resource.
|
Object |
resolveResource(String key,
List<?> args,
Locale locale,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
List<?> args,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Locale locale)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Locale locale,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Map<String,Object> args)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Map<String,Object> args,
Locale locale)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Map<String,Object> args,
Locale locale,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Map<String,Object> args,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Object[] args)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Object[] args,
Locale locale)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Object[] args,
Locale locale,
Object defaultValue)
Try to resolve the resource.
|
Object |
resolveResource(String key,
Object[] args,
Object defaultValue)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
List<?> args,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
List<?> args,
Locale locale,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
List<?> args,
Locale locale,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
List<?> args,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Locale locale,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Locale locale,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Map<String,Object> args,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Map<String,Object> args,
Locale locale,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Map<String,Object> args,
Locale locale,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Map<String,Object> args,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Object[] args,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Object[] args,
Locale locale,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Object[] args,
Locale locale,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
Object[] args,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
<T> T |
resolveResourceConverted(String key,
T defaultValue,
Class<T> type)
Try to resolve the resource.
|
Object |
resolveResourceValue(String key,
Locale locale)
Resolve a resource given a key and a Locale.
|
public ResourceResolverDecorator(@Nonnull ResourceResolver delegate)
@Nonnull protected ResourceResolver getDelegate()
@Nonnull public Object resolveResource(@Nonnull String key) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'NoSuchResourceException
- if no resource is found@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull Locale locale) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupNoSuchResourceException
- if no resource is found@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull Object[] args) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.NoSuchResourceException
- if no resource is found@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupNoSuchResourceException
- if no resource is found@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull List<?> args) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.NoSuchResourceException
- if no resource is found@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupNoSuchResourceException
- if no resource is found@Nullable public Object resolveResource(@Nonnull String key, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'defaultValue
- Message to return if the lookup fails@Nullable public Object resolveResource(@Nonnull String key, @Nonnull Locale locale, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup fails@Nullable public Object resolveResource(@Nonnull String key, @Nonnull Object[] args, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.defaultValue
- Message to return if the lookup fails@Nullable public Object resolveResource(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup fails@Nullable public Object resolveResource(@Nonnull String key, @Nonnull List<?> args, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.defaultValue
- Message to return if the lookup fails@Nullable public Object resolveResource(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup fails@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.NoSuchResourceException
- if no resource is found@Nonnull public Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale) throws NoSuchResourceException
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupNoSuchResourceException
- if no resource is found@Nullable public Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.defaultValue
- Message to return if the lookup fails@Nullable public Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale, @Nullable Object defaultValue)
ResourceResolver
resolveResource
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup fails@Nonnull public Object resolveResourceValue(@Nonnull String key, @Nonnull Locale locale) throws NoSuchResourceException
ResourceResolver
Resolve a resource given a key and a Locale.
This method should use the default Locale if the locale argument is null. The key
argument may refer to
another key if the resolved value results in a CharSequence
that begins with "@[" and ends with "]". In this
case the method will use the enclosed value as the next key to be resolved. For example, given the following key/value
definitions
some.key = Hello {0} other.key = @[some.key]Evaluating the keys results in
assert resolveResourceValue('some.key', Locale.default) == 'Hello {0}' assert resolveResourceValue('other.key', Locale.default) == 'Hello {0}'
resolveResourceValue
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupNoSuchResourceException
- if no message is found@Nonnull public String formatResource(@Nonnull String resource, @Nonnull List<?> args)
ResourceResolver
formatResource
in interface ResourceResolver
resource
- The resource following a predefined format.args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.@Nonnull public String formatResource(@Nonnull String resource, @Nonnull Object[] args)
ResourceResolver
formatResource
in interface ResourceResolver
resource
- The resource following a predefined format.args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.@Nonnull public String formatResource(@Nonnull String resource, @Nonnull Map<String,Object> args)
ResourceResolver
formatResource
in interface ResourceResolver
resource
- The resource following a predefined format.args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.defaultValue
- Message to return if the lookup failstype
- the type to be returned@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup failstype
- the type to be returned@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookuptype
- the type to be returnedNoSuchResourceException
- if no resource is found@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.type
- the type to be returnedNoSuchResourceException
- if no resource is found@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.defaultValue
- Message to return if the lookup failstype
- the type to be returned@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup failstype
- the type to be returned@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookuptype
- the type to be returnedNoSuchResourceException
- if no resource is found@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{:key}"
within a resource, but this might differ between implementations), or null if none.type
- the type to be returnedNoSuchResourceException
- if no resource is found@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.defaultValue
- Message to return if the lookup failstype
- the type to be returned@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}"
within a resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup failstype
- the type to be returned@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.locale
- Locale in which to lookuptype
- the type to be returnedNoSuchResourceException
- if no resource is found@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'args
- Arguments that will be filled in for params within the resource (params look like "{0}" within a
resource, but this might differ between implementations), or null if none.type
- the type to be returnedNoSuchResourceException
- if no resource is found@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'defaultValue
- Message to return if the lookup failstype
- the type to be returned@Nullable public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup failstype
- the type to be returned@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookuptype
- the type to be returnedNoSuchResourceException
- if no resource is found@Nonnull public <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Class<T> type) throws NoSuchResourceException
ResourceResolver
PropertyEditor
.resolveResourceConverted
in interface ResourceResolver
key
- Key to lookup, such as 'sample.SampleModel.icon'type
- the type to be returnedNoSuchResourceException
- if no resource is found