lint, comment, etc.
diff --git a/src/main/java/org/yaml/snakeyaml/nodes/Node.java b/src/main/java/org/yaml/snakeyaml/nodes/Node.java
index fa5030b..002cd10 100644
--- a/src/main/java/org/yaml/snakeyaml/nodes/Node.java
+++ b/src/main/java/org/yaml/snakeyaml/nodes/Node.java
@@ -23,12 +23,14 @@
/**
* Base class for all nodes.
* <p>
- * The nodes form the node-graph described in the <a href="http://yaml.org/spec/1.1/">YAML Specification</a>.
+ * The nodes form the node-graph described in the <a
+ * href="http://yaml.org/spec/1.1/">YAML Specification</a>.
* </p>
* <p>
- * While loading, the node graph is usually created by the {@link org.yaml.snakeyaml.composer.Composer}, and later
- * transformed into application specific Java classes by the classes from the {@link org.yaml.snakeyaml.constructor}
- * package.
+ * While loading, the node graph is usually created by the
+ * {@link org.yaml.snakeyaml.composer.Composer}, and later transformed into
+ * application specific Java classes by the classes from the
+ * {@link org.yaml.snakeyaml.constructor} package.
* </p>
*/
public abstract class Node {
@@ -121,11 +123,13 @@
/**
* Indicates if this node must be constructed in two steps.
* <p>
- * Two-step construction is required whenever a node is a child (direct or indirect) of it self. That is, if a recursive
- * structure is build using anchors and aliases.
+ * Two-step construction is required whenever a node is a child (direct or
+ * indirect) of it self. That is, if a recursive structure is build using
+ * anchors and aliases.
* </p>
* <p>
- * Set by {@link org.yaml.snakeyaml.composer.Composer}, used during the construction process.
+ * Set by {@link org.yaml.snakeyaml.composer.Composer}, used during the
+ * construction process.
* </p>
* <p>
* Only relevant during loading.
@@ -144,7 +148,8 @@
public boolean useClassConstructor() {
if (useClassConstructor == null) {
- if (!tag.isSecondary() && resolved && !Object.class.equals(type) && !tag.equals(Tag.NULL)) {
+ if (!tag.isSecondary() && resolved && !Object.class.equals(type)
+ && !tag.equals(Tag.NULL)) {
return true;
} else if (tag.isCompatible(getType())) {
// the tag is compatible with the runtime class
@@ -162,12 +167,12 @@
}
/**
- * Indicates if the tag was added by {@link org.yaml.snakeyaml.resolver.Resolver}.
+ * Indicates if the tag was added by
+ * {@link org.yaml.snakeyaml.resolver.Resolver}.
*
* @return true if the tag of this node was resolved
*
- * @deprecated Since v1.22. Absent in immediately prior versions, but present previously. Restored deprecated for
- * backwards compatibility.
+ * @deprecated Since v1.22. Absent in immediately prior versions, but present previously. Restored deprecated for backwards compatibility.
*/
@Deprecated
public boolean isResolved() {
diff --git a/src/main/java/org/yaml/snakeyaml/parser/ParserImpl.java b/src/main/java/org/yaml/snakeyaml/parser/ParserImpl.java
index 56a9c99..79e230a 100644
--- a/src/main/java/org/yaml/snakeyaml/parser/ParserImpl.java
+++ b/src/main/java/org/yaml/snakeyaml/parser/ParserImpl.java
@@ -206,7 +206,7 @@
return event;
}
}
-
+
private class ParseImplicitDocumentStart implements Production {
public Event produce() {
// Parse an implicit document.
@@ -409,7 +409,6 @@
Mark startMark = null;
Mark endMark = null;
Mark tagMark = null;
-
if (scanner.checkToken(Token.ID.Alias)) {
AliasToken token = (AliasToken) scanner.getToken();
event = new AliasEvent(token.getValue(), token.getStartMark(), token.getEndMark());
diff --git a/src/test/java/org/yaml/snakeyaml/comment/ComposerWithCommentEnabledTest.java b/src/test/java/org/yaml/snakeyaml/comment/ComposerWithCommentEnabledTest.java
index 4f592fb..2cc080c 100644
--- a/src/test/java/org/yaml/snakeyaml/comment/ComposerWithCommentEnabledTest.java
+++ b/src/test/java/org/yaml/snakeyaml/comment/ComposerWithCommentEnabledTest.java
@@ -1,49 +1,45 @@
+/**
+ * Copyright (c) 2020, http://www.snakeyaml.org
+ *
+ * Licensed 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.yaml.snakeyaml.comment;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import org.junit.Test;
-import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.comments.CommentLine;
import org.yaml.snakeyaml.composer.Composer;
import org.yaml.snakeyaml.constructor.SafeConstructor;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.Event.ID;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.NodeTuple;
import org.yaml.snakeyaml.nodes.ScalarNode;
import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.parser.Parser;
import org.yaml.snakeyaml.parser.ParserImpl;
import org.yaml.snakeyaml.reader.StreamReader;
import org.yaml.snakeyaml.resolver.Resolver;
public class ComposerWithCommentEnabledTest {
- @SuppressWarnings("unused")
- private void assertEventListEquals(List<ID> expectedEventIdList, Parser parser) {
- for (ID expectedEventId : expectedEventIdList) {
- parser.checkEvent(expectedEventId);
- Event event = parser.getEvent();
- System.out.println(event);
- if (event == null) {
- fail("Missing event: " + expectedEventId);
- }
- assertEquals(expectedEventId, event.getEventId());
- }
- }
-
private void printBlockComment(Node node, int level, PrintStream out) {
if (node.getBlockComments() != null) {
List<CommentLine> blockComments = node.getBlockComments();
@@ -119,7 +115,13 @@
private void printNodeList(List<Node> nodeList) {
System.out.println("BEGIN");
+ boolean first = true;
for (Node node : nodeList) {
+ if(first) {
+ first = false;
+ } else {
+ System.out.println("---");
+ }
printNodeInternal(node, 1, System.out);
}
System.out.println("DONE\n");
@@ -135,8 +137,14 @@
private void assertNodesEqual(String[] expecteds, List<Node> nodeList) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ boolean first = true;
try (PrintStream out = new PrintStream(baos)) {
for (Node node : nodeList) {
+ if(first) {
+ first = false;
+ } else {
+ out.println("---");
+ }
printNodeInternal(node, 0, out);
}
}
@@ -400,8 +408,9 @@
" ScalarNode: value3b", //
" InLine Comment", //
"End Comment", //
+ "---", //
"Block Comment", //
- "ScalarNode: ", // FIXME: should not be here
+ "ScalarNode: ", // This is an empty scalar created as this is an empty document
};
Composer sut = newComposerWithCommentsEnabled(data);
@@ -443,8 +452,6 @@
Composer sut = newComposerWithCommentsEnabled(data);
List<Node> result = getNodeList(sut);
- Node newNode = new Yaml().compose(new StringReader("a: b"));
- result.add(newNode);
printNodeList(result);
assertNodesEqual(expecteds, result);
diff --git a/src/test/java/org/yaml/snakeyaml/comment/EmitterWithCommentEnabledTest.java b/src/test/java/org/yaml/snakeyaml/comment/EmitterWithCommentEnabledTest.java
index 4bb8a17..fc2b383 100644
--- a/src/test/java/org/yaml/snakeyaml/comment/EmitterWithCommentEnabledTest.java
+++ b/src/test/java/org/yaml/snakeyaml/comment/EmitterWithCommentEnabledTest.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2020, http://www.snakeyaml.org
+ *
+ * Licensed 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.yaml.snakeyaml.comment;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/yaml/snakeyaml/comment/ParserWithCommentEnabledTest.java b/src/test/java/org/yaml/snakeyaml/comment/ParserWithCommentEnabledTest.java
index 5a31e08..46cb6eb 100644
--- a/src/test/java/org/yaml/snakeyaml/comment/ParserWithCommentEnabledTest.java
+++ b/src/test/java/org/yaml/snakeyaml/comment/ParserWithCommentEnabledTest.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2020, http://www.snakeyaml.org
+ *
+ * Licensed 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.yaml.snakeyaml.comment;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/yaml/snakeyaml/comment/ScannerWithCommentEnabledTest.java b/src/test/java/org/yaml/snakeyaml/comment/ScannerWithCommentEnabledTest.java
index f7fb4fe..15814e4 100644
--- a/src/test/java/org/yaml/snakeyaml/comment/ScannerWithCommentEnabledTest.java
+++ b/src/test/java/org/yaml/snakeyaml/comment/ScannerWithCommentEnabledTest.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2020, http://www.snakeyaml.org
+ *
+ * Licensed 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.yaml.snakeyaml.comment;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/yaml/snakeyaml/comment/SerializerWithCommentEnabledTest.java b/src/test/java/org/yaml/snakeyaml/comment/SerializerWithCommentEnabledTest.java
index 1ed7ccb..ad89d0f 100644
--- a/src/test/java/org/yaml/snakeyaml/comment/SerializerWithCommentEnabledTest.java
+++ b/src/test/java/org/yaml/snakeyaml/comment/SerializerWithCommentEnabledTest.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2020, http://www.snakeyaml.org
+ *
+ * Licensed 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.yaml.snakeyaml.comment;
import static org.junit.Assert.assertEquals;