RequestParameter.java
2.67 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
/*
* Decompiled with CFR 0_118.
*/
package com.day.crx.delite.impl.support;
import com.day.crx.delite.impl.support.Blob;
import com.day.crx.delite.impl.support.HttpHeader;
import com.day.crx.delite.impl.support.HttpMultipartPost;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
public class RequestParameter {
final String name;
private final String contentType;
private final String filename;
private final String defaultEncoding;
private final Blob data;
private String value;
private HttpMultipartPost httpMultipartPost;
protected RequestParameter(HttpMultipartPost httpMultipartPost, String name, String value) {
this.httpMultipartPost = httpMultipartPost;
this.name = name;
this.value = value;
this.contentType = null;
this.defaultEncoding = null;
this.filename = null;
this.data = null;
}
protected RequestParameter(HttpMultipartPost httpMultipartPost, String name, Blob data, String defaultEncoding) {
this.httpMultipartPost = httpMultipartPost;
this.name = name;
this.value = null;
this.contentType = null;
this.defaultEncoding = defaultEncoding;
this.filename = null;
this.data = data;
}
protected RequestParameter(HttpMultipartPost httpMultipartPost, String name, String fileName, HttpHeader contentType, Blob data) {
this.httpMultipartPost = httpMultipartPost;
this.name = name;
this.filename = fileName;
this.value = null;
this.contentType = contentType == null ? null : contentType.getPrimary();
this.defaultEncoding = contentType == null ? null : contentType.getPart("charset");
this.data = data;
}
public boolean isFileParameter() {
return this.filename != null;
}
public String getName() {
return this.name;
}
public Blob getData() {
return this.data;
}
public String getEncoding() {
return this.defaultEncoding;
}
public String getFilename() {
return this.filename;
}
public String getContentType() {
return this.contentType;
}
public String getString() {
try {
if (this.value == null) {
this.value = new String(this.data.getBytes(), this.defaultEncoding == null ? this.httpMultipartPost.getFormEncoding() : this.defaultEncoding);
}
return this.value;
}
catch (UnsupportedEncodingException e) {
throw new InternalError("Encoding not supported.");
}
catch (IOException e) {
throw new InternalError("Unexpected error: " + e);
}
}
}