|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package javax.mail.internet; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| public class ContentDisposition { |
|
26 |
| private String _disposition; |
|
27 |
| private ParameterList _list; |
|
28 |
| |
|
29 |
1
| public ContentDisposition() {
|
|
30 |
1
| setDisposition(null);
|
|
31 |
1
| setParameterList(null);
|
|
32 |
| } |
|
33 |
| |
|
34 |
11
| public ContentDisposition(String disposition) throws ParseException {
|
|
35 |
| |
|
36 |
11
| HeaderTokenizer tokenizer = new HeaderTokenizer(disposition, HeaderTokenizer.MIME);
|
|
37 |
| |
|
38 |
| |
|
39 |
11
| HeaderTokenizer.Token token = tokenizer.next();
|
|
40 |
11
| if (token.getType() != HeaderTokenizer.Token.ATOM) {
|
|
41 |
0
| throw new ParseException("Invalid content disposition");
|
|
42 |
| } |
|
43 |
| |
|
44 |
11
| _disposition = token.getValue();
|
|
45 |
| |
|
46 |
| |
|
47 |
11
| String remainder = tokenizer.getRemainder();
|
|
48 |
11
| if (remainder != null) {
|
|
49 |
11
| _list = new ParameterList(remainder);
|
|
50 |
| } |
|
51 |
| } |
|
52 |
| |
|
53 |
1
| public ContentDisposition(String disposition, ParameterList list) {
|
|
54 |
1
| setDisposition(disposition);
|
|
55 |
1
| setParameterList(list);
|
|
56 |
| } |
|
57 |
| |
|
58 |
6
| public String getDisposition() {
|
|
59 |
6
| return _disposition;
|
|
60 |
| } |
|
61 |
| |
|
62 |
9
| public String getParameter(String name) {
|
|
63 |
9
| if (_list == null) {
|
|
64 |
0
| return null;
|
|
65 |
| } else { |
|
66 |
9
| return _list.get(name);
|
|
67 |
| } |
|
68 |
| } |
|
69 |
| |
|
70 |
4
| public ParameterList getParameterList() {
|
|
71 |
4
| return _list;
|
|
72 |
| } |
|
73 |
| |
|
74 |
3
| public void setDisposition(String string) {
|
|
75 |
3
| _disposition = string;
|
|
76 |
| } |
|
77 |
| |
|
78 |
4
| public void setParameter(String name, String value) {
|
|
79 |
4
| if (_list == null) {
|
|
80 |
0
| _list = new ParameterList();
|
|
81 |
| } |
|
82 |
4
| _list.set(name, value);
|
|
83 |
| } |
|
84 |
| |
|
85 |
2
| public void setParameterList(ParameterList list) {
|
|
86 |
2
| if (list == null) {
|
|
87 |
1
| _list = new ParameterList();
|
|
88 |
| } else { |
|
89 |
1
| _list = list;
|
|
90 |
| } |
|
91 |
| } |
|
92 |
| |
|
93 |
6
| public String toString() {
|
|
94 |
| |
|
95 |
| |
|
96 |
6
| if (_disposition == null) {
|
|
97 |
1
| return null;
|
|
98 |
| } |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
5
| if (_list == null) {
|
|
103 |
0
| return _disposition;
|
|
104 |
| } |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
5
| return _disposition + _list.toString(21 + _disposition.length());
|
|
109 |
| } |
|
110 |
| } |