public final class SymbolGenerator extends java.lang.Object
The generated name follows the patter __$$_<name>_<counter>
.
The default name is symbol
.
The generator maintains a stack of scope names, to generate hierarchical names.
SymbolGenerator sym = new SymbolGenerator("closure");
sym.next(); // __$$_closure_0
sym.next(); // __$$_closure_1
sym.enter("scope");
sym.next(); // __$$_closure_scope_2
sym.enter("subscope");
sym.next(); // __$$_closure_scope_subscope_3
sym.exit().exit();
sym.next(); // __$$_closure_4
Since the counter maintains uniqueness, the name and scopes only purpose is to give somewhat readable names to help debugging.
Be warned that the uniqueness is only preserved in the context of a single generator. Two independent generators with the same name (and scope) can produce identical names.
Constructor and Description |
---|
SymbolGenerator() |
SymbolGenerator(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
SymbolGenerator |
enter(java.lang.String scopeName) |
SymbolGenerator |
exit() |
java.lang.String |
next() |
java.lang.String |
next(java.lang.String name) |
public SymbolGenerator(java.lang.String name)
public SymbolGenerator()
public java.lang.String next()
public java.lang.String next(java.lang.String name)
public SymbolGenerator exit()
public SymbolGenerator enter(java.lang.String scopeName)