public interface ResourceResolver
Modifier and Type | Field and Description |
---|---|
static String |
REF_KEY_END
"]"
|
static String |
REF_KEY_START
"@["
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
static final String REF_KEY_START
static final String REF_KEY_END
@Nonnull Object resolveResource(@Nonnull String key) throws NoSuchResourceException
key
- Key to lookup, such as 'sample.SampleModel.icon'NoSuchResourceException
- if no resource is found@Nonnull Object resolveResource(@Nonnull String key, @Nonnull Locale locale) throws NoSuchResourceException
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupNoSuchResourceException
- if no resource is found@Nonnull Object resolveResource(@Nonnull String key, @Nonnull Object[] args) throws NoSuchResourceException
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 Object resolveResource(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale) throws NoSuchResourceException
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 Object resolveResource(@Nonnull String key, @Nonnull List<?> args) throws NoSuchResourceException
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 Object resolveResource(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale) throws NoSuchResourceException
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 Object resolveResource(@Nonnull String key, @Nullable Object defaultValue)
key
- Key to lookup, such as 'sample.SampleModel.icon'defaultValue
- Message to return if the lookup fails@Nullable Object resolveResource(@Nonnull String key, @Nonnull Locale locale, @Nullable Object defaultValue)
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupdefaultValue
- Message to return if the lookup fails@Nullable Object resolveResource(@Nonnull String key, @Nonnull Object[] args, @Nullable Object defaultValue)
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 Object resolveResource(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale, @Nullable Object defaultValue)
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 Object resolveResource(@Nonnull String key, @Nonnull List<?> args, @Nullable Object defaultValue)
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 Object resolveResource(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale, @Nullable Object defaultValue)
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 Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args) throws NoSuchResourceException
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 Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale) throws NoSuchResourceException
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 Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args, @Nullable Object defaultValue)
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 Object resolveResource(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale, @Nullable Object defaultValue)
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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.key
- Key to lookup, such as 'sample.SampleModel.icon'type
- the type to be returnedNoSuchResourceException
- if no resource is found@Nonnull <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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@Nonnull <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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@Nonnull <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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@Nullable <T> T resolveResourceConverted(@Nonnull String key, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.key
- Key to lookup, such as 'sample.SampleModel.icon'defaultValue
- Message to return if the lookup failstype
- the type to be returned@Nullable <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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@Nullable <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Object[] args, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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@Nullable <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull List<?> args, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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@Nonnull <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale, @Nonnull Class<T> type) throws NoSuchResourceException
PropertyEditor
.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@Nullable <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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 <T> T resolveResourceConverted(@Nonnull String key, @Nonnull Map<String,Object> args, @Nonnull Locale locale, @Nullable T defaultValue, @Nonnull Class<T> type)
PropertyEditor
.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 Object resolveResourceValue(@Nonnull String key, @Nonnull Locale locale) throws NoSuchResourceException
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}'
key
- Key to lookup, such as 'sample.SampleModel.icon'locale
- Locale in which to lookupNoSuchResourceException
- if no message is found@Nonnull String formatResource(@Nonnull String resource, @Nonnull List<?> args)
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 String formatResource(@Nonnull String resource, @Nonnull Object[] args)
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 String formatResource(@Nonnull String resource, @Nonnull Map<String,Object> args)
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.