|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eigenbase.resgen.ResourceDefinition
public class ResourceDefinition
Definition of a resource such as a parameterized message or exception.
A resource is identified within a ResourceBundle by a text
key, and has a message in its base locale (which is
usually US-English (en_US)). It may also have a set of properties, which are
represented as name-value pairs.
A resource definition is immutable.
| Field Summary | |
|---|---|
java.lang.String |
baseMessage
|
java.lang.String |
key
|
static int |
TYPE_DATE
|
static int |
TYPE_NUMBER
|
static int |
TYPE_STRING
|
static int |
TYPE_TIME
|
static int |
TYPE_UNKNOWN
|
| Constructor Summary | |
|---|---|
ResourceDefinition(java.lang.String key,
java.lang.String baseMessage)
Creates a resource definition with no properties. |
|
ResourceDefinition(java.lang.String key,
java.lang.String baseMessage,
java.lang.String[] props)
Creates a resource definition. |
|
| Method Summary | |
|---|---|
protected static int |
getArgType(int i,
java.lang.String message)
Returns the type of the ith argument inside a message,
or TYPE_UNKNOWN if not found. |
java.lang.String[] |
getArgTypes()
Returns the types of arguments. |
protected static java.lang.String[] |
getArgTypes(java.lang.String message,
java.lang.String[] typeNames)
Parses a message for the arguments inside it, and returns an array with the types of those arguments. |
protected static java.lang.String[] |
getArgTypesByHand(java.lang.String message,
java.lang.String[] typeNames)
|
java.lang.String |
getBaseMessage()
Returns this resource definition's message in the base locale. |
java.lang.String |
getKey()
Returns this resource definition's key. |
java.util.Properties |
getProperties()
Returns the properties of this resource definition. |
ResourceInstance |
instantiate(java.util.ResourceBundle bundle,
java.lang.Object[] args)
Creates an instance of this definition with a set of parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.String key
public final java.lang.String baseMessage
public static final int TYPE_UNKNOWN
public static final int TYPE_STRING
public static final int TYPE_NUMBER
public static final int TYPE_DATE
public static final int TYPE_TIME
| Constructor Detail |
|---|
public ResourceDefinition(java.lang.String key,
java.lang.String baseMessage)
key - Unique name for this resource definition.baseMessage - Message for this resource definition in the base
locale.
public ResourceDefinition(java.lang.String key,
java.lang.String baseMessage,
java.lang.String[] props)
key - Unique name for this resource definition.baseMessage - Message for this resource definition in the base
locale.props - Array of property name/value pairs.
null means the same as an empty array.| Method Detail |
|---|
public java.lang.String getKey()
public java.lang.String getBaseMessage()
public java.util.Properties getProperties()
public java.lang.String[] getArgTypes()
public ResourceInstance instantiate(java.util.ResourceBundle bundle,
java.lang.Object[] args)
bundle - Resource bundle the resource instance will belong to
(This contains the locale, among other things.)args - Arguments to populate the message's parameters.
The arguments must be consistent in number and type with the results
of getArgTypes().
protected static java.lang.String[] getArgTypes(java.lang.String message,
java.lang.String[] typeNames)
For example, getArgTypes("I bought {0,number} {2}s",
new String[] {"string", "number", "date", "time"})
yields {"number", null, "string"}.
Note the null corresponding to missing message #1.
message - Message to be parsed.typeNames - Strings to return for types.
protected static java.lang.String[] getArgTypesByHand(java.lang.String message,
java.lang.String[] typeNames)
protected static int getArgType(int i,
java.lang.String message)
ith argument inside a message,
or TYPE_UNKNOWN if not found.
i - Ordinal of argumentmessage - Message to parse
TYPE_STRING etc.)
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||