KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb > IdGeneratorSingleton


1 package org.apache.ojb.tools.mapping.reversedb;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.util.HashMap JavaDoc;
19
20 /**
21  *
22  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
23  * @version $Id: IdGeneratorSingleton.java,v 1.1.2.1 2005/12/21 22:32:04 tomdz Exp $
24  * @deprecated since 2003-06-21
25  */

26 public class IdGeneratorSingleton
27 {
28   private static IdGeneratorSingleton singleton = new IdGeneratorSingleton();
29
30   /** Creates a new instance of IdGeneratorSingleton */
31   
32   private HashMap JavaDoc hmIds = new HashMap JavaDoc();
33   
34   private IdGeneratorSingleton ()
35   {
36   }
37   
38   private int _getId(String JavaDoc type, String JavaDoc instance)
39   {
40     HashMap JavaDoc hmTypeId = (HashMap JavaDoc)hmIds.get(type);
41     if (hmTypeId == null)
42     {
43       hmTypeId = new HashMap JavaDoc();
44       hmIds.put(type, hmTypeId);
45     }
46     Integer JavaDoc storedId = (Integer JavaDoc)hmTypeId.get(instance);
47     int id;
48     if (storedId == null)
49     {
50       id = 0;
51     }
52     else id = storedId.intValue()+1;
53     hmTypeId.put(instance, new Integer JavaDoc(id));
54     return id;
55   }
56   
57   public static int getId(String JavaDoc type, String JavaDoc instance)
58   {
59     return singleton._getId (type, instance);
60   }
61 }
62
63
64 /***************************** Changelog *****************************
65 // $Log: IdGeneratorSingleton.java,v $
66 // Revision 1.1.2.1 2005/12/21 22:32:04 tomdz
67 // Updated license
68 //
69 // Revision 1.1 2004/05/05 16:39:05 arminw
70 // fix fault
71 // wrong package structure used:
72 // org.apache.ojb.tools.reversdb
73 // org.apache.ojb.tools.reversdb2
74 //
75 // instead of
76 // org.apache.ojb.tools.mapping.reversdb
77 // org.apache.ojb.tools.mapping.reversdb2
78 //
79 // Revision 1.1 2004/05/04 13:45:01 arminw
80 // move reverseDB stuff
81 //
82 // Revision 1.5 2004/04/04 23:53:42 brianm
83 // Fixed initial copyright dates to match cvs repository
84 //
85 // Revision 1.4 2004/03/11 18:16:22 brianm
86 // ASL 2.0
87 //
88 // Revision 1.3 2003/06/21 10:36:40 florianbruckner
89 // remove double license header, deprecate class
90 //
91 // Revision 1.2 2002/06/17 19:34:33 jvanzyl
92 // Correcting all the package references.
93 // PR:
94 // Obtained from:
95 // Submitted by:
96 // Reviewed by:
97 //
98 // Revision 1.1.1.1 2002/06/17 18:16:52 jvanzyl
99 // Initial OJB import
100 //
101 // Revision 1.2 2002/05/16 11:47:09 florianbruckner
102 // fix CR/LF issue, change license to ASL
103 //
104 // Revision 1.1 2002/04/18 11:44:16 mpoeschl
105 //
106 // move files to new location
107 //
108 // Revision 1.3 2002/04/07 09:05:16 thma
109 // *** empty log message ***
110 //
111 // Revision 1.2 2002/03/11 17:36:05 florianbruckner
112 // fix line break issue for these files that were previously checked in with -kb
113 //
114 // Revision 1.1 2002/03/04 17:19:32 thma
115 // initial checking for Florians Reverse engineering tool
116 //
117 // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
118 // initial import
119 //
120 /***************************** Changelog *****************************/

121
Popular Tags