weaver 2003/10/17 12:42:38
Modified: portal/src/java/org/apache/jetspeed/om/impl
DisplayNameSetImpl.java
Log:
- added arg checking to the get method
- If cannot find matching locale, due a lookup using just the language as the key
Revision Changes Path
1.2 +24 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/om/impl/DisplayNameSetImpl.java
Index: DisplayNameSetImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/om/impl/DisplayNameSetImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DisplayNameSetImpl.java 10 Oct 2003 05:12:09 -0000 1.1
+++ DisplayNameSetImpl.java 17 Oct 2003 19:42:38 -0000 1.2
@@ -57,6 +57,7 @@
import java.util.Locale;
import java.util.Map;
+import org.apache.jetspeed.om.common.MutableDisplayName;
import org.apache.jetspeed.om.common.MutableDisplayNameSet;
import org.apache.pluto.om.common.DisplayName;
/**
@@ -71,6 +72,9 @@
private Map nameMap = new HashMap();
+ /** This is a fall back if language only Locales */
+ private Map langMap = new HashMap();
+
/** Specifies the type Description we are storing */
protected String displayNameType;
@@ -85,12 +89,27 @@
*/
public DisplayName get(Locale arg0)
{
+ if (arg0 == null)
+ {
+ throw new IllegalArgumentException("Locale argument cannot be null");
+ }
+
+ Object obj = nameMap.get(arg0);
+ if (obj == null)
+ {
+ obj = langMap.get(arg0.getLanguage());
+ }
- return (DisplayName) nameMap.get(arg0);
+ return (DisplayName) obj;
}
public void addDisplayName(DisplayName name)
{
+ if (name == null)
+ {
+ throw new IllegalArgumentException("DisplayName argument cannot be
null");
+ }
+
add(name);
}
@@ -99,8 +118,10 @@
*/
public boolean add(Object o)
{
- DisplayName name = (DisplayName) o;
+ MutableDisplayName name = (MutableDisplayName) o;
+ name.setType(displayNameType);
nameMap.put(name.getLocale(), name);
+ langMap.put(name.getLocale().getLanguage(), name);
return super.add(o);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]