URLSpec.java
4.83 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.livecycle.formsservice.client;
import com.adobe.livecycle.formsservice.utils.FormsServiceClientUtils;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Set;
import java.util.StringTokenizer;
public class URLSpec
implements Serializable {
private static final long serialVersionUID = 5457387861298923100L;
private String applicationWebRoot = null;
private String targetURL = null;
private String contentRootURI = null;
private String baseURL = null;
protected static HashMap propertyMap = new HashMap(5);
public URLSpec() {
}
public URLSpec(String optionsString) {
this.updateOptionsBean(optionsString);
}
public URLSpec(String applicationWebRoot, String targetURL, String contentRootURI, String baseURL) {
this.applicationWebRoot = applicationWebRoot;
this.targetURL = targetURL;
this.contentRootURI = contentRootURI;
this.baseURL = baseURL;
}
public String getApplicationWebRoot() {
return this.applicationWebRoot;
}
public void setApplicationWebRoot(String applicationWebRoot) {
this.applicationWebRoot = applicationWebRoot;
}
public String getBaseURL() {
return this.baseURL;
}
public void setBaseURL(String baseURL) {
this.baseURL = baseURL;
}
public String getContentRootURI() {
return this.contentRootURI;
}
public void setContentRootURI(String contentRootURI) {
this.contentRootURI = contentRootURI;
}
public String getTargetURL() {
return this.targetURL;
}
public void setTargetURL(String targetURL) {
this.targetURL = targetURL;
}
public String getOptions() {
StringBuffer optStr = new StringBuffer();
for (String key : propertyMap.keySet()) {
String val = this.getOption(key);
if (val == null || val.trim().length() <= 0) continue;
optStr.append(key).append("=").append(val).append("&");
}
if (optStr.length() > 1) {
return optStr.substring(0, optStr.length() - 1);
}
return optStr.toString();
}
public String getOption(String key) {
String paramVal = "";
int propId = this.lookupProperty(key);
switch (propId) {
case 1: {
paramVal = this.getApplicationWebRoot();
break;
}
case 2: {
paramVal = this.getTargetURL();
break;
}
case 3: {
paramVal = this.getContentRootURI();
break;
}
case 4: {
paramVal = this.getBaseURL();
}
}
return this.decodeURL(paramVal);
}
public void updateOptionsBean(String key, String value) {
int propId = this.lookupProperty(key);
if (value != null && value.trim().length() == 0) {
value = null;
}
switch (propId) {
case 1: {
this.setApplicationWebRoot(value);
break;
}
case 2: {
this.setTargetURL(value);
break;
}
case 3: {
this.setContentRootURI(value);
break;
}
case 4: {
this.setBaseURL(value);
}
}
}
public void updateOptionsBean(String options) {
if (FormsServiceClientUtils.isEmptyOrNull(options) || options.indexOf("=") == -1) {
return;
}
StringTokenizer inToks = new StringTokenizer(options, "&");
while (inToks.hasMoreTokens()) {
String tok = inToks.nextToken();
int tokEqual = tok.indexOf("=");
if (tokEqual < 0) continue;
this.updateOptionsBean(tok.substring(0, tokEqual), tok.substring(tokEqual + 1));
}
}
public String toString() {
return this.getOptions();
}
private int lookupProperty(String key) {
int propId = 0;
if (!FormsServiceClientUtils.isEmptyOrNull(key) && propertyMap.containsKey(key = key.toLowerCase())) {
propId = (Integer)propertyMap.get(key);
}
return propId;
}
private String decodeURL(String sURLEncoded) {
if (sURLEncoded != null && sURLEncoded.indexOf(37) != -1) {
byte[] cDecoded = FormsServiceClientUtils.URLDecode(sURLEncoded);
sURLEncoded = new String(cDecoded);
}
return sURLEncoded;
}
static {
propertyMap.put("applicationWebRoot".toLowerCase(), new Integer(1));
propertyMap.put("targetURL".toLowerCase(), new Integer(2));
propertyMap.put("contentRootURI".toLowerCase(), new Integer(3));
propertyMap.put("baseURL".toLowerCase(), new Integer(4));
}
}