Author: steve.ebersole(a)jboss.com
Date: 2007-07-26 23:20:24 -0400 (Thu, 26 Jul 2007)
New Revision: 12832
Removed:
core/trunk/core/src/main/java/org/hibernate/util/LinkedHashCollectionHelper.java
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java
core/trunk/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java
core/trunk/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java
core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
core/trunk/core/src/main/java/org/hibernate/mapping/Table.java
core/trunk/core/src/main/java/org/hibernate/sql/CaseFragment.java
core/trunk/core/src/main/java/org/hibernate/sql/Insert.java
core/trunk/core/src/main/java/org/hibernate/sql/Update.java
core/trunk/core/src/main/java/org/hibernate/tuple/EntityModeToTuplizerMapping.java
core/trunk/core/src/main/java/org/hibernate/type/OrderedMapType.java
core/trunk/core/src/main/java/org/hibernate/type/OrderedSetType.java
core/trunk/core/src/main/java/org/hibernate/util/IdentityMap.java
core/trunk/core/src/main/java/org/hibernate/util/IdentitySet.java
Log:
HHH-2748 : remove SequencedHashMap usage;
HHH-2749 : direct use of LinkedHashSet/LinkedHashMap
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java 2007-07-27 00:36:37 UTC
(rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java 2007-07-27 03:20:24 UTC
(rev 12832)
@@ -9,7 +9,6 @@
import java.util.Properties;
import java.util.StringTokenizer;
-import org.apache.commons.collections.SequencedHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Attribute;
@@ -2610,14 +2609,11 @@
}
public static java.util.Map getParameterTypes(Element queryElem) {
- java.util.Map result = new SequencedHashMap();
+ java.util.Map result = new java.util.LinkedHashMap();
Iterator iter = queryElem.elementIterator("query-param");
while ( iter.hasNext() ) {
Element element = (Element) iter.next();
- result.put(
- element.attributeValue("name"),
- element.attributeValue("type")
- );
+ result.put( element.attributeValue("name"),
element.attributeValue("type") );
}
return result;
}
Modified: core/trunk/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java 2007-07-27
00:36:37 UTC (rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -4,9 +4,9 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
-import org.apache.commons.collections.SequencedHashMap;
import org.hibernate.EntityMode;
import org.hibernate.cache.CacheKey;
import org.hibernate.collection.PersistentCollection;
@@ -30,12 +30,12 @@
* elegible for batch-fetching.
* <p/>
* Even though this is a map, we only use the keys. A map was chosen in
- * order to utilize a {@link SequencedHashMap} to maintain sequencing
+ * order to utilize a {@link LinkedHashMap} to maintain sequencing
* as well as uniqueness.
* <p/>
* TODO : this would be better as a SequencedReferenceSet, but no such beast exists!
*/
- private final Map batchLoadableEntityKeys = new SequencedHashMap(8);
+ private final Map batchLoadableEntityKeys = new LinkedHashMap(8);
/**
* A map of {@link SubselectFetch subselect-fetch descriptors} keyed by the
Modified:
core/trunk/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java 2007-07-27
00:36:37 UTC (rev 12831)
+++
core/trunk/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -10,11 +10,11 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.collections.SequencedHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,8 +63,8 @@
private final String queryIdentifier;
private final String queryString;
- private final Map typeMap = new SequencedHashMap();
- private final Map collections = new SequencedHashMap();
+ private final Map typeMap = new LinkedHashMap();
+ private final Map collections = new LinkedHashMap();
private List returnedTypes = new ArrayList();
private final List fromTypes = new ArrayList();
private final List scalarTypes = new ArrayList();
@@ -77,7 +77,7 @@
private final List scalarSelectTokens = new ArrayList();
private final List whereTokens = new ArrayList();
private final List havingTokens = new ArrayList();
- private final Map joins = new SequencedHashMap();
+ private final Map joins = new LinkedHashMap();
private final List orderByTokens = new ArrayList();
private final List groupByTokens = new ArrayList();
private final Set querySpaces = new HashSet();
Modified:
core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java 2007-07-27
00:36:37 UTC (rev 12831)
+++
core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -10,8 +10,8 @@
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.LinkedHashMap;
-import org.apache.commons.collections.SequencedHashMap;
import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
@@ -49,11 +49,11 @@
private final String rootSQLAlias;
private int aliasCount = 0;
- private final Map criteriaEntityNames = new SequencedHashMap();
+ private final Map criteriaEntityNames = new LinkedHashMap();
private final Map criteriaSQLAliasMap = new HashMap();
private final Map aliasCriteriaMap = new HashMap();
- private final Map associationPathCriteriaMap = new SequencedHashMap();
- private final Map associationPathJoinTypesMap = new SequencedHashMap();
+ private final Map associationPathCriteriaMap = new LinkedHashMap();
+ private final Map associationPathJoinTypesMap = new LinkedHashMap();
private final SessionFactoryImplementor sessionFactory;
Modified: core/trunk/core/src/main/java/org/hibernate/mapping/Table.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/mapping/Table.java 2007-07-27 00:36:37 UTC
(rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/mapping/Table.java 2007-07-27 03:20:24 UTC
(rev 12832)
@@ -7,8 +7,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.LinkedHashMap;
-import org.apache.commons.collections.SequencedHashMap;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
@@ -30,7 +30,7 @@
/**
* contains all columns, including the primary key
*/
- private Map columns = new SequencedHashMap();
+ private Map columns = new LinkedHashMap();
private KeyValue idValue;
private PrimaryKey primaryKey;
private Map indexes = new HashMap();
Modified: core/trunk/core/src/main/java/org/hibernate/sql/CaseFragment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/sql/CaseFragment.java 2007-07-27 00:36:37
UTC (rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/sql/CaseFragment.java 2007-07-27 03:20:24
UTC (rev 12832)
@@ -2,11 +2,10 @@
package org.hibernate.sql;
import java.util.Map;
+import java.util.LinkedHashMap;
import org.hibernate.util.StringHelper;
-import org.apache.commons.collections.SequencedHashMap;
-
/**
* Abstract SQL case fragment renderer
*
@@ -17,7 +16,7 @@
protected String returnColumnName;
- protected Map cases = new SequencedHashMap();
+ protected Map cases = new LinkedHashMap();
public CaseFragment setReturnColumnName(String returnColumnName) {
this.returnColumnName = returnColumnName;
Modified: core/trunk/core/src/main/java/org/hibernate/sql/Insert.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/sql/Insert.java 2007-07-27 00:36:37 UTC
(rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/sql/Insert.java 2007-07-27 03:20:24 UTC
(rev 12832)
@@ -3,8 +3,8 @@
import java.util.Iterator;
import java.util.Map;
+import java.util.LinkedHashMap;
-import org.apache.commons.collections.SequencedHashMap;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.LiteralType;
@@ -17,7 +17,7 @@
private Dialect dialect;
private String tableName;
private String comment;
- private Map columns = new SequencedHashMap();
+ private Map columns = new LinkedHashMap();
public Insert(Dialect dialect) {
this.dialect = dialect;
Modified: core/trunk/core/src/main/java/org/hibernate/sql/Update.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/sql/Update.java 2007-07-27 00:36:37 UTC
(rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/sql/Update.java 2007-07-27 03:20:24 UTC
(rev 12832)
@@ -3,13 +3,12 @@
import java.util.Iterator;
import java.util.Map;
+import java.util.LinkedHashMap;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.LiteralType;
import org.hibernate.util.StringHelper;
-import org.apache.commons.collections.SequencedHashMap;
-
/**
* An SQL <tt>UPDATE</tt> statement
*
@@ -24,8 +23,8 @@
private String assignments;
private String comment;
- private Map columns = new SequencedHashMap();
- private Map whereColumns = new SequencedHashMap();
+ private Map columns = new LinkedHashMap();
+ private Map whereColumns = new LinkedHashMap();
private Dialect dialect;
Modified:
core/trunk/core/src/main/java/org/hibernate/tuple/EntityModeToTuplizerMapping.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/tuple/EntityModeToTuplizerMapping.java 2007-07-27
00:36:37 UTC (rev 12831)
+++
core/trunk/core/src/main/java/org/hibernate/tuple/EntityModeToTuplizerMapping.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -1,13 +1,12 @@
package org.hibernate.tuple;
-import org.apache.commons.collections.SequencedHashMap;
-
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import java.util.Map;
import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.io.Serializable;
/**
@@ -18,7 +17,7 @@
public abstract class EntityModeToTuplizerMapping implements Serializable {
// map of EntityMode -> Tuplizer
- private final Map tuplizers = Collections.synchronizedMap( new SequencedHashMap() );
+ private final Map tuplizers = Collections.synchronizedMap( new LinkedHashMap() );
protected void addTuplizer(EntityMode entityMode, Tuplizer tuplizer) {
tuplizers.put( entityMode, tuplizer );
Modified: core/trunk/core/src/main/java/org/hibernate/type/OrderedMapType.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/type/OrderedMapType.java 2007-07-27
00:36:37 UTC (rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/type/OrderedMapType.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -1,16 +1,30 @@
//$Id: OrderedMapType.java 10100 2006-07-10 16:31:09Z steve.ebersole(a)jboss.com $
package org.hibernate.type;
-import org.hibernate.util.LinkedHashCollectionHelper;
+import java.util.LinkedHashMap;
+/**
+ * A specialization of the map type, with (resultset-based) ordering.
+ */
public class OrderedMapType extends MapType {
+ /**
+ * Constructs a map type capable of creating ordered maps of the given
+ * role.
+ *
+ * @param role The collection role name.
+ * @param propertyRef The property ref name.
+ * @param isEmbeddedInXML Is this collection to embed itself in xml
+ */
public OrderedMapType(String role, String propertyRef, boolean isEmbeddedInXML) {
super( role, propertyRef, isEmbeddedInXML );
}
+ /**
+ * {@inheritDoc}
+ */
public Object instantiate(int anticipatedSize) {
- return LinkedHashCollectionHelper.createLinkedHashMap( anticipatedSize );
+ return new LinkedHashMap( anticipatedSize );
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/type/OrderedSetType.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/type/OrderedSetType.java 2007-07-27
00:36:37 UTC (rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/type/OrderedSetType.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -1,16 +1,30 @@
//$Id: OrderedSetType.java 10100 2006-07-10 16:31:09Z steve.ebersole(a)jboss.com $
package org.hibernate.type;
-import org.hibernate.util.LinkedHashCollectionHelper;
+import java.util.LinkedHashSet;
+/**
+ * A specialization of the set type, with (resultset-based) ordering.
+ */
public class OrderedSetType extends SetType {
+ /**
+ * Constructs a set type capable of creating ordered sets of the given
+ * role.
+ *
+ * @param role The collection role name.
+ * @param propertyRef The property ref name.
+ * @param isEmbeddedInXML Is this collection to embed itself in xml
+ */
public OrderedSetType(String role, String propertyRef, boolean isEmbeddedInXML) {
super( role, propertyRef, isEmbeddedInXML );
}
+ /**
+ * {@inheritDoc}
+ */
public Object instantiate(int anticipatedSize) {
- return LinkedHashCollectionHelper.createLinkedHashSet( anticipatedSize );
+ return new LinkedHashSet( anticipatedSize );
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/util/IdentityMap.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/util/IdentityMap.java 2007-07-27 00:36:37
UTC (rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/util/IdentityMap.java 2007-07-27 03:20:24
UTC (rev 12832)
@@ -7,12 +7,11 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.collections.SequencedHashMap;
-
/**
* A <tt>Map</tt> where keys are compared by object identity,
* rather than <tt>equals()</tt>.
@@ -26,22 +25,31 @@
/**
* Return a new instance of this class, with an undefined
- * iteration order
+ * iteration order.
*
+ * @param size The size of the map
* @return Map
*/
public static Map instantiate(int size) {
- return new IdentityMap( new HashMap(size) );
+ return new IdentityMap( new HashMap( size ) );
}
/**
* Return a new instance of this class, with iteration
- * order defined by the order that entries were added
+ * order defined as the order in which entries were added
+ *
+ * @param size The size of the map to create
+ * @return
*/
public static Map instantiateSequenced(int size) {
- return new IdentityMap( new SequencedHashMap(size) );
+ return new IdentityMap( new LinkedHashMap( size ) );
}
+ /**
+ * Private ctor used in serialization.
+ *
+ * @param underlyingMap The delegate map.
+ */
private IdentityMap(Map underlyingMap) {
map = underlyingMap;
dirty = true;
Modified: core/trunk/core/src/main/java/org/hibernate/util/IdentitySet.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/util/IdentitySet.java 2007-07-27 00:36:37
UTC (rev 12831)
+++ core/trunk/core/src/main/java/org/hibernate/util/IdentitySet.java 2007-07-27 03:20:24
UTC (rev 12832)
@@ -1,25 +1,38 @@
//$Id: IdentitySet.java 8807 2005-12-09 15:27:05Z epbernard $
package org.hibernate.util;
-import java.util.Set;
import java.util.Collection;
+import java.util.IdentityHashMap;
import java.util.Iterator;
-import java.util.Map;
+import java.util.Set;
/**
- * Set implementation that use == instead of equals() as its comparison mechanism
- * that base its implementation of IdentityMap
- *
+ * Set implementation that use == instead of equals() as its comparison
+ * mechanism. This is achieved by internally using an IdentityHashMap.
+ *
* @author Emmanuel Bernard
*/
public class IdentitySet implements Set {
- private Map map;
private static final Object DUMP_VALUE = new Object();
+ private final IdentityHashMap map;
+
+ /**
+ * Create an IdentitySet with default sizing.
+ */
public IdentitySet() {
- this.map = IdentityMap.instantiate( 10 );
+ this.map = new IdentityHashMap();
}
+ /**
+ * Create an IdentitySet with the given sizing.
+ *
+ * @param sizing The sizing of the set to create.
+ */
+ public IdentitySet(int sizing) {
+ this.map = new IdentityHashMap( sizing );
+ }
+
public int size() {
return map.size();
}
@@ -41,11 +54,11 @@
}
public Object[] toArray(Object[] a) {
- return map.entrySet().toArray(a);
+ return map.entrySet().toArray( a );
}
public boolean add(Object o) {
- return map.put( o, DUMP_VALUE) == null;
+ return map.put( o, DUMP_VALUE ) == null;
}
public boolean remove(Object o) {
@@ -55,7 +68,9 @@
public boolean containsAll(Collection c) {
Iterator it = c.iterator();
while ( it.hasNext() ) {
- if ( ! map.containsKey( it.next() ) ) return false;
+ if ( !map.containsKey( it.next() ) ) {
+ return false;
+ }
}
return true;
}
@@ -64,7 +79,9 @@
Iterator it = c.iterator();
boolean changed = false;
while ( it.hasNext() ) {
- if ( this.add( it.next() ) ) changed = true;
+ if ( this.add( it.next() ) ) {
+ changed = true;
+ }
}
return changed;
}
@@ -78,7 +95,9 @@
Iterator it = c.iterator();
boolean changed = false;
while ( it.hasNext() ) {
- if ( this.remove( it.next() ) ) changed = true;
+ if ( this.remove( it.next() ) ) {
+ changed = true;
+ }
}
return changed;
}
Deleted: core/trunk/core/src/main/java/org/hibernate/util/LinkedHashCollectionHelper.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/util/LinkedHashCollectionHelper.java 2007-07-27
00:36:37 UTC (rev 12831)
+++
core/trunk/core/src/main/java/org/hibernate/util/LinkedHashCollectionHelper.java 2007-07-27
03:20:24 UTC (rev 12832)
@@ -1,95 +0,0 @@
-//$Id: LinkedHashCollectionHelper.java 10100 2006-07-10 16:31:09Z
steve.ebersole(a)jboss.com $
-package org.hibernate.util;
-
-import java.util.Map;
-import java.util.Set;
-import java.lang.reflect.Constructor;
-
-import org.hibernate.AssertionFailure;
-
-public final class LinkedHashCollectionHelper {
-
- private static final Class SET_CLASS;
- private static final Class MAP_CLASS;
- private static final Class[] CAPACITY_CTOR_SIG = new Class[] { int.class, float.class
};
- private static final Constructor SET_CAPACITY_CTOR;
- private static final Constructor MAP_CAPACITY_CTOR;
- private static final float LOAD_FACTOR_V = .75f;
- private static final Float LOAD_FACTOR = new Float( LOAD_FACTOR_V );
-
- static {
- Class setClass;
- Class mapClass;
- Constructor setCtor;
- Constructor mapCtor;
- try {
- setClass = Class.forName( "java.util.LinkedHashSet" );
- mapClass = Class.forName( "java.util.LinkedHashMap" );
- setCtor = setClass.getConstructor( CAPACITY_CTOR_SIG );
- mapCtor = mapClass.getConstructor( CAPACITY_CTOR_SIG );
- }
- catch ( Throwable t ) {
- setClass = null;
- mapClass = null;
- setCtor = null;
- mapCtor = null;
- }
- SET_CLASS = setClass;
- MAP_CLASS = mapClass;
- SET_CAPACITY_CTOR = setCtor;
- MAP_CAPACITY_CTOR = mapCtor;
- }
-
- public static Set createLinkedHashSet() {
- try {
- return (Set) SET_CLASS.newInstance();
- }
- catch (Exception e) {
- throw new AssertionFailure("Could not instantiate LinkedHashSet", e);
- }
- }
-
- public static Set createLinkedHashSet(int anticipatedSize) {
- if ( anticipatedSize <= 0 ) {
- return createLinkedHashSet();
- }
- int initialCapacity = anticipatedSize + (int)( anticipatedSize * LOAD_FACTOR_V );
- try {
- return ( Set ) SET_CAPACITY_CTOR.newInstance( new Object[] { new Integer(
initialCapacity ), LOAD_FACTOR } );
- }
- catch (Exception e) {
- throw new AssertionFailure("Could not instantiate LinkedHashSet", e);
- }
- }
-
- public static Map createLinkedHashMap() {
- try {
- return (Map) MAP_CLASS.newInstance();
- }
- catch (Exception e) {
- throw new AssertionFailure("Could not instantiate LinkedHashMap", e);
- }
- }
-
- public static Map createLinkedHashMap(int anticipatedSize) {
- if ( anticipatedSize <= 0 ) {
- return createLinkedHashMap();
- }
- int initialCapacity = anticipatedSize + (int)( anticipatedSize * LOAD_FACTOR_V );
- try {
- return ( Map ) MAP_CAPACITY_CTOR.newInstance( new Object[] { new Integer(
initialCapacity ), LOAD_FACTOR } );
- }
- catch (Exception e) {
- throw new AssertionFailure("Could not instantiate LinkedHashMap", e);
- }
- }
-
- private LinkedHashCollectionHelper() {}
-
-}
-
-
-
-
-
-