Skip to content

Commit f5b78c9

Browse files
committed
feat: Address Bar Query String Friendly (AQF) syntax
This is the initial AQF implementation. The vast majority of JsonUrlGrammar has been pulled out into AbstractGrammar.java so it can be shared by two implementations -- the base syntax and the AQF syntax.
1 parent 620208f commit f5b78c9

21 files changed

+2096
-988
lines changed

config/checkstyle.xml

+2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ Checkstyle configuration that checks the Google coding conventions from Google J
216216
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
217217
</module>
218218
<module name="SuppressionCommentFilter"/>
219+
<module name="SuppressWarningsHolder" />
219220
</module>
220221
<module name="BeforeExecutionExclusionFileFilter">
221222
<property name="fileNamePattern" value="module\-info\.java$"/>
@@ -228,4 +229,5 @@ Checkstyle configuration that checks the Google coding conventions from Google J
228229
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
229230
<property name="max" value="100"/>
230231
</module>
232+
<module name="SuppressWarningsFilter" />
231233
</module>

module/jsonurl-core/src/main/java/org/jsonurl/JsonUrlOption.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public enum JsonUrlOption {
4343
/**
4444
* The implied-string-literals option.
4545
* If this option is enabled then all literals are assumed to be strings.
46+
* @see #enableImpliedStringLiterals(Set)
4647
* @see <a href="https://github.com/jsonurl/specification/#292-implied-objects"
4748
* >JSON&#x2192;URL specification, section 2.9.2</a>
4849
*/
@@ -76,7 +77,12 @@ public enum JsonUrlOption {
7677
* If this option is enabled then {@code null} values in the
7778
* input or output will be replaced with an empty string.
7879
*/
79-
COERCE_NULL_TO_EMPTY_STRING;
80+
COERCE_NULL_TO_EMPTY_STRING,
81+
82+
/**
83+
* Address bar query string friendly.
84+
*/
85+
AQF;
8086

8187
/**
8288
* Create an empty set of options. This is just a convenience wrapper
@@ -93,7 +99,7 @@ public static final Set<JsonUrlOption> newSet() {
9399
public static final Set<JsonUrlOption> newSet(
94100
JsonUrlOption first,
95101
JsonUrlOption...rest) {
96-
return EnumSet.of(first, rest);
102+
return first == null ? null : EnumSet.of(first, rest);
97103
}
98104

99105
/**
@@ -218,4 +224,16 @@ public static final boolean optionCoerceNullToEmptyString(
218224
return options != null
219225
&& options.contains(COERCE_NULL_TO_EMPTY_STRING);
220226
}
227+
228+
/**
229+
* Test if the {@link #AQF} option is enabled,
230+
* supplying the default value if necessary.
231+
* @param options a valid Set or {@code null}.
232+
*/
233+
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
234+
public static final boolean optionAQF(
235+
Set<JsonUrlOption> options) {
236+
return options != null && options.contains(AQF);
237+
}
238+
221239
}

module/jsonurl-core/src/main/java/org/jsonurl/SyntaxException.java

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public enum Message {
3939
MSG_BAD_PCT_ENC("invalid percent-encoded sequence"),
4040
/** Invalid encoded UTF-8 sequence. */
4141
MSG_BAD_UTF8("invalid encoded UTF-8 sequence"),
42+
/** Invalid escape sequence. */
43+
MSG_BAD_ESCAPE("invalid escape sequence"),
4244
/** Text missing. */
4345
MSG_NO_TEXT("text missing"),
4446
/** Expected literal value. */

module/jsonurl-core/src/main/java/org/jsonurl/ValueType.java

+6-22
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,27 @@ public enum ValueType {
3030
/**
3131
* A {@code null} literal.
3232
*/
33-
NULL(null),
33+
NULL,
3434
/**
3535
* A {@code true} or {@code false} literal.
3636
*/
37-
BOOLEAN(null),
37+
BOOLEAN,
3838
/**
3939
* A number literal (e.g. 1, 1.2, 1e3, etc).
4040
*/
41-
NUMBER(null),
41+
NUMBER,
4242
/**
4343
* A string literal.
4444
*/
45-
STRING(null),
45+
STRING,
4646
/**
4747
* An array.
4848
*/
49-
ARRAY(CompositeType.ARRAY),
49+
ARRAY,
5050
/**
5151
* An object.
5252
*/
53-
OBJECT(CompositeType.OBJECT);
54-
55-
/**
56-
* see {@link #isPrimitive()}.
57-
*/
58-
private final CompositeType ctype;
59-
60-
ValueType(CompositeType ctype) {
61-
this.ctype = ctype;
62-
}
63-
64-
/**
65-
* Get the {@link CompositeType} for this ValueType.
66-
*/
67-
public CompositeType getCompositeType() {
68-
return ctype;
69-
}
53+
OBJECT;
7054

7155
/**
7256
* Test if the given EnumSet contains a composite value.

0 commit comments

Comments
 (0)