Skip to content

Commit d984c0e

Browse files
committed
TOML data format
1 parent 6444f00 commit d984c0e

23 files changed

+4371
-0
lines changed

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<module>csv</module>
1818
<module>properties</module>
1919
<module>yaml</module>
20+
<module>toml</module>
2021
</modules>
2122

2223
<url>https://github.com/FasterXML/jackson-dataformats-text</url>

toml/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Do not merge `pom.xml` from older version, as it will typically conflict
2+
3+
pom.xml merge=ours

toml/LICENSE

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Jackson is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt).
2+
3+
The TOML grammar and some parts of the test suite are adapted from the TOML project, which is licensed under the MIT license:
4+
5+
The MIT License
6+
7+
Copyright (c) Tom Preston-Werner
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.

toml/pom.xml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<!-- This module was also published with a richer model, Gradle metadata, -->
4+
<!-- which should be used instead. Do not delete the following line which -->
5+
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
6+
<!-- that they should prefer consuming it instead. -->
7+
<!-- do_not_remove: published-with-gradle-metadata -->
8+
<modelVersion>4.0.0</modelVersion>
9+
<parent>
10+
<groupId>com.fasterxml.jackson.dataformat</groupId>
11+
<artifactId>jackson-dataformats-text</artifactId>
12+
<version>3.0.0-SNAPSHOT</version>
13+
</parent>
14+
<artifactId>jackson-dataformat-toml</artifactId>
15+
<packaging>bundle</packaging>
16+
<name>Jackson-dataformat-TOML</name>
17+
<description>Support for reading and writing TOML-encoded data via Jackson abstractions.
18+
</description>
19+
<url>https://github.com/FasterXML/jackson-dataformats-text</url>
20+
21+
<properties>
22+
<packageVersion.dir>com/fasterxml/jackson/dataformat/toml</packageVersion.dir>
23+
<packageVersion.package>${project.groupId}.toml</packageVersion.package>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>com.fasterxml.jackson.core</groupId>
29+
<artifactId>jackson-databind</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.jetbrains</groupId>
34+
<artifactId>annotations</artifactId>
35+
<version>20.1.0</version>
36+
<scope>test</scope>
37+
</dependency>
38+
</dependencies>
39+
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
44+
<groupId>com.google.code.maven-replacer-plugin</groupId>
45+
<artifactId>replacer</artifactId>
46+
<executions>
47+
<execution>
48+
<id>process-packageVersion</id>
49+
<phase>generate-sources</phase>
50+
</execution>
51+
</executions>
52+
</plugin>
53+
<plugin>
54+
<groupId>org.moditect</groupId>
55+
<artifactId>moditect-maven-plugin</artifactId>
56+
</plugin>
57+
<plugin>
58+
<groupId>de.jflex</groupId>
59+
<artifactId>jflex-maven-plugin</artifactId>
60+
<version>1.8.2</version>
61+
<executions>
62+
<execution>
63+
<phase>generate-sources</phase>
64+
<goals>
65+
<goal>generate</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
<configuration>
70+
<backup>false</backup>
71+
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.fasterxml.jackson.dataformat.toml;
2+
3+
import com.fasterxml.jackson.core.JsonLocation;
4+
import com.fasterxml.jackson.core.JsonParser;
5+
import com.fasterxml.jackson.core.exc.StreamReadException;
6+
import com.fasterxml.jackson.core.io.ContentReference;
7+
8+
public class JacksonTomlParseException extends StreamReadException {
9+
private JacksonTomlParseException(JsonParser p, String msg, JsonLocation loc) {
10+
super(p, msg, loc);
11+
}
12+
13+
private JacksonTomlParseException(String msg, JsonLocation loc, Throwable rootCause) {
14+
super(msg, loc, rootCause);
15+
}
16+
17+
static class ErrorContext {
18+
private final ContentReference ContentReference;
19+
private final JsonParser parser;
20+
21+
ErrorContext(ContentReference ContentReference, JsonParser parser) {
22+
this.ContentReference = ContentReference;
23+
this.parser = parser;
24+
}
25+
26+
ErrorBuilder atPosition(Lexer lexer) {
27+
return new ErrorBuilder(lexer);
28+
}
29+
30+
class ErrorBuilder {
31+
private final JsonLocation location;
32+
33+
private ErrorBuilder(Lexer lexer) {
34+
this.location = new JsonLocation(
35+
ContentReference,
36+
-1,
37+
lexer.getCharPos(),
38+
lexer.getLine() + 1,
39+
lexer.getColumn() + 1
40+
);
41+
}
42+
43+
JacksonTomlParseException unexpectedToken(TomlToken actual, String expected) {
44+
return new JacksonTomlParseException(
45+
parser,
46+
"Unexpected token: Got " + actual + ", expected " + expected,
47+
location
48+
);
49+
}
50+
51+
JacksonTomlParseException generic(String message) {
52+
return new JacksonTomlParseException(parser, message, location);
53+
}
54+
55+
JacksonTomlParseException outOfBounds(NumberFormatException cause) {
56+
JacksonTomlParseException parseException = new JacksonTomlParseException("Number out of bounds", location, cause);
57+
parseException._processor = parser;
58+
return parseException;
59+
}
60+
}
61+
}
62+
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package @package@;
2+
3+
import com.fasterxml.jackson.core.Version;
4+
import com.fasterxml.jackson.core.Versioned;
5+
import com.fasterxml.jackson.core.util.VersionUtil;
6+
7+
/**
8+
* Automatically generated from PackageVersion.java.in during
9+
* packageVersion-generate execution of maven-replacer-plugin in
10+
* pom.xml.
11+
*/
12+
public final class PackageVersion implements Versioned {
13+
public final static Version VERSION = VersionUtil.parseVersion(
14+
"@projectversion@", "@projectgroupid@", "@projectartifactid@");
15+
16+
@Override
17+
public Version version() {
18+
return VERSION;
19+
}
20+
}

0 commit comments

Comments
 (0)