ParamUtils.java
1.96 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.dam.scene7.impl.protocol.is;
import com.day.cq.dam.scene7.impl.protocol.NameValue;
import com.day.cq.dam.scene7.impl.protocol.is.ParamCommand;
import java.util.Vector;
public class ParamUtils {
public static boolean isParamRef(String inValue) {
Vector<String> vec = ParamUtils.getParamRefs(inValue);
return vec.size() > 0;
}
public static Vector<String> getParamRefs(String inValue) {
Vector<String> ret = new Vector<String>();
if (inValue == null) {
return ret;
}
int idx1 = 0;
int idx2 = -1;
while ((idx1 = inValue.indexOf(36, idx2 + 1)) != -1 && (idx2 = inValue.indexOf(36, idx1 + 1)) != -1) {
ret.add(inValue.substring(idx1, idx2 + 1));
}
return ret;
}
public static Vector<NameValue> getParameters(NameValue top) {
Vector<NameValue> params = new Vector<NameValue>();
Vector<NameValue> topCmds = top.getChildren();
for (int i = 0; i < topCmds.size(); ++i) {
if (!(topCmds.get(i) instanceof ParamCommand)) continue;
params.add(topCmds.get(i));
}
return params;
}
public static void removeUnusedParameters(NameValue top) {
String cmdStr = top.toString();
Vector<NameValue> topCmds = top.getNodeArray();
for (int i = 0; i < topCmds.size(); ++i) {
if (!(topCmds.get(i) instanceof ParamCommand) || cmdStr.indexOf(topCmds.get(i).getName() + "$") != -1) continue;
top.removeNode(topCmds.get(i).getName());
}
}
public static ParamCommand getParameter(NameValue top, String name) {
Vector<NameValue> children = top.getChildren();
for (int i = 0; i < children.size(); ++i) {
if (!(children.get(i) instanceof ParamCommand) || !children.get(i).getName().equals(name)) continue;
return (ParamCommand)children.get(i);
}
return null;
}
}