weaver 2003/10/17 12:41:33
Modified: portal/src/java/org/apache/jetspeed/om/impl
DescriptionSetImpl.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 +18 -4
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/om/impl/DescriptionSetImpl.java
Index: DescriptionSetImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/om/impl/DescriptionSetImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DescriptionSetImpl.java 10 Oct 2003 05:12:09 -0000 1.1
+++ DescriptionSetImpl.java 17 Oct 2003 19:41:33 -0000 1.2
@@ -56,6 +56,7 @@
import java.util.Iterator;
import java.util.Locale;
+import org.apache.jetspeed.om.common.MutableDescription;
import org.apache.jetspeed.om.common.MutableDescriptionSet;
import org.apache.pluto.om.common.Description;
@@ -84,17 +85,29 @@
*/
public Description get(Locale arg0)
{
+ if (arg0 == null)
+ {
+ throw new IllegalArgumentException("The Locale argument cannot be
null");
+ }
+
// TODO: This may cause concurrent modification exceptions
Iterator itr = iterator();
- while( itr.hasNext())
+ Description fallBack = null;
+ while (itr.hasNext())
{
- Description desc = (Description) itr.next();
+ Description desc = (Description) itr.next();
if (desc.getLocale().equals(arg0))
{
return desc;
}
+ // set fall back if we have a Locale that only has
+ // language set.
+ if (desc.getLocale().getLanguage().equals(arg0.getLanguage()))
+ {
+ fallBack = desc;
+ }
}
- return null;
+ return fallBack;
}
/**
@@ -102,6 +115,7 @@
*/
public void addDescription(Description description)
{
+ ((MutableDescription) description).setType(descriptionType);
add(description);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]