This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 9ce489a621 Utility class cleanup
9ce489a621 is described below
commit 9ce489a62188aaf7161d3aec4919c455d2a1f682
Author: James Bognar <[email protected]>
AuthorDate: Tue Oct 21 15:47:47 2025 -0400
Utility class cleanup
---
.../apache/juneau/internal/StateMachineState.java | 41 ------
.../juneau/objecttools/NumberMatcherFactory.java | 95 +++++++-------
.../juneau/objecttools/TimeMatcherFactory.java | 145 ++++++++++-----------
.../juneau/utils/StringExpressionMatcher.java | 61 +++++----
.../org/apache/juneau/rest/client/RestClient.java | 37 +++---
.../apache/juneau/rest/mock/MockPathResolver.java | 45 ++++---
.../org/apache/juneau/rest/guard/RoleMatcher.java | 61 +++++----
.../juneau/objecttools/ObjectSearcher_Test.java | 28 ++--
8 files changed, 233 insertions(+), 280 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StateMachineState.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StateMachineState.java
deleted file mode 100644
index a0ea474b29..0000000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StateMachineState.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.internal;
-
-/**
- * Enums for state-machine states.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * </ul>
- */
-@SuppressWarnings("javadoc")
-public enum StateMachineState {
- S01, S02, S03, S04, S05, S06, S07, S08, S09, S10, S11, S12, S13, S14,
S15, S16, S17, S18, S19, S20;
-
- /**
- * Returns <jk>true</jk> if the state is any one of the specified
states.
- *
- * @param states The states to check.
- * @return <jk>true</jk> if the state is any one of the specified
states.
- */
- public boolean isAny(StateMachineState...states) {
- for (StateMachineState s : states)
- if (this == s)
- return true;
- return false;
- }
-}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
index e617f5211a..3211fcfbf1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/NumberMatcherFactory.java
@@ -16,13 +16,12 @@
*/
package org.apache.juneau.objecttools;
-import static org.apache.juneau.internal.StateMachineState.*;
+import static org.apache.juneau.common.utils.StateEnum.*;
import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.common.utils.*;
-import org.apache.juneau.internal.*;
/**
* Number matcher factory for the {@link ObjectSearcher} class.
@@ -70,19 +69,19 @@ public class NumberMatcherFactory extends MatcherFactory {
// 123, >123, <123, >=123, <=123, >-123, >=-123,
123-456, -123--456, !123, !123-456, 123 - 456 (one token), 123 -456 (two
separate tokens)
// Possible states:
- // S01 = Looking for start (WS=S01, [!]=S01, [>]=S02,
[<]=S03, SNUM=S06)
- // S02 = Found [>], looking for [=]/SNUM ([=]=S04,
WS=S05, SNUM=S06)
- // S03 = Found [<], looking for [=]/SNUM ([=]=S05,
WS=S05, SNUM=S06)
- // S04 = Found [=], looking for SNUN (WS=S05, SNUM=S06)
- // S05 = Found [... ], looking for SNUM (SNUM=S06)
- // S06 = Found [1], looking for [-]/WS (WS=S07, [-]=S08)
- // S07 = Found [123 ], looking for [-]/SNUM (if -,
could be 123 - 456 or 123 -456) ([-]=S09, SNUM=S07)
- // S08 = Found [123-], looking for SNUM (Could be 123-
456 or 123-456) (SNUM=S11)
- // S09 = Found [123 -], looking for WS/SNUM (If WS,
then it's 123 - 456, otherwise 123 -456) (WS=S10, SNUM=S06)
+ // S1 = Looking for start (WS=S1, [!]=S1, [>]=S2,
[<]=S3, SNUM=S6)
+ // S2 = Found [>], looking for [=]/SNUM ([=]=S4, WS=S5,
SNUM=S6)
+ // S3 = Found [<], looking for [=]/SNUM ([=]=S5, WS=S5,
SNUM=S6)
+ // S4 = Found [=], looking for SNUN (WS=S5, SNUM=S6)
+ // S5 = Found [... ], looking for SNUM (SNUM=S6)
+ // S6 = Found [1], looking for [-]/WS (WS=S7, [-]=S8)
+ // S7 = Found [123 ], looking for [-]/SNUM (if -, could
be 123 - 456 or 123 -456) ([-]=S9, SNUM=S7)
+ // S8 = Found [123-], looking for SNUM (Could be 123-
456 or 123-456) (SNUM=S11)
+ // S9 = Found [123 -], looking for WS/SNUM (If WS, then
it's 123 - 456, otherwise 123 -456) (WS=S10, SNUM=S6)
// S10 = Found [123 - ], looking for SNUM (SNUM=S12)
- // S11 = Found [123 - 4], looking for WS (WS=S01)
+ // S11 = Found [123 - 4], looking for WS (WS=S1)
- StateMachineState state = S01;
+ StateEnum state = S1;
int mark = 0;
boolean isNot = false;
Equality eq = Equality.NONE;
@@ -91,84 +90,84 @@ public class NumberMatcherFactory extends MatcherFactory {
int i;
for (i = 0; i < s.length(); i++) {
char c = s.charAt(i);
- if (state == S01) {
+ if (state == S1) {
if (c == '!') {
isNot = true;
} else if (WS.contains(c)) {
- state = S01;
+ state = S1;
} else if (c == '>') {
- state = S02;
+ state = S2;
eq = Equality.GT;
} else if (c == '<') {
- state = S03;
+ state = S3;
eq = Equality.LT;
} else if (SNUM.contains(c)) {
- state = S06;
+ state = S6;
mark = i;
} else {
break;
}
- } else if (state == S02) {
+ } else if (state == S2) {
if (c == '=') {
- state = S04;
+ state = S4;
eq = Equality.GTE;
} else if (WS.contains(c)) {
- state = S05;
+ state = S5;
} else if (SNUM.contains(c)) {
- state = S06;
+ state = S6;
mark = i;
} else {
break;
}
- } else if (state == S03) {
+ } else if (state == S3) {
if (c == '=') {
- state = S04;
+ state = S4;
eq = Equality.LTE;
} else if (WS.contains(c)) {
- state = S05;
+ state = S5;
} else if (SNUM.contains(c)) {
- state = S06;
+ state = S6;
mark = i;
} else {
break;
}
- } else if (state == S04) {
+ } else if (state == S4) {
if (WS.contains(c)) {
- state = S05;
+ state = S5;
} else if (SNUM.contains(c)) {
mark = i;
- state = S06;
+ state = S6;
} else {
break;
}
- } else if (state == S05) {
+ } else if (state == S5) {
if (WS.contains(c)) {
- state = S05;
+ state = S5;
} else if (SNUM.contains(c)) {
- state = S06;
+ state = S6;
mark = i;
} else {
break;
}
- } else if (state == S06) {
+ } else if (state == S6) {
if (NUM.contains(c)) {
- state = S06;
+ state = S6;
} else if (WS.contains(c)) {
- state = S07;
+ state = S7;
n1 =
Integer.parseInt(s.substring(mark, i));
} else if (c == '-') {
- state = S08;
+ state = S8;
n1 =
Integer.parseInt(s.substring(mark, i));
} else {
break;
}
- } else if (state == S07) {
+ } else if (state == S7) {
if (WS.contains(c)) {
- state = S07;
+ state = S7;
} else if (c == '-') {
- state = S09;
+ state = S9;
} else if (SNUM.contains(c)) {
- state = S06;
+ state = S6;
l.add(new NumberRange(eq, n1,
isNot));
eq = Equality.NONE;
n1 = null;
@@ -177,20 +176,20 @@ public class NumberMatcherFactory extends MatcherFactory {
} else {
break;
}
- } else if (state == S08) {
+ } else if (state == S8) {
if (WS.contains(c)) {
- state = S08;
+ state = S8;
} else if (SNUM.contains(c)) {
state = S11;
mark = i;
} else {
break;
}
- } else if (state == S09) {
+ } else if (state == S9) {
if (WS.contains(c)) {
state = S10;
} else if (NUM.contains(c)) {
- state = S06;
+ state = S6;
l.add(new NumberRange(eq, n1,
isNot));
eq = Equality.NONE;
n1 = null;
@@ -212,7 +211,7 @@ public class NumberMatcherFactory extends MatcherFactory {
if (SNUM.contains(c)) {
state = S11;
} else if (WS.contains(c)) {
- state = S01;
+ state = S1;
n2 =
Integer.parseInt(s.substring(mark, i));
l.add(new NumberRange(eq, n1,
n2, isNot));
eq = Equality.NONE;
@@ -227,11 +226,11 @@ public class NumberMatcherFactory extends MatcherFactory {
if (i != s.length())
throw new PatternException("Invalid range
pattern ({0}): {1}", state, s);
- if (state == S01) {
+ if (state == S1) {
// No tokens found.
- } else if (state == S02 || state == S03 || state == S04
|| state == S08 || state == S09) {
+ } else if (state == S2 || state == S3 || state == S4 ||
state == S8 || state == S9) {
throw new PatternException("Invalid range
pattern (E{0}): {1}", state, s);
- } else if (state == S06) {
+ } else if (state == S6) {
n1 = Integer.parseInt(s.substring(mark).trim());
l.add(new NumberRange(eq, n1, isNot));
} else /* (state == S11) */ {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/TimeMatcherFactory.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/TimeMatcherFactory.java
index 8a895f10c5..63cb82a3fe 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/TimeMatcherFactory.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/TimeMatcherFactory.java
@@ -16,14 +16,13 @@
*/
package org.apache.juneau.objecttools;
-import static org.apache.juneau.internal.StateMachineState.*;
+import static org.apache.juneau.common.utils.StateEnum.*;
import java.time.temporal.*;
import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.common.utils.*;
-import org.apache.juneau.internal.*;
/**
* Date/time matcher factory for the {@link ObjectSearcher} class.
@@ -106,21 +105,21 @@ public class TimeMatcherFactory extends MatcherFactory {
// >2000, <2000, >=2000, <=2000, > 2000, 2000 - 2001,
'2000', >'2000', '2000'-'2001', '2000' - '2001'
// Possible states:
- // S01 = Looking for [<]/[>]/quote/NUM ([>]=S02,
[<]=S03, [']=S05, ["]=S06, NUM=S08)
- // S02 = Found [>], looking for [=]/quote/NUM ([=]=S04,
[']=S05, ["]=S06, NUM=S08)
- // S03 = Found [<], looking for [=]/quote/NUM ([=]=S04,
[']=S05, ["]=S06, NUM=S08)
- // S04 = Found [>=] or [<=], looking for quote/NUM
([']=S05, ["]=S06, NUM=S08)
- // S05 = Found ['], looking for ['] ([']=S01)
- // S06 = Found ["], looking for ["] (["]=S01)
- // S07 = Found [123"] or [123'], looking for WS (WS=S09)
- // S08 = Found [2], looking for WS (WS=S09)
- // S09 = Found [2000 ], looking for [-]/quote/NUM
([-]=S10, [']=S11, ["]=S12, NUM=S13)
+ // S1 = Looking for [<]/[>]/quote/NUM ([>]=S2, [<]=S3,
[']=S5, ["]=S6, NUM=S8)
+ // S2 = Found [>], looking for [=]/quote/NUM ([=]=S4,
[']=S5, ["]=S6, NUM=S8)
+ // S3 = Found [<], looking for [=]/quote/NUM ([=]=S4,
[']=S5, ["]=S6, NUM=S8)
+ // S4 = Found [>=] or [<=], looking for quote/NUM
([']=S5, ["]=S6, NUM=S8)
+ // S5 = Found ['], looking for ['] ([']=S1)
+ // S6 = Found ["], looking for ["] (["]=S1)
+ // S7 = Found [123"] or [123'], looking for WS (WS=S9)
+ // S8 = Found [2], looking for WS (WS=S9)
+ // S9 = Found [2000 ], looking for [-]/quote/NUM
([-]=S10, [']=S11, ["]=S12, NUM=S13)
// S10 = Found [2000 -], looking for quote/NUM
([']=S11, ["]=S12, NUM=S13)
- // S11 = Found [2000 - '], looking for ['] ([']=S01)
- // S12 = Found [2000 - "], looking for ["] (["]=S01)
- // S13 = Found [2000 - 2], looking for WS (WS=S01)
+ // S11 = Found [2000 - '], looking for ['] ([']=S1)
+ // S12 = Found [2000 - "], looking for ["] (["]=S1)
+ // S13 = Found [2000 - 2], looking for WS (WS=S1)
- StateMachineState state = S01;
+ StateEnum state = S1;
int mark = 0;
Equality eq = Equality.NONE;
String s1 = null, s2 = null;
@@ -129,139 +128,139 @@ public class TimeMatcherFactory extends MatcherFactory {
char c = 0;
for (i = 0; i < s.trim().length(); i++) {
c = s.charAt(i);
- if (state == S01) {
- // S01 = Looking for [>]/[<]/quote/NUM
([>]=S02, [<]=S03, [']=S05, ["]=S06, NUM=S08)
+ if (state == S1) {
+ // S1 = Looking for [>]/[<]/quote/NUM
([>]=S2, [<]=S3, [']=S5, ["]=S6, NUM=S8)
if (WS.contains(c)) {
- state = S01;
+ state = S1;
} else if (c == '>') {
- state = S02;
+ state = S2;
eq = Equality.GT;
} else if (c == '<') {
- state = S03;
+ state = S3;
eq = Equality.LT;
} else if (c == '\'') {
- state = S05;
+ state = S5;
mark = i + 1;
} else if (c == '"') {
- state = S06;
+ state = S6;
mark = i + 1;
} else if (DT.contains(c)) {
- state = S08;
+ state = S8;
mark = i;
} else {
break;
}
- } else if (state == S02) {
- // S02 = Found [>], looking for
[=]/quote/NUM ([=]=S04, [']=S05, ["]=S06, NUM=S08)
+ } else if (state == S2) {
+ // S2 = Found [>], looking for
[=]/quote/NUM ([=]=S4, [']=S5, ["]=S6, NUM=S8)
if (WS.contains(c)) {
- state = S02;
+ state = S2;
} else if (c == '=') {
- state = S04;
+ state = S4;
eq = Equality.GTE;
} else if (c == '\'') {
- state = S05;
+ state = S5;
mark = i + 1;
} else if (c == '"') {
- state = S06;
+ state = S6;
mark = i + 1;
} else if (DT.contains(c)) {
- state = S08;
+ state = S8;
mark = i;
} else {
break;
}
- } else if (state == S03) {
- // S03 = Found [<], looking for
[=]/quote/NUM ([=]=S04, [']=S05, ["]=S06, NUM=S08)
+ } else if (state == S3) {
+ // S3 = Found [<], looking for
[=]/quote/NUM ([=]=S4, [']=S5, ["]=S6, NUM=S8)
if (WS.contains(c)) {
- state = S03;
+ state = S3;
} else if (c == '=') {
- state = S04;
+ state = S4;
eq = Equality.LTE;
} else if (c == '\'') {
- state = S05;
+ state = S5;
mark = i + 1;
} else if (c == '"') {
- state = S06;
+ state = S6;
mark = i + 1;
} else if (DT.contains(c)) {
- state = S08;
+ state = S8;
mark = i;
} else {
break;
}
- } else if (state == S04) {
- // S04 = Found [>=] or [<=], looking
for quote/NUM ([']=S05, ["]=S06, NUM=S08)
+ } else if (state == S4) {
+ // S4 = Found [>=] or [<=], looking for
quote/NUM ([']=S5, ["]=S6, NUM=S8)
if (WS.contains(c)) {
- state = S04;
+ state = S4;
} else if (c == '\'') {
- state = S05;
+ state = S5;
mark = i + 1;
} else if (c == '"') {
- state = S06;
+ state = S6;
mark = i + 1;
} else if (DT.contains(c)) {
- state = S08;
+ state = S8;
mark = i;
} else {
break;
}
- } else if (state == S05) {
- // S05 = Found ['], looking for [']
([']=S07)
+ } else if (state == S5) {
+ // S5 = Found ['], looking for [']
([']=S7)
if (c == '\'') {
- state = S07;
+ state = S7;
s1 = s.substring(mark, i);
}
- } else if (state == S06) {
- // S06 = Found ["], looking for ["]
(["]=S07)
+ } else if (state == S6) {
+ // S6 = Found ["], looking for ["]
(["]=S7)
if (c == '"') {
- state = S07;
+ state = S7;
s1 = s.substring(mark, i);
}
- } else if (state == S07) {
- // S07 = Found [123"] or [123'],
looking for WS (WS=S09)
+ } else if (state == S7) {
+ // S7 = Found [123"] or [123'], looking
for WS (WS=S9)
if (WS.contains(c)) {
- state = S09;
+ state = S9;
} else if (c == '-') {
state = S10;
} else {
break;
}
- } else if (state == S08) {
- // S08 = Found [1], looking for WS
(WS=S09)
+ } else if (state == S8) {
+ // S8 = Found [1], looking for WS
(WS=S9)
if (WS.contains(c)) {
- state = S09;
+ state = S9;
s1 = s.substring(mark, i);
}
- } else if (state == S09) {
- // S09 = Found [2000 ], looking for
[-]/[>]/[<]/quote/NUM ([-]=S10, [>]=S02, [<]=S03, [']=S05, ["]=S06, NUM=S08)
+ } else if (state == S9) {
+ // S9 = Found [2000 ], looking for
[-]/[>]/[<]/quote/NUM ([-]=S10, [>]=S2, [<]=S3, [']=S5, ["]=S6, NUM=S8)
if (WS.contains(c)) {
- state = S09;
+ state = S9;
} else if (c == '-') {
state = S10;
} else if (c == '>') {
- state = S02;
+ state = S2;
l.add(new TimestampRange(eq,
s1));
eq = Equality.GT;
s1 = null;
} else if (c == '<') {
- state = S03;
+ state = S3;
l.add(new TimestampRange(eq,
s1));
eq = Equality.LT;
s1 = null;
} else if (c == '\'') {
- state = S05;
+ state = S5;
l.add(new TimestampRange(eq,
s1));
mark = i + 1;
eq = null;
s1 = null;
} else if (c == '"') {
- state = S06;
+ state = S6;
l.add(new TimestampRange(eq,
s1));
mark = i + 1;
eq = null;
s1 = null;
} else if (DT.contains(c)) {
- state = S08;
+ state = S8;
l.add(new TimestampRange(eq,
s1));
eq = null;
s1 = null;
@@ -286,27 +285,27 @@ public class TimeMatcherFactory extends MatcherFactory {
break;
}
} else if (state == S11) {
- // S11 = Found [2000 - '], looking for
['] ([']=S01)
+ // S11 = Found [2000 - '], looking for
['] ([']=S1)
if (c == '\'') {
- state = S01;
+ state = S1;
s2 = s.substring(mark, i);
l.add(new TimestampRange(s1,
s2));
s1 = null;
s2 = null;
}
} else if (state == S12) {
- // S12 = Found [2000 - "], looking for
["] (["]=S01)
+ // S12 = Found [2000 - "], looking for
["] (["]=S1)
if (c == '"') {
- state = S01;
+ state = S1;
s2 = s.substring(mark, i);
l.add(new TimestampRange(s1,
s2));
s1 = null;
s2 = null;
}
} else /* (state == S13) */ {
- // S13 = Found [2000 - 2], looking for
WS (WS=S01)
+ // S13 = Found [2000 - 2], looking for
WS (WS=S1)
if (WS.contains(c)) {
- state = S01;
+ state = S1;
s2 = s.substring(mark, i);
l.add(new TimestampRange(s1,
s2));
s1 = null;
@@ -318,13 +317,13 @@ public class TimeMatcherFactory extends MatcherFactory {
if (i != s.length())
throw new PatternException("Invalid range
pattern ({0}): pattern=[{1}], pos=[{2}], char=[{3}]", state, s, i, c);
- if (state == S01) {
+ if (state == S1) {
// No tokens found.
- } else if (state == S02 || state == S03 || state == S04
|| state == S05 || state == S06 || state == S10 || state == S11 || state ==
S12) {
+ } else if (state == S2 || state == S3 || state == S4 ||
state == S5 || state == S6 || state == S10 || state == S11 || state == S12) {
throw new PatternException("Invalid range
pattern (E{0}): {1}", state, s);
- } else if (state == S07) {
+ } else if (state == S7) {
l.add(new TimestampRange(eq, s1));
- } else if (state == S08) {
+ } else if (state == S8) {
s1 = s.substring(mark).trim();
l.add(new TimestampRange(eq, s1));
} else /* (state == S13) */ {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/StringExpressionMatcher.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/StringExpressionMatcher.java
index a42b278f48..92149e96eb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/StringExpressionMatcher.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/StringExpressionMatcher.java
@@ -16,15 +16,14 @@
*/
package org.apache.juneau.utils;
+import static org.apache.juneau.common.utils.StateEnum.*;
import static org.apache.juneau.common.utils.Utils.*;
-import static org.apache.juneau.internal.StateMachineState.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
import org.apache.juneau.common.utils.*;
-import org.apache.juneau.internal.*;
/**
* Utility class for matching strings against string expressions.
@@ -238,30 +237,30 @@ public class StringExpressionMatcher {
List<Exp> ors = list();
List<Exp> ands = list();
- StateMachineState state = S01;
+ StateEnum state = S1;
int i = 0, mark = -1;
int pDepth = 0;
boolean error = false;
for (i = 0; i < expression.length(); i++) {
char c = expression.charAt(i);
- if (state == S01) {
- // S01 = Looking for start
+ if (state == S1) {
+ // S1 = Looking for start
if (! WS.contains(c)) {
if (c == '(') {
- state = S02;
+ state = S2;
pDepth = 0;
mark = i + 1;
} else if (OP.contains(c)) {
error = true;
break;
} else {
- state = S03;
+ state = S3;
mark = i;
}
}
- } else if (state == S02) {
- // S02 = Found [(], looking for [)].
+ } else if (state == S2) {
+ // S2 = Found [(], looking for [)].
if (c == '(')
pDepth++;
if (c == ')') {
@@ -270,37 +269,37 @@ public class StringExpressionMatcher {
else {
ands.add(parse(expression.substring(mark, i)));
mark = -1;
- state = S04;
+ state = S4;
}
}
- } else if (state == S03) {
- // S03 = Found [A], looking for end of A.
+ } else if (state == S3) {
+ // S3 = Found [A], looking for end of A.
if (WS.contains(c) || OP.contains(c)) {
ands.add(parseOperand(expression.substring(mark, i)));
mark = -1;
if (WS.contains(c)) {
- state = S04;
+ state = S4;
} else {
i--;
- state = S05;
+ state = S5;
}
}
- } else if (state == S04) {
- // S04 = Found [A ], looking for & or | or ,.
+ } else if (state == S4) {
+ // S4 = Found [A ], looking for & or | or ,.
if (! WS.contains(c)) {
if (OP.contains(c)) {
i--;
- state = S05;
+ state = S5;
} else {
error = true;
break;
}
}
- } else if (state == S05) {
- // S05 = Found & or | or ,.
+ } else if (state == S5) {
+ // S5 = Found & or | or ,.
if (c == '&') {
//ands.add(operand);
- state = S06;
+ state = S6;
} else /* (c == '|' || c == ',') */ {
if (ands.size() == 1) {
ors.add(ands.get(0));
@@ -309,24 +308,24 @@ public class StringExpressionMatcher {
}
ands.clear();
if (c == '|') {
- state = S07;
+ state = S7;
} else {
- state = S01;
+ state = S1;
}
}
- } else if (state == S06) {
- // S06 = Found &, looking for & or other
+ } else if (state == S6) {
+ // S6 = Found &, looking for & or other
if (! WS.contains(c)) {
if (c != '&')
i--;
- state = S01;
+ state = S1;
}
- } else /* (state == S07) */ {
- // S07 = Found |, looking for | or other
+ } else /* (state == S7) */ {
+ // S7 = Found |, looking for | or other
if (! WS.contains(c)) {
if (c != '|')
i--;
- state = S01;
+ state = S1;
}
}
}
@@ -334,11 +333,11 @@ public class StringExpressionMatcher {
if (error)
throw new ParseException("Invalid character in
expression '" + expression + "' at position " + i + ". state=" + state, i);
- if (state == S01)
+ if (state == S1)
throw new ParseException("Could not find beginning of
clause in '" + expression + "'", i);
- if (state == S02)
+ if (state == S2)
throw new ParseException("Could not find matching
parenthesis in expression '" + expression + "'", i);
- if (state == S05 || state == S06 || state == S07)
+ if (state == S5 || state == S6 || state == S7)
throw new ParseException("Dangling clause in expression
'" + expression + "'", i);
if (mark != -1)
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 9510501f3d..b098da5349 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -19,6 +19,7 @@ package org.apache.juneau.rest.client;
import static java.lang.Character.*;
import static java.util.logging.Level.*;
import static org.apache.juneau.collections.JsonMap.*;
+import static org.apache.juneau.common.utils.StateEnum.*;
import static org.apache.juneau.common.utils.ThrowableUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import static org.apache.juneau.http.HttpEntities.*;
@@ -26,7 +27,6 @@ import static org.apache.juneau.http.HttpHeaders.*;
import static org.apache.juneau.http.HttpMethod.*;
import static org.apache.juneau.http.HttpParts.*;
import static org.apache.juneau.httppart.HttpPartType.*;
-import static org.apache.juneau.internal.StateMachineState.*;
import static org.apache.juneau.rest.client.RestOperation.*;
import java.io.*;
@@ -78,7 +78,6 @@ import org.apache.juneau.http.remote.*;
import org.apache.juneau.http.resource.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.httppart.bean.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
import org.apache.juneau.marshaller.*;
import org.apache.juneau.msgpack.*;
@@ -6168,42 +6167,42 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
public RestRequest callback(String callString) throws RestCallException
{
callString = emptyIfNull(callString);
- // S01 - Looking for end of method.
- // S02 - Found end of method, looking for beginning of URI or
headers.
- // S03 - Found beginning of headers, looking for end of headers.
- // S04 - Found end of headers, looking for beginning of URI.
- // S05 - Found beginning of URI, looking for end of URI.
+ // S1 - Looking for end of method.
+ // S2 - Found end of method, looking for beginning of URI or
headers.
+ // S3 - Found beginning of headers, looking for end of headers.
+ // S4 - Found end of headers, looking for beginning of URI.
+ // S5 - Found beginning of URI, looking for end of URI.
- StateMachineState state = S01;
+ StateEnum state = S1;
int mark = 0;
String method = null, headers = null, uri = null, content =
null;
for (int i = 0; i < callString.length(); i++) {
char c = callString.charAt(i);
- if (state == S01) {
+ if (state == S1) {
if (isWhitespace(c)) {
method = callString.substring(mark, i);
- state = S02;
+ state = S2;
}
- } else if (state == S02) {
+ } else if (state == S2) {
if (! isWhitespace(c)) {
mark = i;
if (c == '{')
- state = S03;
+ state = S3;
else
- state = S05;
+ state = S5;
}
- } else if (state == S03) {
+ } else if (state == S3) {
if (c == '}') {
headers = callString.substring(mark, i
+ 1);
- state = S04;
+ state = S4;
}
- } else if (state == S04) {
+ } else if (state == S4) {
if (! isWhitespace(c)) {
mark = i;
- state = S05;
+ state = S5;
}
- } else /* (state == S05) */ {
+ } else /* (state == S5) */ {
if (isWhitespace(c)) {
uri = callString.substring(mark, i);
content =
callString.substring(i).trim();
@@ -6212,7 +6211,7 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
}
}
- if (state != S05)
+ if (state != S5)
throw new RestCallException(null, null, "Invalid format
for call string. State={0}", state);
try {
diff --git
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
index 139a397fc3..1f9ee70176 100644
---
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
+++
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockPathResolver.java
@@ -16,15 +16,14 @@
*/
package org.apache.juneau.rest.mock;
+import static org.apache.juneau.common.utils.StateEnum.*;
import static org.apache.juneau.common.utils.Utils.*;
-import static org.apache.juneau.internal.StateMachineState.*;
import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.common.utils.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.rest.util.*;
/**
@@ -154,12 +153,12 @@ class MockPathResolver {
// Path starts with http[s]: so we have to parse it to resolve
variables.
this.uri = pathToResolve;
- // S03 - Found "http://", looking for any character other than
'/' (end of target).
- // S04 - Found any character, looking for 3rd '/' (end of
target).
- // S05 - Found 3rd '/', resolving contextPath.
- // S06 - Resolved contextPath, resolving servletPath.
- // S07 - Resolved servletPath.
- StateMachineState state = S03;
+ // S3 - Found "http://", looking for any character other than
'/' (end of target).
+ // S4 - Found any character, looking for 3rd '/' (end of
target).
+ // S5 - Found 3rd '/', resolving contextPath.
+ // S6 - Resolved contextPath, resolving servletPath.
+ // S7 - Resolved servletPath.
+ StateEnum state = S3;
int cpSegments = StringUtils.countChars(contextPath, '/');
int spSegments = StringUtils.countChars(servletPath, '/');
@@ -171,54 +170,54 @@ class MockPathResolver {
int mark = 0;
for (int i = uri.indexOf("://") + 3; i < uri.length(); i++) {
char c = uri.charAt(i);
- if (state == S03) {
+ if (state == S3) {
if (c != '/')
- state = S04;
+ state = S4;
else
break;
- } else if (state == S04) {
+ } else if (state == S4) {
if (c == '/') {
this.target = uri.substring(0, i);
- state = S05;
+ state = S5;
if (contextPath.isEmpty()) {
- state = S06;
+ state = S6;
if (servletPath.isEmpty()) {
- state = S07;
+ state = S7;
}
}
mark = i;
}
- } else if (state == S05) {
+ } else if (state == S5) {
if (c == '/') {
cpSegments--;
if (cpSegments == 0) {
this.contextPath =
uri.substring(mark, i);
mark = i;
- state = S06;
+ state = S6;
if (servletPath.isEmpty()) {
- state = S07;
+ state = S7;
}
}
}
- } else if (state == S06) {
+ } else if (state == S6) {
if (c == '/') {
spSegments--;
if (spSegments == 0) {
this.servletPath =
uri.substring(mark, i);
mark = i;
- state = S07;
+ state = S7;
}
}
}
}
- if (state == S04) {
+ if (state == S4) {
this.target = uri;
- } else if (state == S05) {
+ } else if (state == S5) {
this.contextPath = uri.substring(mark);
- } else if (state == S06) {
+ } else if (state == S6) {
this.servletPath = uri.substring(mark);
- } else if (state == S07) {
+ } else if (state == S7) {
this.remainder = uri.substring(mark);
} else {
throw new BasicRuntimeException("Invalid URI pattern
encountered: {0}", uri);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/guard/RoleMatcher.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/guard/RoleMatcher.java
index 9fa557fcf1..afe7b73366 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/guard/RoleMatcher.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/guard/RoleMatcher.java
@@ -16,15 +16,14 @@
*/
package org.apache.juneau.rest.guard;
+import static org.apache.juneau.common.utils.StateEnum.*;
import static org.apache.juneau.common.utils.Utils.*;
-import static org.apache.juneau.internal.StateMachineState.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
import org.apache.juneau.common.utils.*;
-import org.apache.juneau.internal.*;
/**
* Utility class for matching JEE user roles against string expressions.
@@ -246,30 +245,30 @@ public class RoleMatcher {
List<Exp> ors = list();
List<Exp> ands = list();
- StateMachineState state = S01;
+ StateEnum state = S1;
int i = 0, mark = -1;
int pDepth = 0;
boolean error = false;
for (i = 0; i < expression.length(); i++) {
char c = expression.charAt(i);
- if (state == S01) {
- // S01 = Looking for start
+ if (state == S1) {
+ // S1 = Looking for start
if (! WS.contains(c)) {
if (c == '(') {
- state = S02;
+ state = S2;
pDepth = 0;
mark = i + 1;
} else if (OP.contains(c)) {
error = true;
break;
} else {
- state = S03;
+ state = S3;
mark = i;
}
}
- } else if (state == S02) {
- // S02 = Found [(], looking for [)].
+ } else if (state == S2) {
+ // S2 = Found [(], looking for [)].
if (c == '(')
pDepth++;
if (c == ')') {
@@ -278,37 +277,37 @@ public class RoleMatcher {
else {
ands.add(parse(expression.substring(mark, i)));
mark = -1;
- state = S04;
+ state = S4;
}
}
- } else if (state == S03) {
- // S03 = Found [A], looking for end of A.
+ } else if (state == S3) {
+ // S3 = Found [A], looking for end of A.
if (WS.contains(c) || OP.contains(c)) {
ands.add(parseOperand(expression.substring(mark, i)));
mark = -1;
if (WS.contains(c)) {
- state = S04;
+ state = S4;
} else {
i--;
- state = S05;
+ state = S5;
}
}
- } else if (state == S04) {
- // S04 = Found [A ], looking for & or | or ,.
+ } else if (state == S4) {
+ // S4 = Found [A ], looking for & or | or ,.
if (! WS.contains(c)) {
if (OP.contains(c)) {
i--;
- state = S05;
+ state = S5;
} else {
error = true;
break;
}
}
- } else if (state == S05) {
- // S05 = Found & or | or ,.
+ } else if (state == S5) {
+ // S5 = Found & or | or ,.
if (c == '&') {
//ands.add(operand);
- state = S06;
+ state = S6;
} else /* (c == '|' || c == ',') */ {
if (ands.size() == 1) {
ors.add(ands.get(0));
@@ -317,24 +316,24 @@ public class RoleMatcher {
}
ands.clear();
if (c == '|') {
- state = S07;
+ state = S7;
} else {
- state = S01;
+ state = S1;
}
}
- } else if (state == S06) {
- // S06 = Found &, looking for & or other
+ } else if (state == S6) {
+ // S6 = Found &, looking for & or other
if (! WS.contains(c)) {
if (c != '&')
i--;
- state = S01;
+ state = S1;
}
- } else /* (state == S07) */ {
- // S07 = Found |, looking for | or other
+ } else /* (state == S7) */ {
+ // S7 = Found |, looking for | or other
if (! WS.contains(c)) {
if (c != '|')
i--;
- state = S01;
+ state = S1;
}
}
}
@@ -342,11 +341,11 @@ public class RoleMatcher {
if (error)
throw new ParseException("Invalid character in
expression '" + expression + "' at position " + i + ". state=" + state, i);
- if (state == S01)
+ if (state == S1)
throw new ParseException("Could not find beginning of
clause in '" + expression + "'", i);
- if (state == S02)
+ if (state == S2)
throw new ParseException("Could not find matching
parenthesis in expression '" + expression + "'", i);
- if (state == S05 || state == S06 || state == S07)
+ if (state == S5 || state == S6 || state == S7)
throw new ParseException("Dangling clause in expression
'" + expression + "'", i);
if (mark != -1)
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/objecttools/ObjectSearcher_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/objecttools/ObjectSearcher_Test.java
index 921bd62612..7b98e38fda 100755
---
a/juneau-utest/src/test/java/org/apache/juneau/objecttools/ObjectSearcher_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/objecttools/ObjectSearcher_Test.java
@@ -354,22 +354,22 @@ public class ObjectSearcher_Test extends TestBase {
@Test void b25_intSearch_badSearches() {
var ss = a(
- "f=x","(S01)",
- "f=>x","(S02)",
- "f=<x","(S03)",
- "f=>=x","(S04)",
- "f=>= x","(S05)",
- "f=1x","(S06)",
- "f=1 x","(S07)",
- "f=1-x","(S08)",
- "f=1 -x","(S09)",
+ "f=x","(S1)",
+ "f=>x","(S2)",
+ "f=<x","(S3)",
+ "f=>=x","(S4)",
+ "f=>= x","(S5)",
+ "f=1x","(S6)",
+ "f=1 x","(S7)",
+ "f=1-x","(S8)",
+ "f=1 -x","(S9)",
"f=1 - x","(S10)",
"f=1 - 1x","(S11)",
- "f=>","(ES02)",
- "f=<","(ES03)",
- "f=>=","(ES04)",
- "f=123-","(ES08)",
- "f=123 -","(ES09)"
+ "f=>","(ES2)",
+ "f=<","(ES3)",
+ "f=>=","(ES4)",
+ "f=123-","(ES8)",
+ "f=123 -","(ES9)"
);
for (var i = 0; i < ss.length; i+=2) {