29
29
*/
30
30
class LiteralPathElement extends PathElement {
31
31
32
- private final char [] text ;
32
+ private final String text ;
33
33
34
34
private final int len ;
35
35
@@ -40,16 +40,7 @@ public LiteralPathElement(int pos, char[] literalText, boolean caseSensitive, ch
40
40
super (pos , separator );
41
41
this .len = literalText .length ;
42
42
this .caseSensitive = caseSensitive ;
43
- if (caseSensitive ) {
44
- this .text = literalText ;
45
- }
46
- else {
47
- // Force all the text lower case to make matching faster
48
- this .text = new char [literalText .length ];
49
- for (int i = 0 ; i < this .len ; i ++) {
50
- this .text [i ] = Character .toLowerCase (literalText [i ]);
51
- }
52
- }
43
+ this .text = new String (literalText );
53
44
}
54
45
55
46
@@ -70,18 +61,13 @@ public boolean matches(int pathIndex, MatchingContext matchingContext) {
70
61
}
71
62
72
63
if (this .caseSensitive ) {
73
- for (int i = 0 ; i < this .len ; i ++) {
74
- if (value .charAt (i ) != this .text [i ]) {
75
- return false ;
76
- }
64
+ if (!this .text .equals (value )) {
65
+ return false ;
77
66
}
78
67
}
79
68
else {
80
- for (int i = 0 ; i < this .len ; i ++) {
81
- // TODO revisit performance if doing a lot of case-insensitive matching
82
- if (Character .toLowerCase (value .charAt (i )) != this .text [i ]) {
83
- return false ;
84
- }
69
+ if (!this .text .equalsIgnoreCase (value )) {
70
+ return false ;
85
71
}
86
72
}
87
73
@@ -114,7 +100,7 @@ public int getNormalizedLength() {
114
100
115
101
@ Override
116
102
public char [] getChars () {
117
- return this .text ;
103
+ return this .text . toCharArray () ;
118
104
}
119
105
120
106
@ Override
@@ -124,7 +110,7 @@ public boolean isLiteral() {
124
110
125
111
@ Override
126
112
public String toString () {
127
- return "Literal(" + String . valueOf ( this .text ) + ")" ;
113
+ return "Literal(" + this .text + ")" ;
128
114
}
129
115
130
116
}
0 commit comments