Java Doc for ICUService.java in  » Internationalization-Localization » icu4j » com » ibm » icu » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.impl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ibm.icu.impl.ICUNotifier
      com.ibm.icu.impl.ICUService

All known Subclasses:   com.ibm.icu.impl.ICULocaleService,
ICUService
public class ICUService extends ICUNotifier (Code)

A Service provides access to service objects that implement a particular service, e.g. transliterators. Users provide a String id (for example, a locale string) to the service, and get back an object for that id. Service objects can be any kind of object. The service object is cached and returned for later queries, so generally it should not be mutable, or the caller should clone the object before modifying it.

Services 'canonicalize' the query id and use the canonical id to query for the service. The service also defines a mechanism to 'fallback' the id multiple times. Clients can optionally request the actual id that was matched by a query when they use an id to retrieve a service object.

Service objects are instantiated by Factory objects registered with the service. The service queries each Factory in turn, from most recently registered to earliest registered, until one returns a service object. If none responds with a service object, a fallback id is generated, and the process repeats until a service object is returned or until the id has no further fallbacks.

Factories can be dynamically registered and unregistered with the service. When registered, a Factory is installed at the head of the factory list, and so gets 'first crack' at any keys or fallback keys. When unregistered, it is removed from the service and can no longer be located through it. Service objects generated by this factory and held by the client are unaffected.

ICUService uses Keys to query factories and perform fallback. The Key defines the canonical form of the id, and implements the fallback strategy. Custom Keys can be defined that parse complex IDs into components that Factories can more easily use. The Key can cache the results of this parsing to save repeated effort. ICUService provides convenience APIs that take Strings and generate default Keys for use in querying.

