|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.templateutil.processor.ContextBasedLocalizedResourceSrv
Presents a generalized service for locating localized resources via entries in *.property files. This is a merging of the ApplicationContextServices registry method for locating a resource and the LocalizedResource service method of finding a localized version of a given resource. A specific use of such a service would be generate the path to localized icons.
To use this class, you need to have an entry in service.properties of the following form :
wt.services/rsc/default/LocalizedResourceService/<Context String>/<Context Class>/0=<Relative path from codebase>
an example of such an entry is :
wt.services/rsc/default/LocalizedResourceService/HELP/java.lang.Object/0=wt.clients.images.helphtml.gif
The Context String and the Context Class will be passed in as arguments in the call to get the localized resource.
The Relative path from codebase will be the path to the file, where the filename is NOT localized.
Field Summary | |
private String[] |
alternateExtensions
|
private ApplicationContext |
applicationContext
|
private boolean |
closeInputStream
|
private Locale |
locale
|
private LocalizedResource |
localizedResource
|
private InputStream |
localizedResourceInputStream
|
protected char |
newFileSeparator
|
protected char |
oldFileSeparator
|
private Vector |
preferences
|
private static String |
RESOURCE
|
private static boolean |
VERBOSE
|
private static String |
versionID
|
Fields inherited from interface wt.services.applicationcontext.ApplicationContextChild |
APPLICATION_CONTEXT |
Constructor Summary | |
ContextBasedLocalizedResourceSrv()
|
Method Summary | |
String[] |
getAlternateExtensions()
Returns the current set of alternate extensions to be used when searching for a localized resource. |
ApplicationContext |
getApplicationContext()
Gets the object for the association that plays role: APPLICATION_CONTEXT. |
ApplicationContextServices |
getApplicationContextServices()
|
Locale |
getLocale()
Returns the current Locale. |
Vector |
getPreferences()
Return the vector of preferences to be used to determine the Locale to use if the Locale has not been set directly with a call to the setLocale method. |
InputStream |
getResourceInputStream(String action,
Object obj)
|
String |
getResourcePath(String action,
Object obj)
Uses the ApplicationContextService with the String and Object as the Context to select a base path for a localized resource. |
String |
getResourceURL(String action,
Object obj)
Returns the full URL to a resource, assuming that the resource is somewhere under the codebase directory. |
static void |
main(String[] args)
Used to test if a certain localized resource is is being found by the service. |
String |
processResourceName(String resourceFileName)
Replaces the "." in the String returned from a *.property file with the correct file separator. |
void |
setAlternateExtensions(String[] new_Extensions)
Sets the allowed alternate extensions when searching for a localized resource. |
void |
setApplicationContext(ApplicationContext a_ApplicationContext)
Sets the object for the association that plays role: APPLICATION_CONTEXT. |
void |
setLocale(Locale new_locale)
Set the Locale to be used to select the localized resource. |
void |
setPreferences(Vector new_Preferences)
Sets the vector of preferences to be used to determine the Locale to use if the Locale has not been set directly with a call to the setLocale method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static final String versionID
private ApplicationContext applicationContext
private static boolean VERBOSE
private Locale locale
private Vector preferences
private String[] alternateExtensions
private boolean closeInputStream
private LocalizedResource localizedResource
private InputStream localizedResourceInputStream
protected char oldFileSeparator
protected char newFileSeparator
Constructor Detail |
public ContextBasedLocalizedResourceSrv() throws UnableToLoadServiceProperties
Method Detail |
public void setLocale(Locale new_locale)
new_locale
- public Locale getLocale()
public void setPreferences(Vector new_Preferences)
new_Preferences
- public Vector getPreferences()
public void setAlternateExtensions(String[] new_Extensions)
For example, when searching for an HTML page, you would like to be able to search for a file name with either the *.html or the *.htm extension. Setting this String array is how you specify these options
new_Extensions
- public String[] getAlternateExtensions()
For example, when searching for an HTML page, you would like to be able to search for a file name with either the *.html or the *.htm extension. Setting this String array is how you specify these options
public String getResourcePath(String action, Object obj) throws WTException
action
- The context String used in the ApplicationContextServices lookupobj
- The class of this Object is used to define the Context Class used in the ApplicationContextServices lookup
WTException
public String processResourceName(String resourceFileName)
resourceFileName
- Entry from the a *.property file
public String getResourceURL(String action, Object obj) throws WTException
action
- The context String used in the ApplicationContextServices serviceobj
- The class of this Object is used to define the class to be used in the ApplicationContextServices service
WTException
public InputStream getResourceInputStream(String action, Object obj) throws WTException
WTException
public ApplicationContextServices getApplicationContextServices()
public ApplicationContext getApplicationContext()
ApplicationContextChild
getApplicationContext
in interface ApplicationContextChild
public void setApplicationContext(ApplicationContext a_ApplicationContext) throws WTPropertyVetoException
ApplicationContextChild
setApplicationContext
in interface ApplicationContextChild
a_ApplicationContext
-
WTPropertyVetoException
public static void main(String[] args)
To run this test, enter the following command line call
java wt.templateutil.processor.ContextBasedLocalizedResourceSrv <Context String> <Locale>
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |