Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/autermann/yaml
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/autermann/yaml:
  raise snakeyaml version and apply required changes
  • Loading branch information
autermann committed Jul 21, 2023
2 parents 342e633 + f26d5ba commit 75d8dd1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>com.github.autermann</groupId>
<artifactId>yaml</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>YAML API</name>
Expand Down Expand Up @@ -84,7 +84,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.15</version>
<version>2.0</version>
</dependency>

<dependency>
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/github/autermann/yaml/YamlNodeRepresenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public YamlNodeRepresenter() {
* @param options the dumper options
*/
public YamlNodeRepresenter(DumperOptions options) {
super(options);
Objects.requireNonNull(options);
this.timeEncoding = ISODateTimeFormat.dateTime();
this.binaryEncoding = BaseEncoding.base64()
Expand Down Expand Up @@ -162,9 +163,9 @@ private Node delegate(Tag tag, Object value) {
private MappingNode delegate(Tag tag,
Iterable<Entry<YamlNode, YamlNode>> mapping) {
List<NodeTuple> value = new LinkedList<>();
MappingNode node = new MappingNode(tag, value, null);
MappingNode node = new MappingNode(tag, value, FlowStyle.AUTO);
representedObjects.put(objectToRepresent, node);
boolean bestStyle = true;
FlowStyle bestStyle = FlowStyle.AUTO;
for (Map.Entry<?, ?> entry : mapping) {
Node nodeKey = representData(entry.getKey());
Node nodeValue = representData(entry.getValue());
Expand All @@ -174,7 +175,7 @@ private MappingNode delegate(Tag tag,
}

if (getDefaultFlowStyle() != FlowStyle.AUTO) {
node.setFlowStyle(getDefaultFlowStyle().getStyleBoolean());
node.setFlowStyle(getDefaultFlowStyle());
} else {
node.setFlowStyle(bestStyle);
}
Expand All @@ -189,11 +190,11 @@ private MappingNode delegate(Tag tag,
*
* @return the new best style
*/
private boolean bestStyle(Node node, boolean bestStyle) {
private FlowStyle bestStyle(Node node, FlowStyle bestStyle) {
if (node instanceof ScalarNode) {
ScalarNode scalar = (ScalarNode) node;
if (scalar.getStyle() == null) {
return false;
if (scalar.getScalarStyle() == null) {
return FlowStyle.AUTO;
}
}
return bestStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.constructor.Construct;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.nodes.MappingNode;
Expand Down Expand Up @@ -87,6 +88,7 @@ public YamlNodeConstructor(YamlNodeFactory nodeFactory) {
*/
public YamlNodeConstructor(YamlNodeFactory nodeFactory,
DumperOptions options) {
super(new LoaderOptions());
this.options = Objects.requireNonNull(options);
this.nodeFactory = Objects.requireNonNull(nodeFactory);
register();
Expand Down Expand Up @@ -320,13 +322,11 @@ public List<? extends Object> constructSequence(SequenceNode node) {
* Constructs a scalar.
*
* @param node the node to construct from
*
* @return the constructed scalar
*
* @see SafeConstructor#constructScalar(ScalarNode)
*/
@Override
public Object constructScalar(ScalarNode node) {
public String constructScalar(ScalarNode node) {
return super.constructScalar(node);
}
}

0 comments on commit 75d8dd1

Please sign in to comment.