org.mmbase.util
Class ReplacingLocalizedString

java.lang.Object
  extended by org.mmbase.util.LocalizedString
      extended by org.mmbase.util.WrappedLocalizedString
          extended by org.mmbase.util.ReplacingLocalizedString
All Implemented Interfaces:
Serializable, Cloneable, PublicCloneable<LocalizedString>

public class ReplacingLocalizedString
extends WrappedLocalizedString

Extends and wraps LocalizedString. It extends to look like a 'normal' LocalizedString, but it overrides 'get' to do token-replacements first. This functionality is not in LocalizedString itself, because now you can have different replacements on the same value set represented by a LocalizedString withouth having to copy everything every time.

Since:
MMBase-1.8
Version:
$Id: ReplacingLocalizedString.java 41036 2010-02-15 22:30:54Z michiel $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mmbase.util.WrappedLocalizedString
wrapped
 
Constructor Summary
ReplacingLocalizedString(LocalizedString s)
           
 
Method Summary
 Map<Locale,String> asMap()
          Returns a Map representation of the localisation setting represented by this LocalizedString.
 ReplacingLocalizedString clone()
           
 String get(Locale locale)
          Gets the value for a certain locale.
static void main(String[] argv)
           
static String makeLiteral(String s)
          Utility method for second argument of replaceAll
protected  String replace(String input)
           
 void replaceAll(String regexp, String replacement)
           
 
Methods inherited from class org.mmbase.util.WrappedLocalizedString
equals, getBundle, getKey, getReadonlyLocalizedString, getValues, hashCode, set, setBundle, setKey
 
Methods inherited from class org.mmbase.util.LocalizedString
degrade, degrade, fillFromXml, getDebugString, getDefault, getLocale, getLocale, getXmlLang, setDefault, setXmlLang, toString, toStrings, toXml
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReplacingLocalizedString

public ReplacingLocalizedString(LocalizedString s)
Parameters:
s - The wrapped LocalizedString.
Method Detail

replaceAll

public void replaceAll(String regexp,
                       String replacement)

replace

protected String replace(String input)

get

public String get(Locale locale)
Description copied from class: LocalizedString
Gets the value for a certain locale. If no match is found, it falls back to the key.

Overrides:
get in class WrappedLocalizedString

asMap

public Map<Locale,String> asMap()
Returns a Map representation of the localisation setting represented by this LocalizedString. It is an unmodifiable mapping: Locale -> localized value. Also takes into account the replacements in the values (but only 'lazily', when actually requested).

Overrides:
asMap in class WrappedLocalizedString

clone

public ReplacingLocalizedString clone()
Specified by:
clone in interface PublicCloneable<LocalizedString>
Overrides:
clone in class LocalizedString

makeLiteral

public static String makeLiteral(String s)
Utility method for second argument of replaceAll


main

public static void main(String[] argv)


MMBase 2.0-SNAPSHOT - null