KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > compiler > SymbolGenerator


1 /* *****************************************************************************
2  * SymbolGenerator.java
3 * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.compiler;
11
12 /** A unique name supply.
13  *
14  * @author Oliver Steele
15  * @version 1.0
16  */

17 public class SymbolGenerator {
18     /** Prefix for generated names. */
19     protected final String JavaDoc mSymbolPrefix;
20     /** Number to append to next generated name. */
21     protected int mIndex = 0;
22
23     /** Constructs an instance.
24      * @param prefix a string prefix
25      */

26     public SymbolGenerator(String JavaDoc prefix) {
27         this.mSymbolPrefix = prefix;
28     }
29
30     /** Returns the next unique name.
31      * @return a unique name
32      */

33     public String JavaDoc next() {
34         mIndex += 1;
35         return mSymbolPrefix + new Integer JavaDoc(mIndex).toString();
36     }
37 }
38
Popular Tags