rename yaml Node to YamlNode

This commit is contained in:
kimchy 2010-04-09 00:06:05 +03:00
parent 8ecf71ffb8
commit 6379e8cc27
13 changed files with 102 additions and 102 deletions

View File

@ -23,7 +23,7 @@ import org.elasticsearch.util.yaml.snakeyaml.constructor.BaseConstructor;
import org.elasticsearch.util.yaml.snakeyaml.constructor.Constructor;
import org.elasticsearch.util.yaml.snakeyaml.error.YAMLException;
import org.elasticsearch.util.yaml.snakeyaml.events.Event;
import org.elasticsearch.util.yaml.snakeyaml.nodes.Node;
import org.elasticsearch.util.yaml.snakeyaml.nodes.YamlNode;
import org.elasticsearch.util.yaml.snakeyaml.parser.Parser;
import org.elasticsearch.util.yaml.snakeyaml.parser.ParserImpl;
import org.elasticsearch.util.yaml.snakeyaml.reader.StreamReader;
@ -81,7 +81,7 @@ public class Loader {
* @param yaml YAML document
* @return parsed root Node for the specified YAML document
*/
public Node compose(Reader yaml) {
public YamlNode compose(Reader yaml) {
Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
this.constructor.setComposer(composer);
return composer.getSingleNode();
@ -94,15 +94,15 @@ public class Loader {
* @param yaml stream of YAML documents
* @return parsed root Nodes for all the specified YAML documents
*/
public Iterable<Node> composeAll(Reader yaml) {
public Iterable<YamlNode> composeAll(Reader yaml) {
final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
this.constructor.setComposer(composer);
Iterator<Node> result = new Iterator<Node>() {
Iterator<YamlNode> result = new Iterator<YamlNode>() {
public boolean hasNext() {
return composer.checkNode();
}
public Node next() {
public YamlNode next() {
return composer.getNode();
}
@ -113,14 +113,14 @@ public class Loader {
return new NodeIterable(result);
}
private class NodeIterable implements Iterable<Node> {
private Iterator<Node> iterator;
private class NodeIterable implements Iterable<YamlNode> {
private Iterator<YamlNode> iterator;
public NodeIterable(Iterator<Node> iterator) {
public NodeIterable(Iterator<YamlNode> iterator) {
this.iterator = iterator;
}
public Iterator<Node> iterator() {
public Iterator<YamlNode> iterator() {
return iterator;
}

View File

@ -19,7 +19,7 @@
package org.elasticsearch.util.yaml.snakeyaml;
import org.elasticsearch.util.yaml.snakeyaml.events.Event;
import org.elasticsearch.util.yaml.snakeyaml.nodes.Node;
import org.elasticsearch.util.yaml.snakeyaml.nodes.YamlNode;
import org.elasticsearch.util.yaml.snakeyaml.reader.UnicodeReader;
import org.elasticsearch.util.yaml.snakeyaml.resolver.Resolver;
@ -130,7 +130,7 @@ public class Yaml {
* @param io stream of a YAML document
* @return parsed root Node for the specified YAML document
*/
public Node compose(Reader io) {
public YamlNode compose(Reader io) {
return loader.compose(io);
}
@ -141,7 +141,7 @@ public class Yaml {
* @param io stream of YAML documents
* @return parsed root Nodes for all the specified YAML documents
*/
public Iterable<Node> composeAll(Reader io) {
public Iterable<YamlNode> composeAll(Reader io) {
return loader.composeAll(io);
}

View File

@ -35,14 +35,14 @@ import java.util.*;
public class Composer {
private final Parser parser;
private final Resolver resolver;
private final Map<String, Node> anchors;
private final Set<Node> recursiveNodes;
private final Map<String, YamlNode> anchors;
private final Set<YamlNode> recursiveNodes;
public Composer(Parser parser, Resolver resolver) {
this.parser = parser;
this.resolver = resolver;
this.anchors = new HashMap<String, Node>();
this.recursiveNodes = new HashSet<Node>();
this.anchors = new HashMap<String, YamlNode>();
this.recursiveNodes = new HashSet<YamlNode>();
}
/**
@ -65,12 +65,12 @@ public class Composer {
* @return The root node of the document or <code>null</code> if no more
* documents are available.
*/
public Node getNode() {
public YamlNode getNode() {
// Get the root node of the next document.
if (!parser.checkEvent(Event.ID.StreamEnd)) {
return composeDocument();
} else {
return (Node) null;
return (YamlNode) null;
}
}
@ -83,11 +83,11 @@ public class Composer {
* @return The root node of the document or <code>null</code> if no document
* is available.
*/
public Node getSingleNode() {
public YamlNode getSingleNode() {
// Drop the STREAM-START event.
parser.getEvent();
// Compose a document if the stream is not empty.
Node document = null;
YamlNode document = null;
if (!parser.checkEvent(Event.ID.StreamEnd)) {
document = composeDocument();
}
@ -102,11 +102,11 @@ public class Composer {
return document;
}
private Node composeDocument() {
private YamlNode composeDocument() {
// Drop the DOCUMENT-START event.
parser.getEvent();
// Compose the root node.
Node node = composeNode(null, null);
YamlNode node = composeNode(null, null);
// Drop the DOCUMENT-END event.
parser.getEvent();
this.anchors.clear();
@ -114,7 +114,7 @@ public class Composer {
return node;
}
private Node composeNode(Node parent, Object index) {
private YamlNode composeNode(YamlNode parent, Object index) {
recursiveNodes.add(parent);
if (parser.checkEvent(Event.ID.Alias)) {
AliasEvent event = (AliasEvent) parser.getEvent();
@ -123,7 +123,7 @@ public class Composer {
throw new ComposerException(null, null, "found undefined alias " + anchor, event
.getStartMark());
}
Node result = (Node) anchors.get(anchor);
YamlNode result = (YamlNode) anchors.get(anchor);
if (recursiveNodes.remove(result)) {
result.setTwoStepsConstruction(true);
}
@ -138,7 +138,7 @@ public class Composer {
.getStartMark());
}
// resolver.descendResolver(parent, index);
Node node = null;
YamlNode node = null;
if (parser.checkEvent(Event.ID.Scalar)) {
node = composeScalarNode(anchor);
} else if (parser.checkEvent(Event.ID.SequenceStart)) {
@ -151,7 +151,7 @@ public class Composer {
return node;
}
private Node composeScalarNode(String anchor) {
private YamlNode composeScalarNode(String anchor) {
ScalarEvent ev = (ScalarEvent) parser.getEvent();
String tag = ev.getTag();
boolean resolved = false;
@ -162,7 +162,7 @@ public class Composer {
} else {
nodeTag = new Tag(tag);
}
Node node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(), ev
YamlNode node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(), ev
.getEndMark(), ev.getStyle());
if (anchor != null) {
anchors.put(anchor, node);
@ -170,7 +170,7 @@ public class Composer {
return node;
}
private Node composeSequenceNode(String anchor) {
private YamlNode composeSequenceNode(String anchor) {
SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
@ -181,7 +181,7 @@ public class Composer {
} else {
nodeTag = new Tag(tag);
}
SequenceNode node = new SequenceNode(nodeTag, resolved, new ArrayList<Node>(), startEvent
SequenceNode node = new SequenceNode(nodeTag, resolved, new ArrayList<YamlNode>(), startEvent
.getStartMark(), null, startEvent.getFlowStyle());
if (anchor != null) {
anchors.put(anchor, node);
@ -196,7 +196,7 @@ public class Composer {
return node;
}
private Node composeMappingNode(String anchor) {
private YamlNode composeMappingNode(String anchor) {
MappingStartEvent startEvent = (MappingStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
@ -213,8 +213,8 @@ public class Composer {
anchors.put(anchor, node);
}
while (!parser.checkEvent(Event.ID.MappingEnd)) {
Node itemKey = composeNode(node, null);
Node itemValue = composeNode(node, itemKey);
YamlNode itemKey = composeNode(node, null);
YamlNode itemValue = composeNode(node, itemKey);
node.getValue().add(new NodeTuple(itemKey, itemValue));
}
Event endEvent = parser.getEvent();

View File

@ -19,7 +19,7 @@
package org.elasticsearch.util.yaml.snakeyaml.constructor;
import org.elasticsearch.util.yaml.snakeyaml.error.YAMLException;
import org.elasticsearch.util.yaml.snakeyaml.nodes.Node;
import org.elasticsearch.util.yaml.snakeyaml.nodes.YamlNode;
/**
* Because recursive structures are not very common we provide a way to save
@ -31,10 +31,10 @@ public abstract class AbstractConstruct implements Construct {
* Fail with a reminder to provide the seconds step for a recursive
* structure
*
* @see org.elasticsearch.util.yaml.snakeyaml.constructor.Construct#construct2ndStep(org.elasticsearch.util.yaml.snakeyaml.nodes.Node,
* @see org.elasticsearch.util.yaml.snakeyaml.constructor.Construct#construct2ndStep(org.elasticsearch.util.yaml.snakeyaml.nodes.YamlNode ,
* java.lang.Object)
*/
public void construct2ndStep(Node node, Object data) {
public void construct2ndStep(YamlNode node, Object data) {
if (node.isTwoStepsConstruction()) {
throw new IllegalStateException("Not Implemented in " + getClass().getName());
} else {

View File

@ -50,16 +50,16 @@ public abstract class BaseConstructor {
protected final Map<String, Construct> yamlMultiConstructors = new HashMap<String, Construct>();
private Composer composer;
private final Map<Node, Object> constructedObjects;
private final Set<Node> recursiveObjects;
private final Map<YamlNode, Object> constructedObjects;
private final Set<YamlNode> recursiveObjects;
private final ArrayList<RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>> maps2fill;
private final ArrayList<RecursiveTuple<Set<Object>, Object>> sets2fill;
protected Tag rootTag;
public BaseConstructor() {
constructedObjects = new HashMap<Node, Object>();
recursiveObjects = new HashSet<Node>();
constructedObjects = new HashMap<YamlNode, Object>();
recursiveObjects = new HashSet<YamlNode>();
maps2fill = new ArrayList<RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>>();
sets2fill = new ArrayList<RecursiveTuple<Set<Object>, Object>>();
rootTag = null;
@ -87,7 +87,7 @@ public abstract class BaseConstructor {
public Object getData() {
// Construct and return the next document.
composer.checkNode();
Node node = composer.getNode();
YamlNode node = composer.getNode();
if (rootTag != null) {
node.setTag(rootTag);
}
@ -102,7 +102,7 @@ public abstract class BaseConstructor {
*/
public Object getSingleData() {
// Ensure that the stream contains a single document and construct it
Node node = composer.getSingleNode();
YamlNode node = composer.getSingleNode();
if (node != null) {
if (rootTag != null) {
node.setTag(rootTag);
@ -119,7 +119,7 @@ public abstract class BaseConstructor {
* @param node root Node
* @return Java instance
*/
private Object constructDocument(Node node) {
private Object constructDocument(YamlNode node) {
Object data = constructObject(node);
fillRecursive();
constructedObjects.clear();
@ -150,7 +150,7 @@ public abstract class BaseConstructor {
* @param node Node to be constructed
* @return Java instance
*/
protected Object constructObject(Node node) {
protected Object constructObject(YamlNode node) {
if (constructedObjects.containsKey(node)) {
return constructedObjects.get(node);
}
@ -177,7 +177,7 @@ public abstract class BaseConstructor {
* @param node Node to be constructed
* @return Construct implementation for the specified node
*/
protected Construct getConstructor(Node node) {
protected Construct getConstructor(YamlNode node) {
if (node.useClassConstructor()) {
return yamlClassConstructors.get(node.getNodeId());
} else {
@ -220,7 +220,7 @@ public abstract class BaseConstructor {
}
protected void constructSequenceStep2(SequenceNode node, List<Object> list) {
for (Node child : node.getValue()) {
for (YamlNode child : node.getValue()) {
list.add(constructObject(child));
}
}
@ -250,8 +250,8 @@ public abstract class BaseConstructor {
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
for (NodeTuple tuple : nodeValue) {
Node keyNode = tuple.getKeyNode();
Node valueNode = tuple.getValueNode();
YamlNode keyNode = tuple.getKeyNode();
YamlNode valueNode = tuple.getValueNode();
Object key = constructObject(keyNode);
if (key != null) {
try {
@ -282,7 +282,7 @@ public abstract class BaseConstructor {
protected void constructSet2ndStep(MappingNode node, Set<Object> set) {
List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
for (NodeTuple tuple : nodeValue) {
Node keyNode = tuple.getKeyNode();
YamlNode keyNode = tuple.getKeyNode();
Object key = constructObject(keyNode);
if (key != null) {
try {

View File

@ -18,7 +18,7 @@
*/
package org.elasticsearch.util.yaml.snakeyaml.constructor;
import org.elasticsearch.util.yaml.snakeyaml.nodes.Node;
import org.elasticsearch.util.yaml.snakeyaml.nodes.YamlNode;
/**
* Provide a way to construct a Java instance out of the composed Node. Support
@ -35,7 +35,7 @@ public interface Construct {
* @param node composed Node
* @return a complete Java instance
*/
public Object construct(Node node);
public Object construct(YamlNode node);
/**
* Apply the second step when constructing recursive structures. Because the
@ -45,5 +45,5 @@ public interface Construct {
* @param object the instance constructed earlier by
* <code>construct(Node node)</code> for the provided Node
*/
public void construct2ndStep(Node node, Object object);
public void construct2ndStep(YamlNode node, Object object);
}

View File

@ -125,7 +125,7 @@ public class Constructor extends SafeConstructor {
* <code>String</code>s) and values are objects to be created
* @return constructed JavaBean
*/
public Object construct(Node node) {
public Object construct(YamlNode node) {
MappingNode mnode = (MappingNode) node;
if (Properties.class.isAssignableFrom(node.getType())) {
Properties properties = new Properties();
@ -169,7 +169,7 @@ public class Constructor extends SafeConstructor {
}
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object object) {
public void construct2ndStep(YamlNode node, Object object) {
if (Map.class.isAssignableFrom(node.getType())) {
constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object);
} else if (Set.class.isAssignableFrom(node.getType())) {
@ -213,7 +213,7 @@ public class Constructor extends SafeConstructor {
} else {
throw new YAMLException("Keys must be scalars but found: " + tuple.getKeyNode());
}
Node valueNode = tuple.getValueNode();
YamlNode valueNode = tuple.getValueNode();
// keys can only be Strings
keyNode.setType(String.class);
String key = (String) constructObject(keyNode);
@ -338,7 +338,7 @@ public class Constructor extends SafeConstructor {
private class ConstructYamlObject implements Construct {
@SuppressWarnings("unchecked")
private Construct getConstructor(Node node) {
private Construct getConstructor(YamlNode node) {
Class cl = getClassForNode(node);
node.setType(cl);
// call the constructor as if the runtime class is defined
@ -346,7 +346,7 @@ public class Constructor extends SafeConstructor {
return constructor;
}
public Object construct(Node node) {
public Object construct(YamlNode node) {
Object result = null;
try {
result = getConstructor(node).construct(node);
@ -357,7 +357,7 @@ public class Constructor extends SafeConstructor {
return result;
}
public void construct2ndStep(Node node, Object object) {
public void construct2ndStep(YamlNode node, Object object) {
try {
getConstructor(node).construct2ndStep(node, object);
} catch (Exception e) {
@ -374,7 +374,7 @@ public class Constructor extends SafeConstructor {
*/
protected class ConstructScalar extends AbstractConstruct {
@SuppressWarnings("unchecked")
public Object construct(Node nnode) {
public Object construct(YamlNode nnode) {
ScalarNode node = (ScalarNode) nnode;
Class type = node.getType();
Object result;
@ -516,7 +516,7 @@ public class Constructor extends SafeConstructor {
*/
private class ConstructSequence implements Construct {
@SuppressWarnings("unchecked")
public Object construct(Node node) {
public Object construct(YamlNode node) {
SequenceNode snode = (SequenceNode) node;
if (List.class.isAssignableFrom(node.getType()) || node.getType().isArray()) {
if (node.isTwoStepsConstruction()) {
@ -543,7 +543,7 @@ public class Constructor extends SafeConstructor {
argumentList = new ArrayList<Object>(snode.getValue().size());
java.lang.reflect.Constructor c = possibleConstructors.get(0);
int index = 0;
for (Node argumentNode : snode.getValue()) {
for (YamlNode argumentNode : snode.getValue()) {
Class type = c.getParameterTypes()[index];
// set runtime classes for arguments
argumentNode.setType(type);
@ -574,7 +574,7 @@ public class Constructor extends SafeConstructor {
}
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object object) {
public void construct2ndStep(YamlNode node, Object object) {
SequenceNode snode = (SequenceNode) node;
List<Object> list = (List<Object>) object;
if (List.class.isAssignableFrom(node.getType())) {
@ -585,7 +585,7 @@ public class Constructor extends SafeConstructor {
}
}
protected Class<?> getClassForNode(Node node) {
protected Class<?> getClassForNode(YamlNode node) {
Class<? extends Object> classForTag = typeTags.get(node.getTag());
if (classForTag == null) {
String name = node.getTag().getClassName();

View File

@ -60,8 +60,8 @@ public class SafeConstructor extends BaseConstructor {
int index = 0;
List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
while (index < nodeValue.size()) {
Node keyNode = nodeValue.get(index).getKeyNode();
Node valueNode = nodeValue.get(index).getValueNode();
YamlNode keyNode = nodeValue.get(index).getKeyNode();
YamlNode valueNode = nodeValue.get(index).getValueNode();
if (keyNode.getTag().equals(Tag.MERGE)) {
nodeValue.remove(index);
switch (valueNode.getNodeId()) {
@ -73,8 +73,8 @@ public class SafeConstructor extends BaseConstructor {
case sequence:
List<List<NodeTuple>> submerge = new ArrayList<List<NodeTuple>>();
SequenceNode sn = (SequenceNode) valueNode;
List<Node> vals = sn.getValue();
for (Node subnode : vals) {
List<YamlNode> vals = sn.getValue();
for (YamlNode subnode : vals) {
if (!(subnode instanceof MappingNode)) {
throw new ConstructorException("while constructing a mapping", node
.getStartMark(), "expected a mapping for merging, but found "
@ -120,7 +120,7 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlNull extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
constructScalar((ScalarNode) node);
return null;
}
@ -138,14 +138,14 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlBool extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
String val = (String) constructScalar((ScalarNode) node);
return BOOL_VALUES.get(val.toLowerCase());
}
}
private class ConstructYamlInt extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
String value = constructScalar((ScalarNode) node).toString().replaceAll("_", "");
int sign = +1;
char first = value.charAt(0);
@ -201,7 +201,7 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlFloat extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
String value = constructScalar((ScalarNode) node).toString().replaceAll("_", "");
int sign = +1;
char first = value.charAt(0);
@ -233,7 +233,7 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlBinary extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
byte[] decoded = Base64Coder.decode(constructScalar((ScalarNode) node).toString()
.toCharArray());
return decoded;
@ -252,7 +252,7 @@ public class SafeConstructor extends BaseConstructor {
return calendar;
}
public Object construct(Node node) {
public Object construct(YamlNode node) {
ScalarNode scalar = (ScalarNode) node;
String nodeValue = scalar.getValue();
Matcher match = YMD_REGEXP.matcher(nodeValue);
@ -314,7 +314,7 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlOmap extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
// Note: we do not check for duplicate keys, because it's too
// CPU-expensive.
Map<Object, Object> omap = new LinkedHashMap<Object, Object>();
@ -324,7 +324,7 @@ public class SafeConstructor extends BaseConstructor {
.getStartMark());
}
SequenceNode snode = (SequenceNode) node;
for (Node subnode : snode.getValue()) {
for (YamlNode subnode : snode.getValue()) {
if (!(subnode instanceof MappingNode)) {
throw new ConstructorException("while constructing an ordered map", node
.getStartMark(), "expected a mapping of length 1, but found "
@ -336,8 +336,8 @@ public class SafeConstructor extends BaseConstructor {
.getStartMark(), "expected a single mapping item, but found "
+ mnode.getValue().size() + " items", mnode.getStartMark());
}
Node keyNode = mnode.getValue().get(0).getKeyNode();
Node valueNode = mnode.getValue().get(0).getValueNode();
YamlNode keyNode = mnode.getValue().get(0).getKeyNode();
YamlNode valueNode = mnode.getValue().get(0).getValueNode();
Object key = constructObject(keyNode);
Object value = constructObject(valueNode);
omap.put(key, value);
@ -349,7 +349,7 @@ public class SafeConstructor extends BaseConstructor {
// Note: the same code as `construct_yaml_omap`.
private class ConstructYamlPairs extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
// Note: we do not check for duplicate keys, because it's too
// CPU-expensive.
if (!(node instanceof SequenceNode)) {
@ -358,7 +358,7 @@ public class SafeConstructor extends BaseConstructor {
}
SequenceNode snode = (SequenceNode) node;
List<Object[]> pairs = new ArrayList<Object[]>(snode.getValue().size());
for (Node subnode : snode.getValue()) {
for (YamlNode subnode : snode.getValue()) {
if (!(subnode instanceof MappingNode)) {
throw new ConstructorException("while constructingpairs", node.getStartMark(),
"expected a mapping of length 1, but found " + subnode.getNodeId(),
@ -370,8 +370,8 @@ public class SafeConstructor extends BaseConstructor {
"expected a single mapping item, but found " + mnode.getValue().size()
+ " items", mnode.getStartMark());
}
Node keyNode = mnode.getValue().get(0).getKeyNode();
Node valueNode = mnode.getValue().get(0).getValueNode();
YamlNode keyNode = mnode.getValue().get(0).getKeyNode();
YamlNode valueNode = mnode.getValue().get(0).getValueNode();
Object key = constructObject(keyNode);
Object value = constructObject(valueNode);
pairs.add(new Object[]{key, value});
@ -381,7 +381,7 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlSet implements Construct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
if (node.isTwoStepsConstruction()) {
return createDefaultSet();
} else {
@ -390,7 +390,7 @@ public class SafeConstructor extends BaseConstructor {
}
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object object) {
public void construct2ndStep(YamlNode node, Object object) {
if (node.isTwoStepsConstruction()) {
constructSet2ndStep((MappingNode) node, (Set<Object>) object);
} else {
@ -400,13 +400,13 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlStr extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
return (String) constructScalar((ScalarNode) node);
}
}
private class ConstructYamlSeq implements Construct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
SequenceNode seqNode = (SequenceNode) node;
if (node.isTwoStepsConstruction()) {
return createDefaultList((seqNode.getValue()).size());
@ -416,7 +416,7 @@ public class SafeConstructor extends BaseConstructor {
}
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object data) {
public void construct2ndStep(YamlNode node, Object data) {
if (node.isTwoStepsConstruction()) {
constructSequenceStep2((SequenceNode) node, (List<Object>) data);
} else {
@ -426,7 +426,7 @@ public class SafeConstructor extends BaseConstructor {
}
private class ConstructYamlMap implements Construct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
if (node.isTwoStepsConstruction()) {
return createDefaultMap();
} else {
@ -435,7 +435,7 @@ public class SafeConstructor extends BaseConstructor {
}
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object object) {
public void construct2ndStep(YamlNode node, Object object) {
if (node.isTwoStepsConstruction()) {
constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object);
} else {
@ -445,7 +445,7 @@ public class SafeConstructor extends BaseConstructor {
}
private static final class ConstructUndefined extends AbstractConstruct {
public Object construct(Node node) {
public Object construct(YamlNode node) {
throw new ConstructorException(null, null,
"could not determine a constructor for the tag " + node.getTag(), node
.getStartMark());

View File

@ -24,7 +24,7 @@ import org.elasticsearch.util.yaml.snakeyaml.error.Mark;
* Base class for the two collection types {@link MappingNode mapping} and
* {@link SequenceNode collection}.
*/
public abstract class CollectionNode extends Node {
public abstract class CollectionNode extends YamlNode {
private Boolean flowStyle;
public CollectionNode(Tag tag, Mark startMark, Mark endMark, Boolean flowStyle) {

View File

@ -23,10 +23,10 @@ package org.elasticsearch.util.yaml.snakeyaml.nodes;
*/
public class NodeTuple {
private final Node keyNode;
private final Node valueNode;
private final YamlNode keyNode;
private final YamlNode valueNode;
public NodeTuple(Node keyNode, Node valueNode) {
public NodeTuple(YamlNode keyNode, YamlNode valueNode) {
if (keyNode == null || valueNode == null) {
throw new NullPointerException("Nodes must be provided.");
}
@ -37,7 +37,7 @@ public class NodeTuple {
/**
* Key node.
*/
public Node getKeyNode() {
public YamlNode getKeyNode() {
return keyNode;
}
@ -46,7 +46,7 @@ public class NodeTuple {
*
* @return value
*/
public Node getValueNode() {
public YamlNode getValueNode() {
return valueNode;
}

View File

@ -26,7 +26,7 @@ import org.elasticsearch.util.yaml.snakeyaml.error.Mark;
* Scalar nodes form the leaves in the node graph.
* </p>
*/
public class ScalarNode extends Node {
public class ScalarNode extends YamlNode {
private Character style;
private String value;

View File

@ -30,9 +30,9 @@ import java.util.List;
*/
public class SequenceNode extends CollectionNode {
private Class<? extends Object> listType;
private List<Node> value;
private List<YamlNode> value;
public SequenceNode(Tag tag, boolean resolved, List<Node> value, Mark startMark, Mark endMark,
public SequenceNode(Tag tag, boolean resolved, List<YamlNode> value, Mark startMark, Mark endMark,
Boolean flowStyle) {
super(tag, startMark, endMark, flowStyle);
if (value == null) {
@ -43,7 +43,7 @@ public class SequenceNode extends CollectionNode {
this.resolved = resolved;
}
public SequenceNode(Tag tag, List<Node> value, Boolean flowStyle) {
public SequenceNode(Tag tag, List<YamlNode> value, Boolean flowStyle) {
this(tag, true, value, null, null, flowStyle);
}
@ -57,8 +57,8 @@ public class SequenceNode extends CollectionNode {
*
* @return Nodes in the specified order.
*/
public List<Node> getValue() {
for (Node node : value) {
public List<YamlNode> getValue() {
for (YamlNode node : value) {
node.setType(listType);
}
return value;

View File

@ -33,7 +33,7 @@ import org.elasticsearch.util.yaml.snakeyaml.error.Mark;
* {@link org.elasticsearch.util.yaml.snakeyaml.constructor} package.
* </p>
*/
public abstract class Node {
public abstract class YamlNode {
private Tag tag;
private Mark startMark;
protected Mark endMark;
@ -45,7 +45,7 @@ public abstract class Node {
protected boolean resolved;
protected Boolean useClassConstructor;
public Node(Tag tag, Mark startMark, Mark endMark) {
public YamlNode(Tag tag, Mark startMark, Mark endMark) {
setTag(tag);
this.startMark = startMark;
this.endMark = endMark;