portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference UserPreferencesImpl.java UserPreferenceValueImpl.java PreferenceValue.java AbstractPreferenceImpl.java UserPreference.java PreferenceSetImpl.java PreferenceImpl.java PreferenceValueImpl.java AbstractPreferenceValue.java PreferenceSetComposite.java PreferenceComposite.java
Date Sun, 03 Aug 2003 14:52:04 GMT
weaver      2003/08/03 07:52:04

  Added:       commons/src/java/org/apache/jetspeed/om/common/preference
                        UserPreferencesImpl.java
                        UserPreferenceValueImpl.java PreferenceValue.java
                        AbstractPreferenceImpl.java UserPreference.java
                        PreferenceSetImpl.java PreferenceImpl.java
                        PreferenceValueImpl.java
                        AbstractPreferenceValue.java
                        PreferenceSetComposite.java
                        PreferenceComposite.java
  Log:
  Refactored preferences into their own package
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/UserPreferencesImpl.java
  
  Index: UserPreferencesImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  import java.util.HashSet;
  import java.util.Set;
  
  import org.apache.pluto.om.common.Preference;
  
  /**
   * UserPreferencesImpl
   * <br/>
   * This is a concrete implentation of the <code>javax.portlet.PortletPreferencesObject</code>
   * <br/>
   * You should use this object to read and write user preferences for portlets
   * back to the container. 
   * 
   * @see javax.portlet.PortletPreferencesObject
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: UserPreferencesImpl.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public class UserPreferencesImpl extends PreferenceSetImpl implements PreferenceSetComposite
  {
      private static final String NULL_KEY_MSG = "The preference \"key\" argument cannot be
null";
  
      private PreferenceSetComposite defaultPreferences;
      /**
       * Creates an instance of UserPreferencesImpl using the
       * the PreferenceSet from the registry that matches with the portlet
       * this UserPreferencesImpl is associated with.   The PreferenceSet
       * IS NEVER modified by this UserPreferencesImpl, it is just used
       * as guide for a users PortletPreferences.
       * 
       * @param prefSet PreferenceSet from the registry that will be used as a
       * base for the PortletPreferenceImpl.
       */
      public UserPreferencesImpl(PreferenceSetComposite defaultPreferences)
      {
          this();
          this.defaultPreferences = defaultPreferences;
      }
  
      public UserPreferencesImpl()
      {
          super();
      }
  
      /**
       * 
       * @param defaultPreferences
       */
      public void setDefaultPreferences(PreferenceSetComposite defaultPreferences)
      {
          this.defaultPreferences = defaultPreferences;
      }
  
      /**
       *  
       * <p>
       * get
       * </p>
       * 
       * @see org.apache.pluto.om.common.PreferenceSet#get(java.lang.String)
       * @param name
       * @return
       */
      public Preference get(String name)
      {
  
          Preference pref = super.get(name);
  
          // Use default
          if (pref == null)
          {
              pref = defaultPreferences.get(name);
          }
  
          return pref;
      }
  
      /** 
       * <p>
       * getPreferenceNames
       * </p>
       * 
       * @see org.apache.jetspeed.om.common.preference.PreferenceSetComposite#getPreferenceNames()
       * @return
       */
      public Set getNames()
      {
          Set names = super.getNames();
        
          names.addAll(defaultPreferences.getNames());
  
          return names;
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/UserPreferenceValueImpl.java
  
  Index: UserPreferenceValueImpl.java
  ===================================================================
  /**
   * Created on Jul 29, 2003
   *
   * 
   * @author
   */
  package org.apache.jetspeed.om.common.preference;
  
  
  /**
   * UserPreferenceValueImpl
   * <br/>
   * PreferenceValue implementation that should be used interanlly
   * to manage user PreferenceValues.
   * 
   * @see AbstractPreferenceValue
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: UserPreferenceValueImpl.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public class UserPreferenceValueImpl extends AbstractPreferenceValue
  {
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/PreferenceValue.java
  
  Index: PreferenceValue.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  /**
   * PreferenceValue
   * <br />
   * Represents an individual value for a preference which could
   * either be the default preferences from a portlet's deployment descriptor
   * or a preference value for a specific user.  This class should only be
   * accessed by Jetspeed internals as Preference values are really
   * only String values.  The use of preference value objects helps
   * facilitate the use object relational tools in terms of persistence operations. 
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: PreferenceValue.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public interface PreferenceValue
  {
      /**
       * @return
       */
      public abstract String getValue();
      /**
       * @param string
       */
      public abstract void setValue(String string);   
      
  }
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/AbstractPreferenceImpl.java
  
  Index: AbstractPreferenceImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.om.common.preference;
  
  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.om.common.DescriptionImpl;
  import org.apache.jetspeed.om.common.DescriptionSetImpl;
  import org.apache.jetspeed.om.common.MutableDescription;
  import org.apache.jetspeed.om.common.MutableDescriptionSet;
  import org.apache.jetspeed.util.HashCodeBuilder;
  import org.apache.pluto.om.common.Description;
  import org.apache.pluto.om.common.Preference;
  
  /**
   * 
   * <p>
   * AbstractPreferenceImpl
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: AbstractPreferenceImpl.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public abstract class  AbstractPreferenceImpl implements PreferenceComposite, Serializable
  {
      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 AbstractPreferenceImpl()
      {
          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;
      }
  
      /**
       * @see org.apache.jetspeed.om.common.PreferenceComposite#getValueAt(int)
       */
      public String getValueAt(int index)
      {
          return getValueArray()[index];
      }
  
      /**
       * @see org.apache.jetspeed.om.common.PreferenceComposite#getValueArray()
       */
      public String[] getValueArray()
      {
          if (valueObjects != null)
          {
              return (String[]) valueObjects.toArray(new String[valueObjects.size()]);
          }
  
          return null;
      }
  
      /**
       * @see org.apache.jetspeed.om.common.PreferenceComposite#setValueAt(int, java.lang.String)
       */
      public void setValueAt(int index, String value)
      {
          if (valueObjects == null)
          {
              valueObjects = new ArrayList();
          }
          
          valueObjects.set(index, value);
  
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/UserPreference.java
  
  Index: UserPreference.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  
  /**
   * <p>
   * PortletPreference
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: UserPreference.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public class UserPreference extends AbstractPreferenceImpl
  {
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/PreferenceSetImpl.java
  
  Index: PreferenceSetImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.om.common.preference;
  
  import java.io.Serializable;
  import java.util.Collection;
  import java.util.HashMap;
  
  import java.util.Set;
  
  import org.apache.jetspeed.om.common.AbstractSupportSet;
  import org.apache.pluto.om.common.Preference;
  
  /**
   * 
   * PreferenceSetImpl
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: PreferenceSetImpl.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public class PreferenceSetImpl extends AbstractSupportSet implements PreferenceSetComposite,
Serializable
  {
  
      protected HashMap prefMap = new HashMap();
  
      /**
       * @param wrappedSet
       */
      public PreferenceSetImpl(Set wrappedSet)
      {
          super(wrappedSet);
      }
  
      public PreferenceSetImpl()
      {
          prefMap = new HashMap();
      }
  
      /**
       * @see org.apache.pluto.om.common.PreferenceSet#get(java.lang.String)
       */
      public Preference get(String name)
      {
          return (Preference) prefMap.get(name);
      }
  
      /**
       * @see org.apache.pluto.om.common.PreferenceSetCtrl#add(java.lang.String, java.util.Collection)
       */
      public Preference add(String name, Collection values)
      {
          PreferenceImpl pref = new PreferenceImpl();
          pref.setName(name);
          pref.setValues(values);
          add(pref);
          return pref;
      }
  
      /**
       * @see org.apache.pluto.om.common.PreferenceSetCtrl#remove(java.lang.String)
       */
      public Preference remove(String name)
      {
          Preference pref = (Preference) prefMap.get(name);
          remove(pref);
          return pref;
      }
  
      /**
       * @see org.apache.pluto.om.common.PreferenceSetCtrl#remove(org.apache.pluto.om.common.Preference)
       */
      public void remove(Preference preference)
      {
          remove((Object) preference);
      }
  
      /**
       * @see java.util.Collection#add(java.lang.Object)
       */
      public boolean add(Object o)
      {
          Preference pref = (Preference) o;
          prefMap.put(pref.getName(), pref);
          return super.add(pref);
      }
  
      /**
       * @see java.util.Collection#remove(java.lang.Object)
       */
      public boolean remove(Object o)
      {
          Preference pref = (Preference) o;
          prefMap.remove(pref.getName());
          return super.remove(o);
      }
  
      public Set getNames()
      {
          return prefMap.keySet();
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/PreferenceImpl.java
  
  Index: PreferenceImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  /**
   * 
   * PreferenceImpl
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: PreferenceImpl.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public class PreferenceImpl extends AbstractPreferenceImpl
  {
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/PreferenceValueImpl.java
  
  Index: PreferenceValueImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  import java.io.Serializable;
  
  /**
   * 
   * PreferenceValueImpl
   * <br />
   * Represents preference values associated the preferences
   * specified within the registry.
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: PreferenceValueImpl.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public class PreferenceValueImpl extends AbstractPreferenceValue implements Serializable,
PreferenceValue
  {
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/AbstractPreferenceValue.java
  
  Index: AbstractPreferenceValue.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  
  
  
  /**
   * 
   * PreferenceValueObject
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: AbstractPreferenceValue.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public abstract class AbstractPreferenceValue implements Serializable, PreferenceValue
  {
      private long preferenceId;
      private long id;
      private String value;
  
      /**
       * @return
       */
      public String getValue()
      {
          return value;
      }
  
      /**
       * @param string
       */
      public void setValue(String string)
      {
          value = string;
      }
  
      /**
       * @return same as <code>getValue()</code>
       */
      public String toString()
      {
          return getValue();
      }
  
      protected final static ArrayList convertValueObjectsToStrings(Collection valueObjs)
      {
          ArrayList values = new ArrayList(valueObjs.size());
          Iterator itr = valueObjs.iterator();
          while (itr.hasNext())
          {
              values.add(itr.next().toString());
          }
  
          return values;
      }
  
      protected final static void convertStringsToValueObjects(Collection stringValues, List
valueObjects, Class valueClass)
      {
          if (valueObjects == null)        
          {
              valueObjects = new ArrayList(stringValues.size());
          }
  
          Iterator itr = stringValues.iterator();
          int count = 0;
          try
          {
              while (itr.hasNext())
              {
                  String strValue = (String) itr.next();
                  if (valueObjects.size() > count)
                  {
                      AbstractPreferenceValue valueObj = (AbstractPreferenceValue) valueObjects.get(count);
                      valueObj.setValue(strValue);
                  }
                  else
                  {
  
                      AbstractPreferenceValue valueObj = (AbstractPreferenceValue) valueClass.newInstance();
                      valueObj.setValue(strValue);
                      valueObjects.add(valueObj);
                  }
                  count++;
              }
          }
          catch (Exception e)
          {
              throw new RuntimeException("Unable to instantiate value class.", e);
          }
  
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/PreferenceSetComposite.java
  
  Index: PreferenceSetComposite.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.om.common.preference;
  
  import java.util.Set;
  
  import org.apache.pluto.om.common.PreferenceSet;
  import org.apache.pluto.om.common.PreferenceSetCtrl;
  
  /**
   * <p>
   * PreferenceSetComposite
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: PreferenceSetComposite.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  public interface PreferenceSetComposite extends PreferenceSet, PreferenceSetCtrl
  {
      Set getNames();
      
      int size();
  }
  
  
  
  1.1                  jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/om/common/preference/PreferenceComposite.java
  
  Index: PreferenceComposite.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.om.common.preference;
  
  import java.io.Serializable;
  import java.util.Locale;
  
  import org.apache.pluto.om.common.Description;
  import org.apache.pluto.om.common.Preference;
  import org.apache.pluto.om.common.PreferenceCtrl;
  
  /**
   * 
   * PreferenceComposite
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: PreferenceComposite.java,v 1.1 2003/08/03 14:52:04 weaver Exp $
   *
   */
  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();
      
      
  
  }
  
  
  

Mime
View raw message