Skip to content

Commit 2bd9b21

Browse files
committed
java codegen: upgrade deps
1 parent 36e3080 commit 2bd9b21

File tree

2 files changed

+13
-157
lines changed

2 files changed

+13
-157
lines changed

schema_salad/java/main_utils/YamlUtils.java

Lines changed: 3 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -11,163 +11,19 @@
1111
import org.snakeyaml.engine.v2.api.LoadSettings;
1212
import org.snakeyaml.engine.v2.nodes.Tag;
1313
import org.snakeyaml.engine.v2.resolver.ScalarResolver;
14-
15-
// Copied from org.snakeyaml.engine.v2.resolver.ResolverTuple because it was marked non-public
16-
/**
17-
* Copyright (c) 2018, http://www.snakeyaml.org
18-
* <p>
19-
* Licensed under the Apache License, Version 2.0 (the "License");
20-
* you may not use this file except in compliance with the License.
21-
* You may obtain a copy of the License at
22-
* <p>
23-
* http://www.apache.org/licenses/LICENSE-2.0
24-
* <p>
25-
* Unless required by applicable law or agreed to in writing, software
26-
* distributed under the License is distributed on an "AS IS" BASIS,
27-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28-
* See the License for the specific language governing permissions and
29-
* limitations under the License.
30-
*/
31-
final class ResolverTuple {
32-
private final Tag tag;
33-
private final Pattern regexp;
34-
35-
public ResolverTuple(Tag tag, Pattern regexp) {
36-
Objects.requireNonNull(tag, "Tag must be provided");
37-
Objects.requireNonNull(regexp, "regexp must be provided");
38-
this.tag = tag;
39-
this.regexp = regexp;
40-
}
41-
42-
public Tag getTag() {
43-
return tag;
44-
}
45-
46-
public Pattern getRegexp() {
47-
return regexp;
48-
}
49-
50-
@Override
51-
public String toString() {
52-
return "Tuple tag=" + tag + " regexp=" + regexp;
53-
}
54-
}
55-
56-
57-
// Adapted from org.snakeyaml.engine.v2.resolver.JsonScalarResolver
58-
// Not guaranteed to be complete coverage of the YAML 1.2 Core Schema
59-
// 2021-02-03 Supports 'True'/'False'/'TRUE','FALSE' as boolean; 'Null', 'NULL', an '~' as null
60-
/**
61-
* Copyright (c) 2018, http://www.snakeyaml.org
62-
* <p>
63-
* Licensed under the Apache License, Version 2.0 (the "License");
64-
* you may not use this file except in compliance with the License.
65-
* You may obtain a copy of the License at
66-
* <p>
67-
* http://www.apache.org/licenses/LICENSE-2.0
68-
* <p>
69-
* Unless required by applicable law or agreed to in writing, software
70-
* distributed under the License is distributed on an "AS IS" BASIS,
71-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72-
* See the License for the specific language governing permissions and
73-
* limitations under the License.
74-
*/
75-
class CoreScalarResolver implements ScalarResolver {
76-
public final Pattern BOOL = Pattern.compile("^(?:true|false|True|False|TRUE|FALSE)$");
77-
public static final Pattern FLOAT = Pattern
78-
.compile("^(-?(0?\\.[0-9]+|[1-9][0-9]*(\\.[0-9]*)?)(e[-+]?[0-9]+)?)|-?\\.(?:inf)|\\.(?:nan)$"); // NOSONAR
79-
public static final Pattern INT = Pattern.compile("^(?:-?(?:0|[1-9][0-9]*))$");
80-
public static final Pattern NULL = Pattern.compile("^(?:null|Null|NULL|~)$");
81-
public static final Pattern EMPTY = Pattern.compile("^$");
82-
83-
public static final Pattern ENV_FORMAT = Pattern
84-
.compile("^\\$\\{\\s*((?<name>\\w+)((?<separator>:?(-|\\?))(?<value>\\w+)?)?)\\s*\\}$");
85-
86-
protected Map<Character, List<ResolverTuple>> yamlImplicitResolvers = new HashMap<Character, List<ResolverTuple>>();
87-
88-
public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
89-
if (first == null) {
90-
List<ResolverTuple> curr = yamlImplicitResolvers.computeIfAbsent(null, c -> new ArrayList<ResolverTuple>());
91-
curr.add(new ResolverTuple(tag, regexp));
92-
} else {
93-
char[] chrs = first.toCharArray();
94-
for (int i = 0, j = chrs.length; i < j; i++) {
95-
Character theC = Character.valueOf(chrs[i]);
96-
if (theC == 0) {
97-
// special case: for null
98-
theC = null;
99-
}
100-
List<ResolverTuple> curr = yamlImplicitResolvers.get(theC);
101-
if (curr == null) {
102-
curr = new ArrayList<ResolverTuple>();
103-
yamlImplicitResolvers.put(theC, curr);
104-
}
105-
curr.add(new ResolverTuple(tag, regexp));
106-
}
107-
}
108-
}
109-
110-
protected void addImplicitResolvers() {
111-
addImplicitResolver(Tag.NULL, EMPTY, null);
112-
addImplicitResolver(Tag.BOOL, BOOL, "tfTF");
113-
/*
114-
* INT must be before FLOAT because the regular expression for FLOAT matches INT
115-
* (see issue 130) http://code.google.com/p/snakeyaml/issues/detail?id=130
116-
*/
117-
addImplicitResolver(Tag.INT, INT, "-0123456789");
118-
addImplicitResolver(Tag.FLOAT, FLOAT, "-0123456789.");
119-
addImplicitResolver(Tag.NULL, NULL, "nN~\u0000");
120-
addImplicitResolver(Tag.ENV_TAG, ENV_FORMAT, "$");
121-
}
122-
123-
public CoreScalarResolver() {
124-
addImplicitResolvers();
125-
}
126-
127-
@Override
128-
public Tag resolve(String value, Boolean implicit) {
129-
if (!implicit) {
130-
return Tag.STR;
131-
}
132-
final List<ResolverTuple> resolvers;
133-
if (value.length() == 0) {
134-
resolvers = yamlImplicitResolvers.get('\0');
135-
} else {
136-
resolvers = yamlImplicitResolvers.get(value.charAt(0));
137-
}
138-
if (resolvers != null) {
139-
for (ResolverTuple v : resolvers) {
140-
Tag tag = v.getTag();
141-
Pattern regexp = v.getRegexp();
142-
if (regexp.matcher(value).matches()) {
143-
return tag;
144-
}
145-
}
146-
}
147-
if (yamlImplicitResolvers.containsKey(null)) {
148-
for (ResolverTuple v : yamlImplicitResolvers.get(null)) {
149-
Tag tag = v.getTag();
150-
Pattern regexp = v.getRegexp();
151-
if (regexp.matcher(value).matches()) {
152-
return tag;
153-
}
154-
}
155-
}
156-
return Tag.STR;
157-
}
158-
}
14+
import org.snakeyaml.engine.v2.schema.CoreSchema;
15915

