public class SortedMapType extends MapType { private final Comparator comparator; public SortedMapType(String role, String propertyRef, Comparator comparator, boolean isEmbeddedInXML) { super(role, propertyRef, isEmbeddedInXML); this.comparator = comparator; } public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) { if ( session.getEntityMode()==EntityMode.DOM4J ) { return new PersistentMapElementHolder(session, persister, key); } else { PersistentSortedMap map = new PersistentSortedMap(session); map.setComparator(comparator); return map; } } public Class getReturnedClass() { return java.util.SortedMap.class; } public Object instantiate(int anticipatedSize) { return new TreeMap(comparator); } public PersistentCollection wrap(SessionImplementor session, Object collection) { if ( session.getEntityMode()==EntityMode.DOM4J ) { return new PersistentElementHolder( session, (Element) collection ); } else { return new PersistentSortedMap( session, (java.util.SortedMap) collection );
public class SortedSetType extends SetType { private final Comparator comparator; public SortedSetType(String role, String propertyRef, Comparator comparator, boolean isEmbeddedInXML) { super(role, propertyRef, isEmbeddedInXML); this.comparator = comparator; } public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) { if ( session.getEntityMode()==EntityMode.DOM4J ) { return new PersistentElementHolder(session, persister, key); } else { PersistentSortedSet set = new PersistentSortedSet(session); set.setComparator(comparator); return set; } } public Class getReturnedClass() { return java.util.SortedSet.class; } public Object instantiate(int anticipatedSize) { return new TreeSet(comparator); } public PersistentCollection wrap(SessionImplementor session, Object collection) { if ( session.getEntityMode()==EntityMode.DOM4J ) { return new PersistentElementHolder( session, (Element) collection ); } else { return new PersistentSortedSet( session, (java.util.SortedSet) collection );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/SortedMapType.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/SortedSetType.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class SortedMapType extends MapType {
1
public class SortedSetType extends SetType {
2
	private final Comparator comparator;
2
	private final Comparator comparator;
3
	public SortedMapType(String role, String propertyRef, Comparator comparator, boolean isEmbeddedInXML) {
3
	public SortedSetType(String role, String propertyRef, Comparator comparator, boolean isEmbeddedInXML) {
4
		super(role, propertyRef, isEmbeddedInXML);
4
		super(role, propertyRef, isEmbeddedInXML);
5
		this.comparator = comparator;
5
		this.comparator = comparator;
6
	}
6
	}
7
	public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
7
	public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) {
8
		if ( session.getEntityMode()==EntityMode.DOM4J ) {
8
		if ( session.getEntityMode()==EntityMode.DOM4J ) {
9
			return new PersistentMapElementHolder(session, persister, key);
9
			return new PersistentElementHolder(session, persister, key);
10
		}
10
		}
11
		else {
11
		else {
12
			PersistentSortedMap map = new PersistentSortedMap(session);
12
			PersistentSortedSet set = new PersistentSortedSet(session);
13
			map.setComparator(comparator);
13
			set.setComparator(comparator);
14
			return map;
14
			return set;
15
		}
15
		}
16
	}
16
	}
17
	public Class getReturnedClass() {
17
	public Class getReturnedClass() {
18
		return java.util.SortedMap.class;
18
		return java.util.SortedSet.class;
19
	}
19
	}
20
	public Object instantiate(int anticipatedSize) {
20
	public Object instantiate(int anticipatedSize) {
21
		return new TreeMap(comparator);
21
		return new TreeSet(comparator);
22
	}
22
	}
23
	
23
	
24
	public PersistentCollection wrap(SessionImplementor session, Object collection) {
24
	public PersistentCollection wrap(SessionImplementor session, Object collection) {
25
		if ( session.getEntityMode()==EntityMode.DOM4J ) {
25
		if ( session.getEntityMode()==EntityMode.DOM4J ) {
26
			return new PersistentElementHolder( session, (Element) collection );
26
			return new PersistentElementHolder( session, (Element) collection );
27
		}
27
		}
28
		else {
28
		else {
29
			return new PersistentSortedMap( session, (java.util.SortedMap) collection );
29
			return new PersistentSortedSet( session, (java.util.SortedSet) collection );
30
		
30
		
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0