db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/otm/util IdentityHashMap.java
Date Tue, 08 Jul 2003 16:01:59 GMT
mattbaird    2003/07/08 09:01:59

  Modified:    src/java/org/apache/ojb/otm/copy
                        CloneableObjectCopyStrategy.java
                        ReflectiveObjectCopyStrategy.java
  Added:       src/java/org/apache/ojb/otm/util IdentityHashMap.java
  Log:
  remove reliance on JDK 1.4
  
  Revision  Changes    Path
  1.3       +2 -2      db-ojb/src/java/org/apache/ojb/otm/copy/CloneableObjectCopyStrategy.java
  
  Index: CloneableObjectCopyStrategy.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/copy/CloneableObjectCopyStrategy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CloneableObjectCopyStrategy.java	7 Jul 2003 22:54:14 -0000	1.2
  +++ CloneableObjectCopyStrategy.java	8 Jul 2003 16:01:58 -0000	1.3
  @@ -1,7 +1,5 @@
   package org.apache.ojb.otm.copy;
   
  -import org.apache.ojb.broker.metadata.DescriptorRepository;
  -
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  @@ -55,6 +53,8 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  +
  +import org.apache.ojb.broker.metadata.DescriptorRepository;
   
   /**
    * @author matthew.baird
  
  
  
  1.2       +13 -4     db-ojb/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java
  
  Index: ReflectiveObjectCopyStrategy.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/copy/ReflectiveObjectCopyStrategy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ReflectiveObjectCopyStrategy.java	7 Jul 2003 22:54:14 -0000	1.1
  +++ ReflectiveObjectCopyStrategy.java	8 Jul 2003 16:01:58 -0000	1.2
  @@ -60,7 +60,17 @@
   import java.lang.reflect.Constructor;
   import java.lang.reflect.Field;
   import java.lang.reflect.Modifier;
  -import java.util.*;
  +import java.util.HashMap;
  +import java.util.HashSet;
  +import java.util.Map;
  +import java.util.Set;
  +//#ifdef JDK14
  +import java.util.IdentityHashMap;
  +//#else
  +/*
  +import org.apache.ojb.otm.util.IdentityHashMap;
  +*/
  +//#endif
   
   /**
    * User: matthew.baird
  @@ -97,7 +107,6 @@
   	{
   		return clone(toCopy, new IdentityHashMap(), new HashMap());
   	}
  -
   	/*
   	 * class used to cache class metadata info
   	 */
  @@ -260,8 +269,8 @@
   	 * traversal
   	 */
   	private static void setFields(final Object from, final Object to,
  -								  final Field[] fields, final boolean accessible,
  -								  final Map objMap, final Map metadataMap)
  +	                              final Field[] fields, final boolean accessible,
  +	                              final Map objMap, final Map metadataMap)
   	{
   		for (int f = 0, fieldsLength = fields.length; f < fieldsLength; ++f)
   		{
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/otm/util/IdentityHashMap.java
  
  Index: IdentityHashMap.java
  ===================================================================
  package org.apache.ojb.otm.util;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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 ObjectRelationalBridge" 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 ObjectRelationalBridge", 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/>.
   */
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * replacement for the JDK1.4 version
   * User: Matthew Baird
   * Date: Jul 8, 2003
   * Time: 8:37:00 AM
   */
  public final class IdentityHashMap extends HashMap
  {
  	private static final class IdentityKey
  	{
  		private Object m_key;
  
  		public IdentityKey(Object key)
  		{
  			m_key = key;
  		}
  
  		public boolean equals(Object o)
  		{
  			return (o == m_key);
  		}
  
  		public int hashCode()
  		{
  			return System.identityHashCode(m_key);
  		}
  	}
  
  	/**
  	 * Constructor for IdentityHashMap.
  	 * @param initialCapacity
  	 * @param loadFactor
  	 */
  	public IdentityHashMap(int initialCapacity, float loadFactor)
  	{
  		super(initialCapacity, loadFactor);
  	}
  
  	/**
  	 * Constructor for IdentityHashMap.
  	 * @param initialCapacity
  	 */
  	public IdentityHashMap(int initialCapacity)
  	{
  		super(initialCapacity);
  	}
  
  	/**
  	 * Constructor for IdentityHashMap.
  	 */
  	public IdentityHashMap()
  	{
  		super();
  	}
  
  	/**
  	 * Constructor for IdentityHashMap.
  	 * @param t
  	 */
  	public IdentityHashMap(Map t)
  	{
  		super(t);
  	}
  
  	/**
  	 * @see java.util.Map#get(java.lang.Object)
  	 */
  	public Object get(Object key)
  	{
  		return super.get(new IdentityKey(key));
  	}
  
  	/**
  	 * @see java.util.Map#put(java.lang.Object, java.lang.Object)
  	 */
  	public Object put(Object key, Object value)
  	{
  		return super.put(new IdentityKey(key), value);
  	}
  
  	/**
  	 * adds an object to the Map. new IdentityKey(obj) is used as key
  	 */
  	public Object add(Object value)
  	{
  		Object key = new IdentityKey(value);
  		if (!super.containsKey(key))
  		{
  			return super.put(key, value);
  		}
  		else
  		{
  			return null;
  		}
  	}
  
  	/**
  	 * @see java.util.Map#remove(java.lang.Object)
  	 */
  	public Object remove(Object key)
  	{
  		return super.remove(new IdentityKey(key));
  	}
  
  	/**
  	 * @see java.util.Map#containsKey(java.lang.Object)
  	 */
  	public boolean containsKey(Object key)
  	{
  		return super.containsKey(new IdentityKey(key));
  	}
  }
  
  
  
  

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


Mime
View raw message