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 )
|