|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jabb.util.text.NameDeduplicator
public class NameDeduplicator
This utility class can rename names by appending numbers to avoid name duplication,
it is multi-thread safe.
这个工具类可以通过给名称后面添加数字的方式来为避免重名而自动改名,它是多线程安全的。
| Field Summary | |
|---|---|
protected PutOnGetMap<String,Sequencer> |
nameSequencers
|
protected String |
renamePattern
|
| Constructor Summary | |
|---|---|
NameDeduplicator()
Constructs an instance with " (%d)" as the postfix pattern.创建一个实例,以" (%d)"作为后缀模版。 |
|
NameDeduplicator(String postfixPattern)
Constructs an instance with specified postfix pattern. 创建一个实例,使用指定的后缀模板。 |
|
| Method Summary | |
|---|---|
String |
deduplicate(String name)
Ensure a unique name, rename if needed. 确保名称不重复,如果有必要就改名。 |
long |
nextId(String name)
Get the next sequential id for specified name. 取得指定名称的下一个不重复Id值。 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected PutOnGetMap<String,Sequencer> nameSequencers
protected String renamePattern
| Constructor Detail |
|---|
public NameDeduplicator(String postfixPattern)
postfixPattern - Patten for the postfix to be appended,
for example, " (%d)" or "_%d" (%d)"或"_%d"。public NameDeduplicator()
" (%d)" as the postfix pattern. (%d)"作为后缀模版。
| Method Detail |
|---|
public String deduplicate(String name)
This method is multi-threads safe.
这个方法是多线程安全的。
name - The original namepublic long nextId(String name)
For a specified name, the first time of invocation will return 0, the second time return 1, the third time return 2, so on and so forth. This method is multi-threads safe.
对于同一个名称,第一次调用返回的是0,第二次是1,第三次是2,依此类推。 这个方法是多线程安全的。
name - The specified name
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||