KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > util > LinkedHashCollectionHelper


1 //$Id: LinkedHashCollectionHelper.java,v 1.1 2004/06/03 16:31:30 steveebersole Exp $
2
package org.hibernate.util;
3
4 import java.util.Map JavaDoc;
5 import java.util.Set JavaDoc;
6
7 import org.hibernate.AssertionFailure;
8
9 public final class LinkedHashCollectionHelper {
10
11     private static final Class JavaDoc SET_CLASS;
12     private static final Class JavaDoc MAP_CLASS;
13     static {
14         Class JavaDoc setClass;
15         Class JavaDoc mapClass;
16         try {
17             setClass = Class.forName("java.util.LinkedHashSet");
18             mapClass = Class.forName("java.util.LinkedHashMap");
19         }
20         catch (ClassNotFoundException JavaDoc cnfe) {
21             setClass = null;
22             mapClass = null;
23         }
24         SET_CLASS = setClass;
25         MAP_CLASS = mapClass;
26     }
27
28     public static Set JavaDoc createLinkedHashSet() {
29         try {
30             return (Set JavaDoc) SET_CLASS.newInstance();
31         }
32         catch (Exception JavaDoc e) {
33             throw new AssertionFailure("Could not instantiate LinkedHashSet", e);
34         }
35     }
36
37     public static Map JavaDoc createLinkedHashMap() {
38         try {
39             return (Map JavaDoc) MAP_CLASS.newInstance();
40         }
41         catch (Exception JavaDoc e) {
42             throw new AssertionFailure("Could not instantiate LinkedHashMap", e);
43         }
44     }
45
46     private LinkedHashCollectionHelper() {}
47
48 }
49
50
51
52
53
54
55
Popular Tags