ComponentSuffixGenerator.java
926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.wcm.designimporter.util;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
public class ComponentSuffixGenerator {
private Stack<Map<String, Integer>> stack;
public ComponentSuffixGenerator() {
this.reset();
}
public String getSuffix(String componentName) {
Map<String, Integer> nameMap = this.stack.peek();
int suffix = -1;
if (nameMap.containsKey(componentName)) {
suffix = nameMap.get(componentName) + 1;
}
nameMap.put(componentName, suffix);
return suffix > -1 ? "_" + suffix : "";
}
public void startComponentStack() {
this.stack.push(new HashMap());
}
public void endComponentStack() {
this.stack.pop();
}
public void reset() {
this.stack = new Stack();
this.stack.push(new HashMap());
}
}