1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
package org.json.simple; |
6 |
|
|
7 |
|
import java.util.ArrayList; |
8 |
|
import java.util.List; |
9 |
|
import java.util.StringTokenizer; |
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
@author |
15 |
|
|
|
|
| 0% |
Uncovered Elements: 90 (90) |
Complexity: 33 |
Complexity Density: 0.67 |
|
16 |
|
public class ItemList |
17 |
|
{ |
18 |
|
private String sp = ","; |
19 |
|
|
20 |
|
List items = new ArrayList(); |
21 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
22 |
0 |
public ItemList()... |
23 |
|
{ |
24 |
|
} |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
26 |
0 |
public ItemList(String s)... |
27 |
|
{ |
28 |
0 |
this.split(s, sp, items); |
29 |
|
} |
30 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
31 |
0 |
public ItemList(String s, String sp)... |
32 |
|
{ |
33 |
0 |
this.sp = s; |
34 |
0 |
this.split(s, sp, items); |
35 |
|
} |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
37 |
0 |
public ItemList(String s, String sp, boolean isMultiToken)... |
38 |
|
{ |
39 |
0 |
split(s, sp, items, isMultiToken); |
40 |
|
} |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
0 |
public List getItems()... |
43 |
|
{ |
44 |
0 |
return this.items; |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
0 |
public String[] getArray()... |
48 |
|
{ |
49 |
0 |
return (String[]) this.items.toArray(); |
50 |
|
} |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
52 |
0 |
public void split(String s, String sp, List append, boolean isMultiToken)... |
53 |
|
{ |
54 |
0 |
if (s == null || sp == null) |
55 |
0 |
return; |
56 |
0 |
if (isMultiToken) |
57 |
|
{ |
58 |
0 |
StringTokenizer tokens = new StringTokenizer(s, sp); |
59 |
0 |
while (tokens.hasMoreTokens()) |
60 |
|
{ |
61 |
0 |
append.add(tokens.nextToken().trim()); |
62 |
|
} |
63 |
|
} |
64 |
|
else |
65 |
|
{ |
66 |
0 |
this.split(s, sp, append); |
67 |
|
} |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
70 |
0 |
public void split(String s, String sp, List append)... |
71 |
|
{ |
72 |
0 |
if (s == null || sp == null) |
73 |
0 |
return; |
74 |
0 |
int pos = 0; |
75 |
0 |
int prevPos = 0; |
76 |
0 |
do |
77 |
|
{ |
78 |
0 |
prevPos = pos; |
79 |
0 |
pos = s.indexOf(sp, pos); |
80 |
0 |
if (pos == -1) |
81 |
0 |
break; |
82 |
0 |
append.add(s.substring(prevPos, pos).trim()); |
83 |
0 |
pos += sp.length(); |
84 |
0 |
} while (pos != -1); |
85 |
0 |
append.add(s.substring(prevPos).trim()); |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0 |
public void setSP(String sp)... |
89 |
|
{ |
90 |
0 |
this.sp = sp; |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
93 |
0 |
public void add(int i, String item)... |
94 |
|
{ |
95 |
0 |
if (item == null) |
96 |
0 |
return; |
97 |
0 |
items.add(i, item.trim()); |
98 |
|
} |
99 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
100 |
0 |
public void add(String item)... |
101 |
|
{ |
102 |
0 |
if (item == null) |
103 |
0 |
return; |
104 |
0 |
items.add(item.trim()); |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0 |
public void addAll(ItemList list)... |
108 |
|
{ |
109 |
0 |
items.addAll(list.items); |
110 |
|
} |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
public void addAll(String s)... |
113 |
|
{ |
114 |
0 |
this.split(s, sp, items); |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0 |
public void addAll(String s, String sp)... |
118 |
|
{ |
119 |
0 |
this.split(s, sp, items); |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0 |
public void addAll(String s, String sp, boolean isMultiToken)... |
123 |
|
{ |
124 |
0 |
this.split(s, sp, items, isMultiToken); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
@param |
129 |
|
|
130 |
|
@return |
131 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
0 |
public String get(int i)... |
133 |
|
{ |
134 |
0 |
return (String) items.get(i); |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0 |
public int size()... |
138 |
|
{ |
139 |
0 |
return items.size(); |
140 |
|
} |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
0 |
public String toString()... |
143 |
|
{ |
144 |
0 |
return toString(sp); |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
147 |
0 |
public String toString(String sp)... |
148 |
|
{ |
149 |
0 |
StringBuffer sb = new StringBuffer(); |
150 |
|
|
151 |
0 |
for (int i = 0; i < items.size(); i++) |
152 |
|
{ |
153 |
0 |
if (i == 0) |
154 |
0 |
sb.append(items.get(i)); |
155 |
|
else |
156 |
|
{ |
157 |
0 |
sb.append(sp); |
158 |
0 |
sb.append(items.get(i)); |
159 |
|
} |
160 |
|
} |
161 |
0 |
return sb.toString(); |
162 |
|
|
163 |
|
} |
164 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
165 |
0 |
public void clear()... |
166 |
|
{ |
167 |
0 |
items.clear(); |
168 |
|
} |
169 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
170 |
0 |
public void reset()... |
171 |
|
{ |
172 |
0 |
sp = ","; |
173 |
0 |
items.clear(); |
174 |
|
} |
175 |
|
} |