Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/cantaloop/cgimlet/IDManager.java


1   /*
2    *
3    * Copyright (C) 2001, 2002 David Leuschner, Stefan Heimann
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18   * USA
19   *
20   */
21  
22  package org.cantaloop.cgimlet;
23  
24  /**
25   * The <code>IDManager</code> helps you to avaid naming-conflicts in your generated
26   * code. Just append the next id to your identifiers.
27   *
28   * @author <a href="mailto:david@cantaloop.org">David Leuschner</a>
29   * @author <a href="mailto:stefan@cantaloop.org">Stefan Heimann</a>
30   *
31   * @version @version@ ($Revision: 1.6 $)
32   */
33  public class IDManager {
34    
35    private int m_currentID = 0;
36      
37    public IDManager() {
38    }
39    
40      
41    /**
42     * Sets the id to its next value and returns it.
43     *
44     * @return a <code>String</code> value
45     */
46    public synchronized String nextID() {
47      return Integer.toString(++m_currentID);
48    }
49    
50    /**
51     * Returns the current id.
52     *
53     * @return a <code>String</code> value
54     */
55    public synchronized String currentID() {
56      return Integer.toString(m_currentID);
57    }
58  }
59  
60