weaver 2003/08/01 13:03:37 Modified: commons/src/java/org/apache/jetspeed/om/common PreferenceSetImpl.java PreferenceValue.java PreferenceImpl.java PreferenceComposite.java PreferenceSetComposite.java Log: Added convenience methods Revision Changes Path 1.2 +7 -3 jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceSetImpl.java Index: PreferenceSetImpl.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceSetImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PreferenceSetImpl.java 30 Jul 2003 18:30:15 -0000 1.1 +++ PreferenceSetImpl.java 1 Aug 2003 20:03:37 -0000 1.2 @@ -62,7 +62,6 @@ import org.apache.pluto.om.common.Preference; - /** * * PreferenceSetImpl @@ -74,7 +73,7 @@ public class PreferenceSetImpl extends AbstractSupportSet implements PreferenceSetComposite, Serializable { - private HashMap prefMap = new HashMap(); + protected HashMap prefMap = new HashMap(); /** * @param wrappedSet @@ -145,6 +144,11 @@ Preference pref = (Preference) o; prefMap.remove(pref.getName()); return super.remove(o); + } + + public Set getPreferenceNames() + { + return prefMap.keySet(); } } 1.2 +3 -2 jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceValue.java Index: PreferenceValue.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceValue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PreferenceValue.java 30 Jul 2003 18:30:15 -0000 1.1 +++ PreferenceValue.java 1 Aug 2003 20:03:37 -0000 1.2 @@ -76,5 +76,6 @@ /** * @param string */ - public abstract void setValue(String string); + public abstract void setValue(String string); + } 1.2 +2 -167 jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceImpl.java Index: PreferenceImpl.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PreferenceImpl.java 30 Jul 2003 18:30:15 -0000 1.1 +++ PreferenceImpl.java 1 Aug 2003 20:03:37 -0000 1.2 @@ -51,20 +51,8 @@ * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ - package org.apache.jetspeed.om.common; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; - -import org.apache.jetspeed.util.HashCodeBuilder; -import org.apache.pluto.om.common.Description; -import org.apache.pluto.om.common.Preference; - /** * * PreferenceImpl @@ -73,160 +61,7 @@ * @version $Id$ * */ -public class PreferenceImpl implements PreferenceComposite, Serializable +public class PreferenceImpl extends AbstractPreferenceImpl { - private String name; - protected Collection values; - private boolean modifiable; - /** a collection of <code>PreferenceValueObjects</code> - * that can be persisted in a unique fashion. - */ - private List valueObjects; - - /** Localized Descriptions */ - private MutableDescriptionSet descriptions; - - /** Unique key for O/R tools*/ - protected long id; - - /** FK to parent portlet */ - protected long portletId; - - public PreferenceImpl() - { - values = new ArrayList(); - } - - /** - * @see org.apache.pluto.om.common.Preference#getName() - */ - public String getName() - { - return name; - } - - /** - * @see org.apache.pluto.om.common.Preference#getValues() - */ - public Iterator getValues() - { - if (values == null) - { - values = AbstractPreferenceValue.convertValueObjectsToStrings(this.valueObjects); - } - return values.iterator(); - } - - /** - * @see org.apache.pluto.om.common.Preference#isModifiable() - */ - public boolean isModifiable() - { - return modifiable; - } - - /** - * @see org.apache.pluto.om.common.PreferenceCtrl#setName(java.lang.String) - */ - public void setName(String name) - { - this.name = name; - } - - /** - * @see org.apache.pluto.om.common.PreferenceCtrl#setValues(java.util.Collection) - */ - public void setValues(Collection values) - { - this.values = values; - AbstractPreferenceValue.convertStringsToValueObjects(values, valueObjects, PreferenceValueImpl.class); - } - - /** - * @see org.apache.pluto.om.common.PreferenceCtrl#setDescription(java.lang.String) - */ - public void setDescription(String description) - { - // TODO: Is this still needed as we are using localized text??? - //this.description = description; - if (descriptions == null) - { - descriptions = new DescriptionSetImpl(MutableDescription.TYPE_PREFERENCE); - } - - descriptions.addDescription(new DescriptionImpl(Locale.getDefault(), description, MutableDescription.TYPE_PREFERENCE)); - } - - /** - * @see org.apache.pluto.om.common.PreferenceCtrl#setModifiable(boolean) - */ - public void setModifiable(boolean modifiable) - { - this.modifiable = modifiable; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Preference) - { - Preference pref = (Preference) obj; - return pref.getName().equals(this.getName()); - } - - return false; - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - HashCodeBuilder hasher = new HashCodeBuilder(23, 83); - hasher.append(name); - return hasher.toHashCode(); - } - - /** - * @see org.apache.jetspeed.om.common.PreferenceComposite#addDescription(java.util.Locale, java.lang.String) - */ - public void addDescription(Locale locale, String description) - { - if (descriptions == null) - { - descriptions = new DescriptionSetImpl(MutableDescription.TYPE_PREFERENCE); - } - descriptions.addDescription(new DescriptionImpl(locale, description, MutableDescription.TYPE_PREFERENCE)); - } - - /** - * @see org.apache.jetspeed.om.common.PreferenceComposite#getDescription(java.util.Locale) - */ - public Description getDescription(Locale locale) - { - if (descriptions != null) - { - return descriptions.get(locale); - } - return null; - } - - /** - * Remove when Castor is properly mapped - * @deprecated - * @return - */ - public String getDescription() - { - Description desc = getDescription(Locale.getDefault()); - if (desc != null) - { - return desc.getDescription(); - } - - return null; - } } 1.2 +20 -2 jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceComposite.java Index: PreferenceComposite.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceComposite.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PreferenceComposite.java 28 Jul 2003 23:46:40 -0000 1.1 +++ PreferenceComposite.java 1 Aug 2003 20:03:37 -0000 1.2 @@ -72,7 +72,25 @@ public interface PreferenceComposite extends PreferenceCtrl, Preference, Serializable { void addDescription(Locale locale, String Description); - + Description getDescription(Locale locale); + + /** + * @throws java.lang.ArrayIndexOutofBounds if index is outside the constraints + * @param index + * @return The String value at the specified index or <code>null</code> + * if no values are present. + */ + String getValueAt(int index); + + void setValueAt(int index, String value); + + /** + * + * @return + */ + String[] getValueArray(); + + } 1.2 +4 -2 jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceSetComposite.java Index: PreferenceSetComposite.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/PreferenceSetComposite.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PreferenceSetComposite.java 30 Jul 2003 18:30:15 -0000 1.1 +++ PreferenceSetComposite.java 1 Aug 2003 20:03:37 -0000 1.2 @@ -53,6 +53,8 @@ */ package org.apache.jetspeed.om.common; +import java.util.Set; + import org.apache.pluto.om.common.PreferenceSet; import org.apache.pluto.om.common.PreferenceSetCtrl; @@ -67,5 +69,5 @@ */ public interface PreferenceSetComposite extends PreferenceSet, PreferenceSetCtrl { - + Set getPreferenceNames(); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]