1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.reflection.property;
17
18 import java.util.Iterator;
19
20
21
22
23 public class PropertyTokenizer implements Iterator<PropertyTokenizer> {
24 private String name;
25 private final String indexedName;
26 private String index;
27 private final String children;
28
29 public PropertyTokenizer(String fullname) {
30 int delim = fullname.indexOf('.');
31 if (delim > -1) {
32 name = fullname.substring(0, delim);
33 children = fullname.substring(delim + 1);
34 } else {
35 name = fullname;
36 children = null;
37 }
38 indexedName = name;
39 delim = name.indexOf('[');
40 if (delim > -1) {
41 index = name.substring(delim + 1, name.length() - 1);
42 name = name.substring(0, delim);
43 }
44 }
45
46 public String getName() {
47 return name;
48 }
49
50 public String getIndex() {
51 return index;
52 }
53
54 public String getIndexedName() {
55 return indexedName;
56 }
57
58 public String getChildren() {
59 return children;
60 }
61
62 @Override
63 public boolean hasNext() {
64 return children != null;
65 }
66
67 @Override
68 public PropertyTokenizer next() {
69 return new PropertyTokenizer(children);
70 }
71
72 @Override
73 public void remove() {
74 throw new UnsupportedOperationException(
75 "Remove is not supported, as it has no meaning in the context of properties.");
76 }
77 }