ICUService provides API to get the list of ids publicly supported by the service (although queries aren't restricted to this list). This list contains only 'simple' IDs, and not fully unique ids. Factories are associated with each simple ID and the responsible factory can also return a human-readable localized version of the simple ID, for use in user interfaces. ICUService can also provide a sorted collection of the all the localized visible ids.

ICUService implements ICUNotifier, so that clients can register to receive notification when factories are added or removed from the service. ICUService provides a default EventListener subinterface, ServiceListener, which can be registered with the service. When the service changes, the ServiceListener's serviceChanged method is called, with the service as the only argument.

The ICUService API is both rich and generic, and it is expected that most implementations will statically 'wrap' ICUService to present a more appropriate API-- for example, to declare the type of the objects returned from get, to limit the factories that can be registered with the service, or to define their own listener interface with a custom callback method. They might also customize ICUService by overriding it, for example, to customize the Key and fallback strategy. ICULocaleService is a customized service that uses Locale names as ids and uses Keys that implement the standard resource bundle fallback strategy.


Inner Class :public static class Key
Inner Class :public static interface Factory
Inner Class :public static class SimpleFactory implements Factory
Inner Class :public static interface ServiceListener extends EventListener

Field Summary
final protected  Stringname
     Name used for debugging.

Constructor Summary
public  ICUService()
     Constructor.
public  ICUService(String name)
     Construct with a name (useful for debugging).

Method Summary
protected  booleanacceptsListener(EventListener l)
     Return true if the listener is accepted; by default this requires a ServiceListener.
protected  voidclearCaches()
     Clear caches maintained by this service.
protected  voidclearServiceCache()
     Clears only the service cache.
public  KeycreateKey(String id)
     Create a key from an id.
final public  Listfactories()
     Return a snapshot of the currently registered factories.
public  Objectget(String descriptor)
     Convenience override for get(String, String[]).
public  Objectget(String descriptor, String[] actualReturn)
     Convenience override for get(Key, String[]).
public  StringgetDisplayName(String id)
     Convenience override for getDisplayName(String, ULocale) that uses the current default locale.
public  StringgetDisplayName(String id, ULocale locale)
     Given a visible id, return the display name in the requested locale.
public  SortedMapgetDisplayNames()
     Convenience override of getDisplayNames(ULocale, Comparator, String) that uses the current default Locale as the locale, null as the comparator, and null for the matchID.
public  SortedMapgetDisplayNames(ULocale locale)
     Convenience override of getDisplayNames(ULocale, Comparator, String) that uses null for the comparator, and null for the matchID.
public  SortedMapgetDisplayNames(ULocale locale, Comparator com)
     Convenience override of getDisplayNames(ULocale, Comparator, String) that uses null for the matchID, thus returning all display names.
public  SortedMapgetDisplayNames(ULocale locale, String matchID)
     Convenience override of getDisplayNames(ULocale, Comparator, String) that uses null for the comparator.
public  SortedMapgetDisplayNames(ULocale locale, Comparator com, String matchID)
     Return a snapshot of the mapping from display names to visible IDs for this service.
public  ObjectgetKey(Key key)
     Convenience override for get(Key, String[]).
public  ObjectgetKey(Key key, String[] actualReturn)
    

Given a key, return a service object, and, if actualReturn is not null, the descriptor with which it was found in the first element of actualReturn.

public  ObjectgetKey(Key key, String[] actualReturn, Factory factory)
    
public  StringgetName()
     Return the name of this service.
public  SetgetVisibleIDs()
     Convenience override for getVisibleIDs(String) that passes null as the fallback, thus returning all visible IDs.
public  SetgetVisibleIDs(String matchID)
    

Return a snapshot of the visible IDs for this service.

protected  ObjecthandleDefault(Key key, String[] actualIDReturn)
     Default handler for this service if no factory in the list handled the key.
public  booleanisDefault()
     Return true if the service is in its default state.
protected  voidmarkDefault()
     Set the default size to the current number of registered factories.
protected  voidnotifyListener(EventListener l)
     Notify the listener, which by default is a ServiceListener.
protected  voidreInitializeFactories()
     Reinitialize the factory list to its default state.
final public  FactoryregisterFactory(Factory factory)
     Register a Factory.
public  FactoryregisterObject(Object obj, String id)
     A convenience override of registerObject(Object, String, boolean) that defaults visible to true.
public  FactoryregisterObject(Object obj, String id, boolean visible)
     Register an object with the provided id.
final public  voidreset()
     Reset the service to the default factories.
public  Stringstats()
     Return a string describing the statistics for this service. This also resets the statistics.
public  StringtoString()
     Returns the result of super.toString, appending the name in curly braces.
final public  booleanunregisterFactory(Factory factory)
     Unregister a factory.

Field Detail
name
final protected String name(Code)
Name used for debugging.




Constructor Detail
ICUService
public ICUService()(Code)
Constructor.



ICUService
public ICUService(String name)(Code)
Construct with a name (useful for debugging).




Method Detail
acceptsListener
protected boolean acceptsListener(EventListener l)(Code)
Return true if the listener is accepted; by default this requires a ServiceListener. Subclasses can override to accept different listeners.



clearCaches
protected void clearCaches()(Code)
Clear caches maintained by this service. Subclasses can override if they implement additional that need to be cleared when the service changes. Subclasses should generally not call this method directly, as it must only be called while synchronized on this.



clearServiceCache
protected void clearServiceCache()(Code)
Clears only the service cache. This can be called by subclasses when a change affects the service cache but not the id caches, e.g., when the default locale changes the resolution of ids changes, but not the visible ids themselves.



createKey
public Key createKey(String id)(Code)
Create a key from an id. This creates a Key instance. Subclasses can override to define more useful keys appropriate to the factories they accept. If id is null, returns null.



factories
final public List factories()(Code)
Return a snapshot of the currently registered factories. There is no guarantee that the list will still match the current factory list of the service subsequent to this call.



get
public Object get(String descriptor)(Code)
Convenience override for get(String, String[]). This uses createKey to create a key for the provided descriptor.



get
public Object get(String descriptor, String[] actualReturn)(Code)
Convenience override for get(Key, String[]). This uses createKey to create a key from the provided descriptor.



getDisplayName
public String getDisplayName(String id)(Code)
Convenience override for getDisplayName(String, ULocale) that uses the current default locale.



getDisplayName
public String getDisplayName(String id, ULocale locale)(Code)
Given a visible id, return the display name in the requested locale. If there is no directly supported id corresponding to this id, return null.



getDisplayNames
public SortedMap getDisplayNames()(Code)
Convenience override of getDisplayNames(ULocale, Comparator, String) that uses the current default Locale as the locale, null as the comparator, and null for the matchID.



getDisplayNames
public SortedMap getDisplayNames(ULocale locale)(Code)
Convenience override of getDisplayNames(ULocale, Comparator, String) that uses null for the comparator, and null for the matchID.



getDisplayNames
public SortedMap getDisplayNames(ULocale locale, Comparator com)(Code)
Convenience override of getDisplayNames(ULocale, Comparator, String) that uses null for the matchID, thus returning all display names.



getDisplayNames
public SortedMap getDisplayNames(ULocale locale, String matchID)(Code)
Convenience override of getDisplayNames(ULocale, Comparator, String) that uses null for the comparator.



getDisplayNames
public SortedMap getDisplayNames(ULocale locale, Comparator com, String matchID)(Code)
Return a snapshot of the mapping from display names to visible IDs for this service. This set will not change as factories are added or removed, but the supported ids will, so there is no guarantee that all and only the ids in the returned map will be visible and supported by the service in subsequent calls, nor is there any guarantee that the current display names match those in the set. The display names are sorted based on the comparator provided.



getKey
public Object getKey(Key key)(Code)
Convenience override for get(Key, String[]).



getKey
public Object getKey(Key key, String[] actualReturn)(Code)

Given a key, return a service object, and, if actualReturn is not null, the descriptor with which it was found in the first element of actualReturn. If no service object matches this key, return null, and leave actualReturn unchanged.

This queries the cache using the key's descriptor, and if no object in the cache matches it, tries the key on each registered factory, in order. If none generates a service object for the key, repeats the process with each fallback of the key, until either one returns a service object, or the key has no fallback.

If key is null, just returns null.




getKey
public Object getKey(Key key, String[] actualReturn, Factory factory)(Code)



getName
public String getName()(Code)
Return the name of this service. This will be the empty string if none was assigned.



getVisibleIDs
public Set getVisibleIDs()(Code)
Convenience override for getVisibleIDs(String) that passes null as the fallback, thus returning all visible IDs.



getVisibleIDs
public Set getVisibleIDs(String matchID)(Code)

Return a snapshot of the visible IDs for this service. This set will not change as Factories are added or removed, but the supported ids will, so there is no guarantee that all and only the ids in the returned set are visible and supported by the service in subsequent calls.

matchID is passed to createKey to create a key. If the key is not null, it is used to filter out ids that don't have the key as a fallback.




handleDefault
protected Object handleDefault(Key key, String[] actualIDReturn)(Code)
Default handler for this service if no factory in the list handled the key.



isDefault
public boolean isDefault()(Code)
Return true if the service is in its default state. The default implementation returns true if there are no factories registered.



markDefault
protected void markDefault()(Code)
Set the default size to the current number of registered factories. Used by subclasses to customize the behavior of isDefault.



notifyListener
protected void notifyListener(EventListener l)(Code)
Notify the listener, which by default is a ServiceListener. Subclasses can override to use a different listener.



reInitializeFactories
protected void reInitializeFactories()(Code)
Reinitialize the factory list to its default state. By default this clears the list. Subclasses can override to provide other default initialization of the factory list. Subclasses must not call this method directly, as it must only be called while holding write access to the factory list.



registerFactory
final public Factory registerFactory(Factory factory)(Code)
Register a Factory. Returns the factory if the service accepts the factory, otherwise returns null. The default implementation accepts all factories.



registerObject
public Factory registerObject(Object obj, String id)(Code)
A convenience override of registerObject(Object, String, boolean) that defaults visible to true.



registerObject
public Factory registerObject(Object obj, String id, boolean visible)(Code)
Register an object with the provided id. The id will be canonicalized. The canonicalized ID will be returned by getVisibleIDs if visible is true.



reset
final public void reset()(Code)
Reset the service to the default factories. The factory lock is acquired and then reInitializeFactories is called.



stats
public String stats()(Code)
Return a string describing the statistics for this service. This also resets the statistics. Used for debugging purposes.



toString
public String toString()(Code)
Returns the result of super.toString, appending the name in curly braces.



unregisterFactory
final public boolean unregisterFactory(Factory factory)(Code)
Unregister a factory. The first matching registered factory will be removed from the list. Returns true if a matching factory was removed.



Methods inherited from com.ibm.icu.impl.ICUNotifier
abstract protected boolean acceptsListener(EventListener l)(Code)(Java Doc)
public void addListener(EventListener l)(Code)(Java Doc)
public void notifyChanged()(Code)(Java Doc)
abstract protected void notifyListener(EventListener l)(Code)(Java Doc)
public void removeListener(EventListener l)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.