01: /* *****************************************************************************
02: * SymbolGenerator.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
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 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 prefix) {
27: this .mSymbolPrefix = prefix;
28: }
29:
30: /** Returns the next unique name.
31: * @return a unique name
32: */
33: public String next() {
34: mIndex += 1;
35: return mSymbolPrefix + new Integer(mIndex).toString();
36: }
37: }
|