KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > hql > CollectionProperties


1 // $Id: CollectionProperties.java,v 1.5 2005/02/13 11:50:01 oneovthafew Exp $
2
package org.hibernate.hql;
3
4 import org.hibernate.persister.collection.CollectionPropertyNames;
5
6 import java.util.HashMap JavaDoc;
7 import java.util.Map JavaDoc;
8
9 /**
10  * Provides a map of collection function names to the corresponding property names.
11  *
12  * @author josh Aug 16, 2004 7:51:45 PM
13  */

14 public final class CollectionProperties {
15     public static final Map JavaDoc HQL_COLLECTION_PROPERTIES;
16
17     private static final String JavaDoc COLLECTION_INDEX_LOWER = CollectionPropertyNames.COLLECTION_INDEX.toLowerCase();
18
19     static {
20         HQL_COLLECTION_PROPERTIES = new HashMap JavaDoc();
21         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_ELEMENTS.toLowerCase(), CollectionPropertyNames.COLLECTION_ELEMENTS );
22         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_INDICES.toLowerCase(), CollectionPropertyNames.COLLECTION_INDICES );
23         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_SIZE.toLowerCase(), CollectionPropertyNames.COLLECTION_SIZE );
24         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MAX_INDEX.toLowerCase(), CollectionPropertyNames.COLLECTION_MAX_INDEX );
25         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MIN_INDEX.toLowerCase(), CollectionPropertyNames.COLLECTION_MIN_INDEX );
26         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MAX_ELEMENT.toLowerCase(), CollectionPropertyNames.COLLECTION_MAX_ELEMENT );
27         HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MIN_ELEMENT.toLowerCase(), CollectionPropertyNames.COLLECTION_MIN_ELEMENT );
28         HQL_COLLECTION_PROPERTIES.put( COLLECTION_INDEX_LOWER, CollectionPropertyNames.COLLECTION_INDEX );
29     }
30
31     private CollectionProperties() {
32     }
33
34     public static boolean isCollectionProperty(String JavaDoc name) {
35         String JavaDoc key = name.toLowerCase();
36         // CollectionPropertyMapping processes everything except 'index'.
37
if ( COLLECTION_INDEX_LOWER.equals( key ) ) {
38             return false;
39         }
40         else {
41             return HQL_COLLECTION_PROPERTIES.containsKey( key );
42         }
43     }
44
45     public static String JavaDoc getNormalizedPropertyName(String JavaDoc name) {
46         return ( String JavaDoc ) HQL_COLLECTION_PROPERTIES.get( name );
47     }
48
49     public static boolean isAnyCollectionProperty(String JavaDoc name) {
50         String JavaDoc key = name.toLowerCase();
51         return HQL_COLLECTION_PROPERTIES.containsKey( key );
52     }
53 }
54
Popular Tags