public class StandardResourceDescriptionResolver extends Object implements ResourceDescriptionResolver
ResourceBundle based ResourceDescriptionResolver that builds resource bundle
keys by taking a "key prefix" provided to the constructor and dot-appending the string params to the
various getXXXDescription methods. The "key prefix" is associated with a particular resource and serves
to provide a namespace for the resource's key's in the set of keys used by a ResourceBundle.
Code that uses this class to localize text descriptions should store their text description in a properties
file whose keys follow the following format, where "prefix" is the keyPrefix param passed to the constructor,
"attribute-name" is the name of an attribute, "operation-name" is the name of an operation, "param-name" is the
name of a parameter to an operation, "child-type" is the name of one of the resource's valid child types, and
"value-type-suffix" is the name of some detail element in a parameter, attribute or operation reply value that has a
complex type.
prefix=The description of the resource
prefix.attribute-name=The description of one of the resource's attributes.
prefix.attribute-name.value-type-suffix=The description of an element in a complex attribute's ModelDescriptionConstants.VALUE_TYPE.
prefix.operation-name=The description of one of the resource's operations.
prefix.operation-name.param-name=The description of one of an operation's parameters.
prefix.operation-name.param-name.value-type-suffix=The description of an element in a complex operation parameter's ModelDescriptionConstants.VALUE_TYPE.
prefix.operation-name.reply=The description of an operation's reply value.
prefix.operation-name.reply.value-type-suffix=The description of an element in a complex operation reply value's ModelDescriptionConstants.VALUE_TYPE.
prefix.child-type=The description of one of the resource's child resource types.
The constructor supports two settings designed to help minimize the need for redundant entries in the properties file:
reuseAttributesForAdd affects how the getOperationParameter... methods work. If true,
the assumption is that for an operation named "add" the text description of a parameter will be the same as
the description of an attribute of the same name. This would allow the properties for this example resource:
pool.min-size=The minimum pool size. pool.max-size=The maximum pool size. pool.add.min-size=The minimum pool size. pool.add.max-size=The maximum pool size.
To be reduced to:
pool.min-size=The minimum pool size. pool.max-size=The maximum pool size.
useUnprefixedChildTypes affects how the getChildTypeDescription(String, Locale, ResourceBundle)
method works. The descriptions of a set of related resources need to include a description in the parent resource
of its relationship to the child resource, as well as the description of the child resource itself. These two
descriptions are often included in the same properties file and may be the exact same text. If useUnprefixedChildTypes
is true, getChildTypeDescription(...) will assume there is an entry in the properties file
that exactly matches the name of the child type. This would allow the properties for this example set of resources:
subsystem=The foo subsystem. ... attributes and operations of the "subsystem" resource subsystem.connector=A connector that can be used to access the foo. connector=A connector that can be used to access the foo. ... attributes and operations of the "connector" resource
To be reduced to:
subsystem=The foo subsystem. ... attributes and operations of the "subsystem" resource connector=A connector that can be used to access the foo. connector=A connector that can be used to access the foo. ... attributes and operations of the "connector" resource
Note that while this kind of usage is convenient, it often results in slightly lower quality descriptions. For example, in the example above, a better description for "subsystem.connector" is "The connectors that can be used to access the foo."
| Modifier and Type | Field and Description |
|---|---|
static String |
REPLY
Additional string dot-appended to the key by the
getOperationReplyDescription(String, Locale, ResourceBundle) method. |
| Constructor and Description |
|---|
StandardResourceDescriptionResolver(String keyPrefix,
String bundleBaseName,
ClassLoader bundleLoader) |
StandardResourceDescriptionResolver(String keyPrefix,
String bundleBaseName,
ClassLoader bundleLoader,
boolean reuseAttributesForAdd,
boolean useUnprefixedChildTypes) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getBundleKey(String... args) |
StandardResourceDescriptionResolver |
getChildResolver(String key) |
String |
getChildTypeDescription(String childType,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's child types.
|
String |
getKeyPrefix() |
String |
getNotificationDescription(String notificationType,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's notification.
|
String |
getOperationDeprecatedDescription(String operationName,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's operations.
|
String |
getOperationDescription(String operationName,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's operations.
|
String |
getOperationParameterDeprecatedDescription(String operationName,
String paramName,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's operation's parameters.
|
String |
getOperationParameterDescription(String operationName,
String paramName,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's operation's parameters.
|
String |
getOperationParameterValueTypeDescription(String operationName,
String paramName,
Locale locale,
ResourceBundle bundle,
String... suffixes)
Gets the description of a portion of a complex value type of one of the resource's operation's parameters.
|
String |
getOperationReplyDescription(String operationName,
Locale locale,
ResourceBundle bundle)
Gets the description of the reply value for one of the resource's operations, or
null if there is
no description. |
String |
getOperationReplyValueTypeDescription(String operationName,
Locale locale,
ResourceBundle bundle,
String... suffixes)
Gets the description of a portion of a complex value type of the reply value for one of the resource's operations, or
null if there is
no description. |
String |
getResourceAttributeDeprecatedDescription(String attributeName,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's attributes.
|
String |
getResourceAttributeDescription(String attributeName,
Locale locale,
ResourceBundle bundle)
Gets the description of one of the resource's attributes.
|
String |
getResourceAttributeValueTypeDescription(String attributeName,
Locale locale,
ResourceBundle bundle,
String... suffixes)
Gets the description of a portion of a complex value type of one of the resource's attributes.
|
ResourceBundle |
getResourceBundle(Locale locale)
Returns a
ResourceBundle for the given Locale, or null if this resolver
is not based on resource bundles. |
String |
getResourceDeprecatedDescription(Locale locale,
ResourceBundle bundle)
Gets the description of the resource.
|
String |
getResourceDescription(Locale locale,
ResourceBundle bundle)
Gets the description of the resource.
|
boolean |
isReuseAttributesForAdd() |
boolean |
isUseUnprefixedChildTypes() |
public static final String REPLY
getOperationReplyDescription(String, Locale, ResourceBundle) method.public StandardResourceDescriptionResolver(String keyPrefix, String bundleBaseName, ClassLoader bundleLoader)
public StandardResourceDescriptionResolver(String keyPrefix, String bundleBaseName, ClassLoader bundleLoader, boolean reuseAttributesForAdd, boolean useUnprefixedChildTypes)
public String getKeyPrefix()
public boolean isReuseAttributesForAdd()
public boolean isUseUnprefixedChildTypes()
public StandardResourceDescriptionResolver getChildResolver(String key)
public ResourceBundle getResourceBundle(Locale locale)
ResourceBundle for the given Locale, or null if this resolver
is not based on resource bundles.
This method will be invoked at least once before a series of invocations of the other methods in this interface, and the returned bundle will be passed to those methods as a parameter. The intent is to cache a resource bundle on the stack during the execution of all the methods needed to describe a resource or operation.
getResourceBundle in interface ResourceDescriptionResolverlocale - the localenullpublic String getResourceDescription(Locale locale, ResourceBundle bundle)
getResourceDescription in interface ResourceDescriptionResolverlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle)
getResourceAttributeDescription in interface ResourceDescriptionResolverattributeName - the name of the attributelocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getResourceAttributeValueTypeDescription(String attributeName, Locale locale, ResourceBundle bundle, String... suffixes)
getResourceAttributeValueTypeDescription in interface ResourceDescriptionResolverattributeName - the name of the attributelocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullsuffixes - suffixes to dot-append to the base attribute key to generate a keypublic String getOperationDescription(String operationName, Locale locale, ResourceBundle bundle)
getOperationDescription in interface ResourceDescriptionResolveroperationName - the name of the operationlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getOperationParameterDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)
getOperationParameterDescription in interface ResourceDescriptionResolveroperationName - the name of the operationparamName - the name of the operation's parameterlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getOperationParameterValueTypeDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle, String... suffixes)
getOperationParameterValueTypeDescription in interface ResourceDescriptionResolveroperationName - the name of the operationparamName - the name of the operation's parameterlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullsuffixes - suffixes to dot-append to the base attribute key to generate a keypublic String getOperationReplyDescription(String operationName, Locale locale, ResourceBundle bundle)
null if there is
no description.getOperationReplyDescription in interface ResourceDescriptionResolveroperationName - the name of the operationlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullnullpublic String getOperationReplyValueTypeDescription(String operationName, Locale locale, ResourceBundle bundle, String... suffixes)
null if there is
no description.getOperationReplyValueTypeDescription in interface ResourceDescriptionResolveroperationName - the name of the operationlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullsuffixes - suffixes to dot-append to the base attribute key to generate a keynullpublic String getNotificationDescription(String notificationType, Locale locale, ResourceBundle bundle)
getNotificationDescription in interface ResourceDescriptionResolvernotificationType - the type of the notificationlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getChildTypeDescription(String childType, Locale locale, ResourceBundle bundle)
getChildTypeDescription in interface ResourceDescriptionResolverchildType - the name of the child typelocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getResourceDeprecatedDescription(Locale locale, ResourceBundle bundle)
getResourceDeprecatedDescription in interface ResourceDescriptionResolverlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getResourceAttributeDeprecatedDescription(String attributeName, Locale locale, ResourceBundle bundle)
getResourceAttributeDeprecatedDescription in interface ResourceDescriptionResolverattributeName - the name of the attributelocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getOperationDeprecatedDescription(String operationName, Locale locale, ResourceBundle bundle)
getOperationDeprecatedDescription in interface ResourceDescriptionResolveroperationName - the name of the operationlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullpublic String getOperationParameterDeprecatedDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle)
getOperationParameterDeprecatedDescription in interface ResourceDescriptionResolveroperationName - the name of the operationparamName - the name of the operation's parameterlocale - the localebundle - a resource bundle previously obtained from a call to ResourceDescriptionResolver.getResourceBundle(java.util.Locale),
or null if that call returned nullCopyright © 2019 JBoss by Red Hat. All rights reserved.