|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.moremotion.resource.Resource
public class Resource
Represents a multi-lingual resource. A resource has a resource Id, arguments and the name of the Resource Bundle where the resource definition exist.
Example:
String tableName = "table_x"; String dbName = "products"; Resource res = new Resource("TABLE_NOT_FOUND", new String[]{tableName,dbName}, "myres"); ADOM myds = request.newRequestADOM("myds"); myds.setNodeValue("msg", res.toString());
toString()
Method returns a specially formatted string. E.g: $res(TABLE_NOT_FOUND#myres,table_x,products)Such
$res()
definitions existing in an ADOM are resolved with the actual resource text in the language
of the page to be displayed next. The actual text of a resource i.e. TABLE_NOT_FOUND
is taken
from the resource bundle i.e. myres
and the %0, %1
symbols in the resource text are
replaced with arguments i.e. table_x, products
.
Field Summary | |
---|---|
static java.lang.String |
RES
|
Constructor Summary | |
---|---|
Resource(java.lang.String id)
Creates a new resource. |
|
Resource(java.lang.String id,
java.lang.String[] arguments)
Creates a new resource. |
|
Resource(java.lang.String id,
java.lang.String[] arguments,
java.lang.String resBundleName)
Creates a new resource. |
Method Summary | |
---|---|
boolean |
bundleAssigned()
Returns 'true' is a bundle name is assigned to resource 'false' otherwise |
java.lang.String |
format(java.lang.String language)
Formats this resource by retrieving the actual text in specified language from the resource bundle and replacing the resource argument symbols in it. |
java.lang.String[] |
getArguments()
Returns the resource arguments. |
java.lang.String |
getBundleName()
Returns the name of the resource bundle |
java.lang.String |
getId()
Returns the resource Id. |
static void |
main(java.lang.String[] args)
Test method. |
static Resource |
parse(java.lang.String resfunc)
Parses the resource function in the specified string and returns a resource object. |
void |
setArguments(java.lang.String[] value)
Sets the resource arguments. |
void |
setBundleName(java.lang.String bundleName)
Sets the name of the resource bundle |
java.lang.String |
toString()
Returns the string respresentation of this resource as $res() function. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String RES
Constructor Detail |
---|
public Resource(java.lang.String id)
id
- The resource Idpublic Resource(java.lang.String id, java.lang.String[] arguments)
id
- The resource Idarguments
- The String array each element of it positionally corresponding to a resource argumentpublic Resource(java.lang.String id, java.lang.String[] arguments, java.lang.String resBundleName)
id
- The resource Idarguments
- The String array each element of it positionally corresponding to a resource argumentresBundleName
- The name of the resource bundle where the actual resource text of this resource is keptMethod Detail |
---|
public void setBundleName(java.lang.String bundleName)
public java.lang.String getBundleName()
public boolean bundleAssigned()
public java.lang.String getId()
public java.lang.String[] getArguments()
public void setArguments(java.lang.String[] value)
public java.lang.String toString()
$res(RESOURCE_ID#bundle_name,res_arg1,res_arg2,..)
toString
in class java.lang.Object
public java.lang.String format(java.lang.String language) throws ResourceException
language
- The language code i.e. en, de, fr, tr, etc.
ResourceException
- if retrieval of the actual text fails.public static Resource parse(java.lang.String resfunc) throws ResourceException
ResourceException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |