org.mmbase.util
Class LocalizedEntryListFactory<C>

java.lang.Object
  extended by org.mmbase.util.LocalizedEntryListFactory<C>
All Implemented Interfaces:
Serializable, Cloneable

public class LocalizedEntryListFactory<C>
extends Object
implements Serializable, Cloneable

These factories can produce Collections based on a Locale (The get(java.util.Locale) method is essential). The other methods besides get are methods to define these lists. There are two ways to add entries to the produced collections. The first one is to explicitely add them, using the add(java.util.Locale, java.io.Serializable, java.io.Serializable) method. This gives precise control, and the collections can have different orders for different languages. The size of the collections are always the same, so if for a certain locale less entries are added, these are completed with the unused keys. If for a certain locale no entries are added, it will behave itself like as the default locale of LocalizedString.getDefault(). It is also possible to add entire 'bundles'. For this use addBundle(java.lang.String, java.lang.ClassLoader, java.lang.Class, java.lang.Class, java.util.Comparator). When a Collection instance for a certain Locale is requested these informations are used to call SortedBundle.getResource(java.lang.String, java.util.Locale, java.lang.ClassLoader, java.util.Map, java.lang.Class, java.util.Comparator). It is possible to mix both methods, so having an enumeration partially defined by a bundle, partially by explicit values, though this is not recommended.

Since:
MMBase-1.8
Version:
$Id: LocalizedEntryListFactory.java 42607 2010-06-18 14:33:37Z michiel $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

Constructor Summary
LocalizedEntryListFactory()
           
 
Method Summary
protected  List<Serializable> add(Locale locale, Object entry)
          Add entry to 'localized'
 Map.Entry<Serializable,Serializable> add(Locale locale, Serializable key, Serializable value)
          Adds a value for a certain key and Locale
 void addBundle(String baseName, ClassLoader classLoader, Class constantsProvider, Class wrapper, Comparator comparator)
          Adds a bundle, to the (current) end of all maintained collections.
 void addQuery(Locale locale, Document queryElement)
           
 Object castKey(Object key)
           
 Object castKey(Object key, Cloud cloud)
          Since keys may be somehow wrapped, you can also 'unwrap' by this.
 Object castKeyOrException(Object key, Cloud cloud)
           
 void clear()
          Clears all added keys, bundles and queries.
 Object clone()
           
 void fillFromXml(Element enumerationElement, Class wrapperDefault)
          Given a certain DOM parent element, it configures this LocalizedEntryListFactory with sub tags of type 'entry' and 'query'
 List<Map.Entry<C,String>> get(Locale locale)
          Defaulting version of get(Locale, Cloud).
 List<Map.Entry<C,String>> get(Locale locale, Cloud cloud)
          Returns a Collection of Map.Entries for the given Locale.
 List<Map.Entry<C,String>> get(Locale locale, Cloud c, Node node, Field field)
           
protected  Cloud getCloud(Locale locale)
           
 boolean isEmpty()
           
 int size()
           
 int size(Cloud cloud)
          The size of the collections returned by get(java.util.Locale)
 String toString()
           
 Element toXml()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalizedEntryListFactory

public LocalizedEntryListFactory()
Method Detail

isEmpty

public boolean isEmpty()

add

public Map.Entry<Serializable,Serializable> add(Locale locale,
                                                Serializable key,
                                                Serializable value)
Adds a value for a certain key and Locale

Returns:
The created Map.Entry.

add

protected List<Serializable> add(Locale locale,
                                 Object entry)
Add entry to 'localized'

Parameters:
entry - the object, which has not Locale support of itself (Entry, DocumentSerializable)
locale - Can be null too, in which case the default locale is used
Returns:
List of currently unused keys for this locale.

addBundle

public void addBundle(String baseName,
                      ClassLoader classLoader,
                      Class constantsProvider,
                      Class wrapper,
                      Comparator comparator)
Adds a bundle, to the (current) end of all maintained collections. Actually, only the definition of the bundle is added, it is instantiated only later, when requested for a specific locale.


addQuery

public void addQuery(Locale locale,
                     Document queryElement)

get

public List<Map.Entry<C,String>> get(Locale locale)
Defaulting version of get(Locale, Cloud). Using default anonymous cloud.


getCloud

protected Cloud getCloud(Locale locale)

get

public List<Map.Entry<C,String>> get(Locale locale,
                                     Cloud c,
                                     Node node,
                                     Field field)
Since:
MMBase-1.9.1

get

public List<Map.Entry<C,String>> get(Locale locale,
                                     Cloud cloud)
Returns a Collection of Map.Entries for the given Locale. The collection is kind of 'virtual', it only reflects the underlying memory structures. This collection does have a well defined iteration order.

Parameters:
locale - The locale of null for the default locale.
cloud - The cloud to use. Can be null if no queries added (see addQuery(java.util.Locale, org.w3c.dom.Document)). If Locale is null, but cloud isn't, the locale of the cloud is used.

size

public int size(Cloud cloud)
The size of the collections returned by get(java.util.Locale)


size

public int size()

castKey

public Object castKey(Object key)

castKey

public Object castKey(Object key,
                      Cloud cloud)
Since keys may be somehow wrapped, you can also 'unwrap' by this. If e.g. a constants provider was used, that values can be indicated by the name of the constants and this method casts to the value.


castKeyOrException

public Object castKeyOrException(Object key,
                                 Cloud cloud)
                          throws IllegalArgumentException
Throws:
IllegalArgumentException
Since:
MMBase-2.0

clone

public Object clone()
Overrides:
clone in class Object

clear

public void clear()
Clears all added keys, bundles and queries.


fillFromXml

public void fillFromXml(Element enumerationElement,
                        Class wrapperDefault)
Given a certain DOM parent element, it configures this LocalizedEntryListFactory with sub tags of type 'entry' and 'query'


toXml

public Element toXml()

toString

public String toString()
Overrides:
toString in class Object


MMBase 2.0-SNAPSHOT - null