16016
public class YamlUtils {
16117

16218
public static Map<String, Object> mapFromString(final String text) {
163-
LoadSettings settings = LoadSettings.builder().setScalarResolver(new CoreScalarResolver()).build();
19+
LoadSettings settings = LoadSettings.builder().setSchema(new CoreSchema()).build();
16420
Load load = new Load(settings);
16521
final Map<String, Object> result = (Map<String, Object>) load.loadFromString(text);
16622
return result;
16723
}
16824

16925
public static List<Object> listFromString(final String text) {
170-
LoadSettings settings = LoadSettings.builder().setScalarResolver(new CoreScalarResolver()).build();
26+
LoadSettings settings = LoadSettings.builder().setSchema(new CoreSchema()).build();
17127
Load load = new Load(settings);
17228
final List<Object> result = (List<Object>) load.loadFromString(text);
17329
return result;

schema_salad/java/pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
<plugin>
2727
<groupId>org.apache.maven.plugins</groupId>
2828
<artifactId>maven-deploy-plugin</artifactId>
29-
<version>2.8.2</version>
29+
<version>3.0.0</version>
3030
</plugin>
3131
<plugin>
3232
<groupId>org.apache.maven.plugins</groupId>
3333
<artifactId>maven-compiler-plugin</artifactId>
34-
<version>3.8.1</version>
34+
<version>3.10.1</version>
3535
<configuration>
3636
<release>11</release>
3737
<showDeprecation>true</showDeprecation>
@@ -58,14 +58,14 @@
5858
<plugin>
5959
<groupId>org.apache.maven.plugins</groupId>
6060
<artifactId>maven-javadoc-plugin</artifactId>
61-
<version>3.3.1</version>
61+
<version>3.4.1</version>
6262
<configuration>
6363
</configuration>
6464
</plugin>
6565
<plugin>
6666
<groupId>org.apache.maven.plugins</groupId>
6767
<artifactId>maven-jar-plugin</artifactId>
68-
<version>3.2.0</version>
68+
<version>3.3.0</version>
6969
<configuration>
7070
<archive>
7171
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
@@ -117,25 +117,25 @@
117117
<dependency>
118118
<groupId>org.snakeyaml</groupId>
119119
<artifactId>snakeyaml-engine</artifactId>
120-
<version>2.3</version>
120+
<version>2.6</version>
121121
</dependency>
122122
<dependency>
123123
<groupId>com.fasterxml.jackson.core</groupId>
124124
<artifactId>jackson-databind</artifactId>
125-
<version>[2.13.2.1,)</version>
125+
<version>2.14.2</version>
126126
</dependency>
127127
<dependency>
128128
<groupId>com.fasterxml.jackson.dataformat</groupId>
129129
<artifactId>jackson-dataformat-yaml</artifactId>
130-
<version>2.10.4</version>
130+
<version>2.14.2</version>
131131
</dependency>
132132
</dependencies>
133133
<profiles>
134134
<profile>
135-
<id>travis</id>
135+
<id>github</id>
136136
<activation>
137137
<property>
138-
<name>env.TRAVIS</name>
138+
<name>env.CI</name>
139139
<value>true</value>
140140
</property>
141141
</activation>
@@ -144,7 +144,7 @@
144144
<plugin>
145145
<groupId>org.jacoco</groupId>
146146
<artifactId>jacoco-maven-plugin</artifactId>
147-
<version>0.8.7</version>
147+
<version>0.8.8</version>
148148
<executions>
149149
<execution>
150150
<id>prepare-agent</id>

0 commit comments

Comments
 (0)