| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.kuali.student.common.assembly.data; |
| 20 |
|
|
| 21 |
|
import java.util.Iterator; |
| 22 |
|
|
| 23 |
|
import org.kuali.student.common.assembly.data.Data.Key; |
| 24 |
|
|
| 25 |
|
@author |
| 26 |
|
|
| 27 |
|
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 10 |
Complexity Density: 0.43 |
|
| 28 |
|
public class DefaultPathParser implements PathParser { |
| 29 |
|
|
| 30 |
|
private static final String PATH_SEPARATOR = "/"; |
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 32 |
0
|
@Override... |
| 33 |
|
public String format(final QueryPath path) { |
| 34 |
0
|
final StringBuilder sb = new StringBuilder(); |
| 35 |
0
|
for (final Iterator<Key> itr = path.iterator(); itr.hasNext();) { |
| 36 |
0
|
final Key key = itr.next(); |
| 37 |
0
|
if (key == null) { |
| 38 |
|
|
| 39 |
|
|
| 40 |
0
|
sb.append("null"); |
| 41 |
|
} else { |
| 42 |
0
|
sb.append(key.toString()); |
| 43 |
|
} |
| 44 |
0
|
if (itr.hasNext()) { |
| 45 |
0
|
sb.append(PATH_SEPARATOR); |
| 46 |
|
} |
| 47 |
|
} |
| 48 |
0
|
return sb.toString(); |
| 49 |
|
} |
| 50 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
0
|
@Override... |
| 52 |
|
public String getWildCard() { |
| 53 |
0
|
return "*"; |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 56 |
0
|
@Override... |
| 57 |
|
public QueryPath parse(final String path) { |
| 58 |
0
|
final QueryPath result = new QueryPath(); |
| 59 |
0
|
final String[] elements = path.split(PATH_SEPARATOR); |
| 60 |
0
|
for (String element : elements) { |
| 61 |
0
|
element = element.trim(); |
| 62 |
0
|
if (!element.isEmpty()) { |
| 63 |
0
|
Integer index = null; |
| 64 |
0
|
try { |
| 65 |
0
|
index = Integer.valueOf(element); |
| 66 |
|
} catch (final Exception e) { |
| 67 |
|
|
| 68 |
|
} |
| 69 |
0
|
if (index == null) { |
| 70 |
0
|
result.add(new Data.StringKey(element)); |
| 71 |
|
} else { |
| 72 |
0
|
result.add(new Data.IntegerKey(index)); |
| 73 |
|
} |
| 74 |
|
} |
| 75 |
|
} |
| 76 |
0
|
return result; |
| 77 |
|
} |
| 78 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 79 |
0
|
@Override... |
| 80 |
|
public String getPathSeparator() { |
| 81 |
0
|
return PATH_SEPARATOR; |
| 82 |
|
} |
| 83 |
|
} |