org.mmbase.util
Class ReplacingLocalizedString

java.lang.Object
  extended byorg.mmbase.util.LocalizedString
      extended byorg.mmbase.util.ReplacingLocalizedString
All Implemented Interfaces:
Cloneable, Serializable

public class ReplacingLocalizedString
extends LocalizedString

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,v 1.4 2005/10/21 16:46:11 michiel Exp $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

Constructor Summary
protected ReplacingLocalizedString()
           
  ReplacingLocalizedString(LocalizedString s)
           
 
Method Summary
 Map 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).
 Object clone()
           
 String get(Locale locale)
          Gets the value for a certain locale.
 String getKey()
          Gets the key to use as a default and/or for obtaining a value from the bundle
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)
           
 void set(String value, Locale locale)
          Sets the value for a certain locale.
 void setBundle(String b)
          A resource-bundle with given name can be associated to this LocalizedString.
 void setKey(String key)
          Sets the key to use as a default and/or for obtaining a value from the bundle
 String toString()
           For LocalizedString this returns the String for the default Locale (see LocalizedString.getDefault()). For LocalizedString this returns the String for the default Locale (see LocalizedString.getDefault()).
 
Methods inherited from class org.mmbase.util.LocalizedString
equals, fillFromXml, getDefault, getLocale, getLocale, getXmlLang, hashCode, setDefault, setXmlLang, toStrings, toXml
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReplacingLocalizedString

protected ReplacingLocalizedString()

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)

getKey

public String getKey()
Description copied from class: LocalizedString
Gets the key to use as a default and/or for obtaining a value from the bundle

Overrides:
getKey in class LocalizedString

setKey

public void setKey(String key)
Description copied from class: LocalizedString
Sets the key to use as a default and/or for obtaining a value from the bundle

Overrides:
setKey in class LocalizedString

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 LocalizedString

set

public void set(String value,
                Locale locale)
Description copied from class: LocalizedString
Sets the value for a certain locale. If the value for a more general locale is still unset, it will also set that (so, it sets also nl when setting nl_BE if nl still is unset).

Overrides:
set in class LocalizedString

asMap

public Map 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 LocalizedString

setBundle

public void setBundle(String b)
Description copied from class: LocalizedString
A resource-bundle with given name can be associated to this LocalizedString. If no translations were explicitely added, it can be used to look up the translation in the bundle, using the key.

Overrides:
setBundle in class LocalizedString

toString

public String toString()
Description copied from class: LocalizedString
For LocalizedString this returns the String for the default Locale (see LocalizedString.getDefault()).

Overrides:
toString in class LocalizedString

clone

public Object clone()
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 build 1.8.1.20060716