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/services/registry/src/java/org/apache/jetspeed/om/impl DisplayNameSetImpl.java DisplayNameImpl.java DescriptionSetImpl.java LanguageSetImpl.java DescriptionImpl.java
Date Wed, 04 Feb 2004 21:12:10 GMT
weaver      2004/02/04 13:12:10

  Modified:    services/registry/src/java/org/apache/jetspeed/om/impl
                        DisplayNameSetImpl.java DisplayNameImpl.java
                        DescriptionSetImpl.java LanguageSetImpl.java
                        DescriptionImpl.java
  Log:
  - refactored to support the new non-OJB collections
  
  Revision  Changes    Path
  1.2       +62 -27    jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/DisplayNameSetImpl.java
  
  Index: DisplayNameSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/services/registry/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	12 Jan 2004 06:19:51 -0000	1.1
  +++ DisplayNameSetImpl.java	4 Feb 2004 21:12:10 -0000	1.2
  @@ -53,9 +53,10 @@
    */
   package org.apache.jetspeed.om.impl;
   
  -import java.util.HashMap;
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.Iterator;
   import java.util.Locale;
  -import java.util.Map;
   
   import org.apache.jetspeed.om.common.MutableDisplayName;
   import org.apache.jetspeed.om.common.MutableDisplayNameSet;
  @@ -67,40 +68,52 @@
    * @version $Id$
    *
    */
  -public class DisplayNameSetImpl extends AbstractSupportSet implements MutableDisplayNameSet
  +public class DisplayNameSetImpl  implements MutableDisplayNameSet
   {
   
  -    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;
  +    
  +	protected Collection innerCollection;
  +
   
  -    public DisplayNameSetImpl(String type)
  +
  +
  +    public DisplayNameSetImpl()
       {
  -        super();
  -        this.displayNameType = type;
  +        super();        
  +        this.innerCollection = new ArrayList();
       }
  +    
  +	public DisplayNameSetImpl(Collection collection)
  +	{
  +		super();		
  +		this.innerCollection = collection;
  +	}
   
       /**
        * @see org.apache.pluto.om.common.DisplayNameSet#get(java.util.Locale)
        */
       public DisplayName get(Locale arg0)
       {
  -        if (arg0 == null)
  -        {
  -            throw new IllegalArgumentException("Locale argument cannot be null");
  -        }
   
  -        Object obj = nameMap.get(arg0);
  -        if (obj == null)
  +        DisplayName fallBack = null;
  +        Iterator searchItr = innerCollection.iterator();
  +        while(searchItr.hasNext())
           {
  -            obj = langMap.get(arg0.getLanguage());
  -        }
  +        	DisplayName aDName = (DisplayName) searchItr.next();
  +        	if(aDName.getLocale().equals(arg0))
  +        	{
  +        		return aDName;
  +        	}
  +        	else if(aDName.getLocale().getLanguage().equals(arg0.getLanguage()))
  +        	{
  +        		fallBack = aDName;
  +        	}
  +        	
  +        }        
   
  -        return (DisplayName) obj;
  +        return fallBack;
       }
   
       public void addDisplayName(DisplayName name)
  @@ -119,10 +132,8 @@
       public boolean add(Object o)
       {
           MutableDisplayName name = (MutableDisplayName) o;
  -        name.setType(displayNameType);
  -        nameMap.put(name.getLocale(), name);
  -        langMap.put(name.getLocale().getLanguage(), name);
  -        return super.add(o);
  +
  +        return innerCollection.add(o);
       }
   
       /**
  @@ -131,8 +142,32 @@
       public boolean remove(Object o)
       {
           DisplayName name = (DisplayName) o;
  -        nameMap.remove(name.getLocale());
  -        return super.remove(o);
  +        
  +        return innerCollection.remove(o);
  +    }
  +
  +    /**
  +     * @see org.apache.pluto.om.common.DisplayNameSet#iterator()
  +     */
  +    public Iterator iterator()
  +    {        
  +        return this.innerCollection.iterator();
  +    }
  +
  +    /**
  +     * @return
  +     */
  +    public Collection getInnerCollection()
  +    {
  +        return innerCollection;
  +    }
  +
  +    /**
  +     * @param collection
  +     */
  +    public void setInnerCollection(Collection collection)
  +    {
  +        innerCollection = collection;
       }
   
   }
  
  
  
  1.2       +15 -37    jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/DisplayNameImpl.java
  
  Index: DisplayNameImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/DisplayNameImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DisplayNameImpl.java	12 Jan 2004 06:19:51 -0000	1.1
  +++ DisplayNameImpl.java	4 Feb 2004 21:12:10 -0000	1.2
  @@ -65,24 +65,25 @@
    * @version $Id$
    *
    */
  -public class DisplayNameImpl implements MutableDisplayName
  +public abstract class DisplayNameImpl implements MutableDisplayName
   {
  -
       private String displayName;
       private Locale locale;
  -    /** Denotes the type of Description this: Portlet, Application, etc. **/
  -    protected String type;
  -
  -    /**
  -     * Links this DisplayName to the object that it describes
  -     */
  -    //  protected long objectId;
  -
  +	/**
  +	* Tells OJB which class to use to materialize.  
  +	*/
  +	protected String ojbConcreteClass = DisplayNameImpl.class.getName();
  +	
  +	protected long parentId;
  +    
  +	protected long id;
  +    
  + 
       public DisplayNameImpl()
       {
           super();
           // always init to default locale
  -        locale=JetspeedLocale.getDefaultLocale();
  +        locale = JetspeedLocale.getDefaultLocale();
       }
   
       /**
  @@ -90,12 +91,11 @@
        * @param locale Locale of this DisaplyName.
        * @param name The actual text of the display name.
        */
  -    public DisplayNameImpl(Locale locale, String name, String type)
  +    public DisplayNameImpl(Locale locale, String name)
       {
           this();
           this.locale = locale;
  -        this.displayName = name;
  -        this.type = type;
  +        this.displayName = name;        
       }
   
       /**
  @@ -133,28 +133,6 @@
       public void setLanguage(String lang)
       {
           this.locale = new Locale(lang);
  -    }
  -
  -    /**
  -     * @return
  -     */
  -    public String getType()
  -    {
  -        return type;
  -    }
  -
  -    /** 
  -     * <p>
  -     * setType
  -     * </p>
  -     * 
  -     * @see org.apache.jetspeed.om.common.MutableDisplayName#setType(java.lang.String)
  -     * @param type
  -     */
  -    public void setType(String type)
  -    {
  -        this.type = type;
  -
       }
   
   }
  
  
  
  1.2       +49 -5     jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/DescriptionSetImpl.java
  
  Index: DescriptionSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/services/registry/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	12 Jan 2004 06:19:51 -0000	1.1
  +++ DescriptionSetImpl.java	4 Feb 2004 21:12:10 -0000	1.2
  @@ -53,10 +53,11 @@
    */
   package org.apache.jetspeed.om.impl;
   
  +import java.util.ArrayList;
  +import java.util.Collection;
   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;
   
  @@ -69,10 +70,31 @@
    * @version $Id$
    *
    */
  -public class DescriptionSetImpl extends AbstractSupportSet implements MutableDescriptionSet
  +public class DescriptionSetImpl  implements MutableDescriptionSet
   {
       /** Specifies the type Description we are storing */
       protected String descriptionType;
  +    protected Collection innerCollection;
  +
  +    /**
  +     * 
  +     */
  +    public DescriptionSetImpl()
  +    {
  +        super();
  +		this.innerCollection = new ArrayList();        
  +    }
  +
  +    /**
  +     * @param c
  +     */
  +    public DescriptionSetImpl(Collection c)
  +    {
  +        this.innerCollection = c;  
  +    }
  +
  +
  +
   
       public DescriptionSetImpl(String descriptionType)
       {
  @@ -114,10 +136,32 @@
        * @see org.apache.jetspeed.om.common.MutableDescriptionSet#addDescription(java.lang.String)
        */
       public void addDescription(Description description)
  +    {        
  +        innerCollection.add(description);
  +    }
  +
  +    /**
  +     * @see org.apache.pluto.om.common.DescriptionSet#iterator()
  +     */
  +    public Iterator iterator()
  +    {        
  +        return innerCollection.iterator();
  +    }
  +
  +    /**
  +     * @return
  +     */
  +    public Collection getInnerCollection()
       {
  -        ((MutableDescription) description).setType(descriptionType);
  -        add(description);
  +        return innerCollection;
  +    }
   
  +    /**
  +     * @param collection
  +     */
  +    public void setInnerCollection(Collection collection)
  +    {
  +        innerCollection = collection;
       }
   
   }
  
  
  
  1.2       +65 -16    jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/LanguageSetImpl.java
  
  Index: LanguageSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/LanguageSetImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LanguageSetImpl.java	12 Jan 2004 06:19:51 -0000	1.1
  +++ LanguageSetImpl.java	4 Feb 2004 21:12:10 -0000	1.2
  @@ -54,10 +54,12 @@
   package org.apache.jetspeed.om.impl;
   
   import java.io.Serializable;
  -import java.util.HashMap;
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.Locale;
  -import java.util.Set;
  +
   
   import org.apache.jetspeed.util.JetspeedLocale;
   import org.apache.jetspeed.om.common.MutableLanguage;
  @@ -72,24 +74,27 @@
    * @version $Id$
    *
    */
  -public class LanguageSetImpl extends AbstractSupportSet implements LanguageSet, Serializable
  +public class LanguageSetImpl implements LanguageSet, Serializable
   {
   
  -    /** Contains all loaded langauges, keyed by <code>java.util.Locale</code>
*/
  -    private HashMap languageMap = new HashMap();
  +    
  +
  +    protected Collection innerCollection;
   
       /**
        * 
        * @param wrappedSet
        */
  -    public LanguageSetImpl(Set wrappedSet)
  +    public LanguageSetImpl(Collection collection)
       {
  -        super(wrappedSet);
  +        super();
  +        this.innerCollection = collection;
       }
   
       public LanguageSetImpl()
       {
           super();
  +        this.innerCollection = new ArrayList();
       }
   
       /**
  @@ -97,7 +102,7 @@
        */
       public Iterator iterator()
       {
  -        return super.iterator();
  +        return innerCollection.iterator();
       }
   
       /**
  @@ -105,7 +110,15 @@
        */
       public Iterator getLocales()
       {
  -        return languageMap.keySet().iterator();
  +        HashSet localSet = new HashSet();
  +        Iterator itr = innerCollection.iterator();
  +        while (itr.hasNext())
  +        {
  +            Language lang = (Language) itr.next();
  +            localSet.add(lang.getLocale());
  +        }
  +
  +        return localSet.iterator();
       }
   
       /**
  @@ -113,7 +126,23 @@
        */
       public Language get(Locale locale)
       {
  -        return (Language) languageMap.get(locale);
  +		Language fallBack = null;
  +        Iterator searchItr = innerCollection.iterator();
  +        while (searchItr.hasNext())
  +        {
  +			Language lang = (Language) searchItr.next();
  +            if (lang.getLocale().equals(locale))
  +            {
  +                return lang;
  +            }
  +            else if (lang.getLocale().getLanguage().equals(locale.getLanguage()))
  +            {
  +                fallBack = lang;
  +            }
  +
  +        }
  +
  +        return fallBack;
       }
   
       /**
  @@ -134,8 +163,8 @@
           {
               ((MutableLanguage) o).setLocale(JetspeedLocale.getDefaultLocale());
           }
  -        languageMap.put(language.getLocale(), language);
  -        return super.add(o);
  +        
  +        return innerCollection.add(o);
       }
   
       /**
  @@ -143,9 +172,29 @@
        */
       public boolean remove(Object o)
       {
  -        Language language = (Language) o;
  -        languageMap.remove(language.getLocale());
  -        return super.remove(language);
  +        Language language = (Language) o;        
  +        return innerCollection.remove(language);
  +    }
  +
  +    /**
  +     * @return
  +     */
  +    public Collection getInnerCollection()
  +    {
  +        return innerCollection;
  +    }
  +
  +    /**
  +     * @param collection
  +     */
  +    public void setInnerCollection(Collection collection)
  +    {
  +        innerCollection = collection;
  +    }
  +    
  +    public int size()
  +    {
  +    	return innerCollection.size();
       }
   
   }
  
  
  
  1.2       +17 -33    jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/DescriptionImpl.java
  
  Index: DescriptionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/services/registry/src/java/org/apache/jetspeed/om/impl/DescriptionImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DescriptionImpl.java	12 Jan 2004 06:19:51 -0000	1.1
  +++ DescriptionImpl.java	4 Feb 2004 21:12:10 -0000	1.2
  @@ -70,19 +70,25 @@
    * @version $Id$
    *
    */
  -public class DescriptionImpl implements MutableDescription
  +public abstract class DescriptionImpl implements MutableDescription 
   {
   
       private String description;
       private Locale locale;
  -    /** Denotes the type of Description this: Portlet, Application, etc. **/
  -    protected String type;
  -    /**
  -     * Links this description to the object that it describes
  -     */
  -    //  protected long objectId;
  +    
  +	protected long parentId;
  +    
  +	protected long id;
  +
  +	/**
  +	* Tells OJB which class to use to materialize.  
  +	*/
  +	protected String ojbConcreteClass = DescriptionImpl.class.getName();
  +    
  + 
  +
  +
   
  -    // private long id;
   
       public DescriptionImpl()
       {
  @@ -91,12 +97,12 @@
           locale = JetspeedLocale.getDefaultLocale();
       }
   
  -    public DescriptionImpl(Locale locale, String description, String type)
  +    public DescriptionImpl(Locale locale, String description)
       {
           this();
           this.locale = locale;
           this.description = description;
  -        this.type = type;
  +        
       }
   
       /**
  @@ -136,28 +142,6 @@
       public void setLanguage(String lang)
       {
           this.locale = new Locale(lang);
  -    }
  -
  -    /**
  -     * @return
  -     */
  -    public String getType()
  -    {
  -        return type;
  -    }
  -
  -    /** 
  -     * <p>
  -     * setType
  -     * </p>
  -     * 
  -     * @see org.apache.jetspeed.om.common.MutableDescription#setType(java.lang.String)
  -     * @param type
  -     * @return
  -     */
  -    public void setType(String type)
  -    {        
  -        this.type = type;
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message