1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.http.multipart;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21
22
23
24
25 public class InternalAttribute implements InterfaceHttpData {
26 protected List<String> value = new ArrayList<String>();
27
28 public HttpDataType getHttpDataType() {
29 return HttpDataType.InternalAttribute;
30 }
31
32 public List<String> getValue() {
33 return value;
34 }
35
36 public void addValue(String value) {
37 if (value == null) {
38 throw new NullPointerException("value");
39 }
40 this.value.add(value);
41 }
42
43 public void addValue(String value, int rank) {
44 if (value == null) {
45 throw new NullPointerException("value");
46 }
47 this.value.add(rank, value);
48 }
49
50 public void setValue(String value, int rank) {
51 if (value == null) {
52 throw new NullPointerException("value");
53 }
54 this.value.set(rank, value);
55 }
56
57 @Override
58 public int hashCode() {
59 return getName().hashCode();
60 }
61
62 @Override
63 public boolean equals(Object o) {
64 if (!(o instanceof Attribute)) {
65 return false;
66 }
67 Attribute attribute = (Attribute) o;
68 return getName().equalsIgnoreCase(attribute.getName());
69 }
70
71 public int compareTo(InterfaceHttpData data) {
72 if (!(data instanceof InternalAttribute)) {
73 throw new ClassCastException("Cannot compare " + getHttpDataType() +
74 " with " + data.getHttpDataType());
75 }
76 return compareTo((InternalAttribute) data);
77 }
78
79 public int compareTo(InternalAttribute o) {
80 return getName().compareToIgnoreCase(o.getName());
81 }
82
83 public int size() {
84 int size = 0;
85 for (String elt : value) {
86 size += elt.length();
87 }
88 return size;
89 }
90 @Override
91 public String toString() {
92 StringBuilder result = new StringBuilder();
93 for (String elt : value) {
94 result.append(elt);
95 }
96 return result.toString();
97 }
98
99 public String getName() {
100 return "InternalAttribute";
101 }
102 }