[jboss-cvs] jboss-portal/common/src/main/org/jboss/portal/common/util ...

Julien Viet julien at jboss.com
Mon Jul 31 15:29:46 EDT 2006


  User: julien  
  Date: 06/07/31 15:29:46

  Added:       common/src/main/org/jboss/portal/common/util  LazyMap.java
  Log:
  - moved the portal api in the api module in order to have a standalone jar
  - JBPORTAL-631 : Try to move org.jboss.portlet package to the api module
  - IPC support in 2.4 (only for local portlets)
  
  Revision  Changes    Path
  1.1      date: 2006/07/31 19:29:46;  author: julien;  state: Exp;jboss-portal/common/src/main/org/jboss/portal/common/util/LazyMap.java
  
  Index: LazyMap.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.common.util;
  
  import java.util.Map;
  import java.util.Set;
  import java.util.Collection;
  import java.util.Iterator;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public abstract class LazyMap implements Map
  {
  
     /** . */
     private Map delegate;
  
     /** . */
     private boolean modified;
  
     /**
      * Create the delegate. There are no guarantees that this method will be called only once.
      */
     protected abstract Map createDelegate();
  
     public boolean isModified()
     {
        return modified;
     }
  
     private Map getDelegate()
     {
        if (delegate == null)
        {
           delegate = createDelegate();
        }
        if (delegate == null)
        {
           throw new IllegalStateException("No delegate obtained");
        }
        return delegate;
     }
  
     public int size()
     {
        return getDelegate().size();
     }
  
     public boolean isEmpty()
     {
        return getDelegate().isEmpty();
     }
  
     public boolean containsKey(Object key)
     {
        return getDelegate().containsKey(key);
     }
  
     public boolean containsValue(Object value)
     {
        return getDelegate().containsValue(value);
     }
  
     public Object get(Object key)
     {
        return getDelegate().get(key);
     }
  
     public Object put(Object key, Object value)
     {
        modified = true;
        return getDelegate().put(key, value);
     }
  
     public Object remove(Object key)
     {
        modified = true;
        return getDelegate().remove(key);
     }
  
     public void putAll(Map t)
     {
        modified = true;
        getDelegate().putAll(t);
     }
  
     public void clear()
     {
        modified = true;
        getDelegate().clear();
     }
  
     public Set keySet()
     {
        return new Set()
        {
           Set keySet = getDelegate().keySet();
  
           public int size()
           {
              return keySet.size();
           }
  
           public boolean isEmpty()
           {
              return keySet.isEmpty();
           }
  
           public boolean contains(Object o)
           {
              return keySet.contains(o);
           }
  
           public Iterator iterator()
           {
              return keySet.iterator();
           }
  
           public Object[] toArray()
           {
              return keySet.toArray();
           }
  
           public Object[] toArray(Object[] a)
           {
              return keySet.toArray(a);
           }
  
           public boolean add(Object o)
           {
              modified = true;
              return keySet.add(o);
           }
  
           public boolean remove(Object o)
           {
              modified = true;
              return keySet.remove(o);
           }
  
           public boolean containsAll(Collection c)
           {
              return keySet.containsAll(c);
           }
  
           public boolean addAll(Collection c)
           {
              modified = true;
              return keySet.addAll(c);
           }
  
           public boolean retainAll(Collection c)
           {
              return keySet.retainAll(c);
           }
  
           public boolean removeAll(Collection c)
           {
              modified = true;
              return keySet.removeAll(c);
           }
  
           public void clear()
           {
              modified = true;
              keySet.clear();
           }
  
           public boolean equals(Object o)
           {
              return keySet.equals(o);
           }
  
           public int hashCode()
           {
              return keySet.hashCode();
           }
        };
     }
  
     public Collection values()
     {
        return new Collection()
        {
           /** . */
           Collection values = getDelegate().values();
  
           public int size()
           {
              return values.size();
           }
  
           public boolean isEmpty()
           {
              return values.isEmpty();
           }
  
           public boolean contains(Object o)
           {
              return values.contains(o);
           }
  
           public Iterator iterator()
           {
              return values.iterator();
           }
  
           public Object[] toArray()
           {
              return values.toArray();
           }
  
           public Object[] toArray(Object[] a)
           {
              return values.toArray(a);
           }
  
           public boolean add(Object o)
           {
              modified = true;
              return values.add(o);
           }
  
           public boolean remove(Object o)
           {
              modified = true;
              return values.remove(o);
           }
  
           public boolean containsAll(Collection c)
           {
              return values.containsAll(c);
           }
  
           public boolean addAll(Collection c)
           {
              modified = true;
              return values.addAll(c);
           }
  
           public boolean removeAll(Collection c)
           {
              modified = true;
              return values.removeAll(c);
           }
  
           public boolean retainAll(Collection c)
           {
              return values.retainAll(c);
           }
  
           public void clear()
           {
              modified = true;
              values.clear();
           }
  
           public boolean equals(Object o)
           {
              return values.equals(o);
           }
  
           public int hashCode()
           {
              return values.hashCode();
           }
        };
     }
  
     public Set entrySet()
     {
        return new Set()
        {
           /** . */
           Set entrySet = getDelegate().entrySet();
  
           public int size()
           {
              return entrySet.size();
           }
  
           public boolean isEmpty()
           {
              return entrySet.isEmpty();
           }
  
           public boolean contains(Object o)
           {
              return entrySet.contains(o);
           }
  
           public Iterator iterator()
           {
              return entrySet.iterator();
           }
  
           public Object[] toArray()
           {
              return entrySet.toArray();
           }
  
           public Object[] toArray(Object[] a)
           {
              return entrySet.toArray(a);
           }
  
           public boolean add(Object o)
           {
              modified = true;
              return entrySet.add(o);
           }
  
           public boolean remove(Object o)
           {
              modified = true;
              return entrySet.remove(o);
           }
  
           public boolean containsAll(Collection c)
           {
              return entrySet.containsAll(c);
           }
  
           public boolean addAll(Collection c)
           {
              modified = true;
              return entrySet.addAll(c);
           }
  
           public boolean retainAll(Collection c)
           {
              modified = true;
              return entrySet.retainAll(c);
           }
  
           public boolean removeAll(Collection c)
           {
              modified = true;
              return entrySet.removeAll(c);
           }
  
           public void clear()
           {
              modified = true;
              entrySet.clear();
           }
  
           public boolean equals(Object o)
           {
              return entrySet.equals(o);
           }
  
           public int hashCode()
           {
              return entrySet.hashCode();
           }
        };
     }
  
     public boolean equals(Object o)
     {
        return getDelegate().equals(o);
     }
  
     public int hashCode()
     {
        return getDelegate().hashCode();
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list