Java Doc for LocalizedString.java in  » Database-ORM » MMBase » org » mmbase » util » 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 » Database ORM » MMBase » org.mmbase.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mmbase.util.LocalizedString

All known Subclasses:   org.mmbase.util.WrappedLocalizedString,
LocalizedString
public class LocalizedString implements java.io.Serializable,Cloneable(Code)

A String which is localized. There are two mechanisms to find and provide translations: They can explicitely be set with LocalizedString.set (e.g. during parsing an XML), or a resource-bundle can be associated with LocalizedString.setBundle , which will be used to find translations based on the key of this object.

The 'set' mechanism can also be driven by LocalizedString.fillFromXml , which provides a sensible way to fill the LocalizedString with setting from a sub element of XMLs.

The idea is that objects of this type can be used in stead of normal String objects, for error messages, descriptions and other texts which need localization (e.g. because they are exposed to end-users).


author:
   Michiel Meeuwissen
version:
   $Id: LocalizedString.java,v 1.31 2007/05/23 13:19:59 michiel Exp $
since:
   MMBase-1.8



Constructor Summary
protected  LocalizedString()
    
public  LocalizedString(String k)
    

Method Summary
public  Map<Locale, String>asMap()
     Returns a Map representation of the localisation setting represented by this LocalizedString.
public  Objectclone()
    
public static  Localedegrade(Locale locale, Locale originalLocale)
     Degrades a Locale object to a more general Locale.
public  booleanequals(Object o)
    
public  voidfillFromXml(String tagName, Element element)
     Given a certain tagname, and a DOM parent element, it configures this LocalizedString, using subtags with this tagname with 'xml:lang' attributes.
public  Stringget(Locale locale)
     Gets the value for a certain locale.
public static  LocalegetDefault()
     Returns the default locale if set, or otherwise the system default ( java.util.Locale.getDefault ).
public  StringgetKey()
    
public static  LocalegetLocale(Element element)
    
public static  LocalegetLocale(String xmlLang)
    
public static  StringgetXmlLang(Locale locale)
     This utility determines the value of an xml:lang attribute.
public  inthashCode()
    
public  voidset(String value, Locale locale)
     Sets the value for a certain locale.
public  voidsetBundle(String b)
     A resource-bundle with given name can be associated to this LocalizedString.
public static  LocalesetDefault(Locale locale)
     Sets a default locale for this JVM or web-app.
public  voidsetKey(String key)
    
public static  voidsetXmlLang(Element element, Locale locale)
     This utility takes care of setting the xml:lang attribute on an element.
public  StringtoString()
     For LocalizedString this returns the String for the default Locale (see LocalizedString.getDefault ).
public static  Collection<String>toStrings(Collection<LocalizedString> col, Locale locale)
     Converts a collection of localized strings to a collection of normal strings.
public  voidtoXml(String tagName, String ns, Element element, String path)
     Writes this LocalizedString object back to an XML, i.e.


Constructor Detail
LocalizedString
protected LocalizedString()(Code)



LocalizedString
public LocalizedString(String k)(Code)

Parameters:
  k - The key of this String, if k == null then the first set will define it.




Method Detail
asMap
public Map<Locale, String> asMap()(Code)
Returns a Map representation of the localisation setting represented by this LocalizedString. It is an unmodifiable mapping: Locale -> localized value.



clone
public Object clone()(Code)



degrade
public static Locale degrade(Locale locale, Locale originalLocale)(Code)
Degrades a Locale object to a more general Locale. Principally this means that first the 'variant' will be dropped and then the country. As an extra the 'variant' is also degraded progressively. This is done by taking away parts (from the end) which are separated by underscore characters. Also, after degrading the country, also locales are tried with no country, but with a variant only. So e.g. nl_BE_a_b is degraded to nl_BE_a, then nl_BE, then nl__a_b, then nl__a, then nl.
Parameters:
  locale - The locale to be degraded
Parameters:
  originalLocale - The original locale (used to find back the original variant afterdropping the country) A degraded Locale of null if the locale could not be degraded any further.
since:
   MMBase-1.8.5



equals
public boolean equals(Object o)(Code)



fillFromXml
public void fillFromXml(String tagName, Element element)(Code)
Given a certain tagname, and a DOM parent element, it configures this LocalizedString, using subtags with this tagname with 'xml:lang' attributes. This boils down to repeative calls to LocalizedString.set(String,Locale) .



get
public String get(Locale locale)(Code)
Gets the value for a certain locale. If no match is found, it falls back to the key.



getDefault
public static Locale getDefault()(Code)
Returns the default locale if set, or otherwise the system default ( java.util.Locale.getDefault ).



getKey
public String getKey()(Code)
Gets the key to use as a default and/or for obtaining a value from the bundle



getLocale
public static Locale getLocale(Element element)(Code)
This utility takes care of reading the xml:lang attribute from an element
Parameters:
  element - a DOM element A java.util.Locale object, or null if the element did not have,or had an empty, xml:lang attribute



getLocale
public static Locale getLocale(String xmlLang)(Code)

since:
   MMBase-1.8.1



getXmlLang
public static String getXmlLang(Locale locale)(Code)
This utility determines the value of an xml:lang attribute. So, given a java.util.Locale it produces a String.
Parameters:
  locale - A java locale A string that can be used as the value for an XML xml:lang attribute.
since:
   MMBase-1.8.1



hashCode
public int hashCode()(Code)



set
public void set(String value, Locale locale)(Code)
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).



setBundle
public void setBundle(String b)(Code)
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.



setDefault
public static Locale setDefault(Locale locale)(Code)
Sets a default locale for this JVM or web-app. When not using it, the locale is the system default. Several web-apps do run in one JVM however and it is very imaginable that you want a different default for the Locale. So, this function can be called only once. Calling it the second time will not do anything. It returns the already set default locale then, which should probably prompt you to log an error or throw an exception or so. Otherwise it returns null indicating that the default locale is now what you just set.



setKey
public void setKey(String key)(Code)
Sets the key to use as a default and/or for obtaining a value from the bundle



setXmlLang
public static void setXmlLang(Element element, Locale locale)(Code)
This utility takes care of setting the xml:lang attribute on an element.
Parameters:
  element - Element on which the xml:lang attribute is going to be set
Parameters:
  locale - Java's Locale object
since:
   MMBase-1.8.1



toString
public String toString()(Code)
For LocalizedString this returns the String for the default Locale (see LocalizedString.getDefault ).



toStrings
public static Collection<String> toStrings(Collection<LocalizedString> col, Locale locale)(Code)
Converts a collection of localized strings to a collection of normal strings.
Parameters:
  col - Collection of LocalizedString objects
Parameters:
  locale - Locale to be used for the call to LocalizedString.get(Locale) which obviously is needed



toXml
public void toXml(String tagName, String ns, Element element, String path)(Code)
Writes this LocalizedString object back to an XML, i.e. it searches for and creates sub-elements (identified by xml:lang attributes) of a certain given parent element, and sets the node-text-value of those elements corresponding to the locale.
Parameters:
  tagName - Tag-name of the to be used sub-elements
Parameters:
  ns - Namespace of the to be created sub-elements, or null
Parameters:
  element - The parent element which must contain the localized elements.
Parameters:
  path - A comma separated list of names of tags which must skipped, before appendingchilds. See org.mmbase.util.xml.DocumentReader.appendChild(ElementElementString).
since:
   MMBase-1.8.1



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.