1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.filters.upload;
24
25 /**
26 * Encapsulates an element of a multipart request.
27 *
28 * @author Jose M. Palomar
29 * @version $Revision: 127 $
30 */
31 public final class MultipartElement {
32
33
34 /**
35 * Element type text.
36 */
37 public static final int TEXT = 0;
38
39 /**
40 * Element type file.
41 */
42 public static final int FILE = 1;
43
44
45 /**
46 * Name of element.
47 */
48 private final String name;
49
50 /**
51 * File name of element.
52 */
53 private final String filename;
54
55 /**
56 * Value of element.
57 */
58 private final Object value;
59
60 /**
61 * Type of element.
62 */
63 private final int type;
64
65
66 /**
67 * Creates a new <code>MultipartElement</code> of type TEXT using given name and
68 * value.
69 *
70 * @param name String name of element.
71 * @param value String value of element.
72 */
73 public MultipartElement(String name, String value) {
74 this.name = name;
75 this.filename = null;
76 this.value = value;
77 this.type = TEXT;
78 }
79
80 /**
81 * Creates a new <code>MultipartElement</code> of type FILE using given name and
82 * value.
83 *
84 * @param name String name of element.
85 * @param filename String file name of element.
86 * @param value MultipartFile value of element.
87 */
88 public MultipartElement(String name, String filename, MultipartFile value) {
89 this.name = name;
90 this.filename = filename;
91 this.value = value;
92 this.type = FILE;
93 }
94
95
96 /**
97 * Returns name of element.
98 *
99 * @return String name of element.
100 */
101 public String getName() {
102 return name;
103 }
104
105 /**
106 * Returns file name of element (FILE type only).
107 *
108 * @return String file name of element.
109 */
110 public String getFilename() {
111 return filename;
112 }
113
114 /**
115 * Returns value of element.
116 *
117 * @return Object value of element.
118 */
119 public Object getValue() {
120 return value;
121 }
122
123 /**
124 * Returns type of element. Type can be TEXT of FILE.
125 *
126 * @return int type of element.
127 */
128 public int getType() {
129 return type;
130 }
131
132 }