From 6379e8cc273b55de459f9eeb71e13c36a75b86f6 Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 9 Apr 2010 00:06:05 +0300 Subject: [PATCH] rename yaml Node to YamlNode --- .../util/yaml/snakeyaml/Loader.java | 18 +++---- .../util/yaml/snakeyaml/Yaml.java | 6 +-- .../yaml/snakeyaml/composer/Composer.java | 40 +++++++------- .../constructor/AbstractConstruct.java | 6 +-- .../constructor/BaseConstructor.java | 26 +++++----- .../yaml/snakeyaml/constructor/Construct.java | 6 +-- .../snakeyaml/constructor/Constructor.java | 22 ++++---- .../constructor/SafeConstructor.java | 52 +++++++++---------- .../yaml/snakeyaml/nodes/CollectionNode.java | 2 +- .../util/yaml/snakeyaml/nodes/NodeTuple.java | 10 ++-- .../util/yaml/snakeyaml/nodes/ScalarNode.java | 2 +- .../yaml/snakeyaml/nodes/SequenceNode.java | 10 ++-- .../nodes/{Node.java => YamlNode.java} | 4 +- 13 files changed, 102 insertions(+), 102 deletions(-) rename modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/{Node.java => YamlNode.java} (98%) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Loader.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Loader.java index cda747fe6e2..642e4b5c880 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Loader.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Loader.java @@ -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 composeAll(Reader yaml) { + public Iterable composeAll(Reader yaml) { final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); this.constructor.setComposer(composer); - Iterator result = new Iterator() { + Iterator result = new Iterator() { 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 { - private Iterator iterator; + private class NodeIterable implements Iterable { + private Iterator iterator; - public NodeIterable(Iterator iterator) { + public NodeIterable(Iterator iterator) { this.iterator = iterator; } - public Iterator iterator() { + public Iterator iterator() { return iterator; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Yaml.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Yaml.java index 48c3f01ed45..2bdaea598ff 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Yaml.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/Yaml.java @@ -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 composeAll(Reader io) { + public Iterable composeAll(Reader io) { return loader.composeAll(io); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/composer/Composer.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/composer/Composer.java index a0bffe5b505..b77e71047b6 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/composer/Composer.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/composer/Composer.java @@ -35,14 +35,14 @@ import java.util.*; public class Composer { private final Parser parser; private final Resolver resolver; - private final Map anchors; - private final Set recursiveNodes; + private final Map anchors; + private final Set recursiveNodes; public Composer(Parser parser, Resolver resolver) { this.parser = parser; this.resolver = resolver; - this.anchors = new HashMap(); - this.recursiveNodes = new HashSet(); + this.anchors = new HashMap(); + this.recursiveNodes = new HashSet(); } /** @@ -65,12 +65,12 @@ public class Composer { * @return The root node of the document or null 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 null 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(), startEvent + SequenceNode node = new SequenceNode(nodeTag, resolved, new ArrayList(), 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(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/AbstractConstruct.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/AbstractConstruct.java index 77cdaa78d51..f5e12e42e5d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/AbstractConstruct.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/AbstractConstruct.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/BaseConstructor.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/BaseConstructor.java index 572c55a372e..c88d12cf33e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/BaseConstructor.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/BaseConstructor.java @@ -50,16 +50,16 @@ public abstract class BaseConstructor { protected final Map yamlMultiConstructors = new HashMap(); private Composer composer; - private final Map constructedObjects; - private final Set recursiveObjects; + private final Map constructedObjects; + private final Set recursiveObjects; private final ArrayList, RecursiveTuple>> maps2fill; private final ArrayList, Object>> sets2fill; protected Tag rootTag; public BaseConstructor() { - constructedObjects = new HashMap(); - recursiveObjects = new HashSet(); + constructedObjects = new HashMap(); + recursiveObjects = new HashSet(); maps2fill = new ArrayList, RecursiveTuple>>(); sets2fill = new ArrayList, 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 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 mapping) { List nodeValue = (List) 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 set) { List nodeValue = (List) node.getValue(); for (NodeTuple tuple : nodeValue) { - Node keyNode = tuple.getKeyNode(); + YamlNode keyNode = tuple.getKeyNode(); Object key = constructObject(keyNode); if (key != null) { try { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Construct.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Construct.java index 50501943023..d041966b77d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Construct.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Construct.java @@ -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 * construct(Node node) for the provided Node */ - public void construct2ndStep(Node node, Object object); + public void construct2ndStep(YamlNode node, Object object); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Constructor.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Constructor.java index ce34aafa5bd..86576ac89dc 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Constructor.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/Constructor.java @@ -125,7 +125,7 @@ public class Constructor extends SafeConstructor { * Strings) 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); } 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(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 list = (List) 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 classForTag = typeTags.get(node.getTag()); if (classForTag == null) { String name = node.getTag().getClassName(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/SafeConstructor.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/SafeConstructor.java index 0faa583dc2a..c5da0c5c8a7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/SafeConstructor.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/constructor/SafeConstructor.java @@ -60,8 +60,8 @@ public class SafeConstructor extends BaseConstructor { int index = 0; List nodeValue = (List) 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> submerge = new ArrayList>(); SequenceNode sn = (SequenceNode) valueNode; - List vals = sn.getValue(); - for (Node subnode : vals) { + List 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 omap = new LinkedHashMap(); @@ -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 pairs = new ArrayList(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); } 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) 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); } 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()); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/CollectionNode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/CollectionNode.java index 64f4e65781f..3fdf7fb5066 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/CollectionNode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/CollectionNode.java @@ -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) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/NodeTuple.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/NodeTuple.java index 479d34a36be..fe331b6c3b8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/NodeTuple.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/NodeTuple.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/ScalarNode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/ScalarNode.java index cde3c543d3f..32cd8c7f3d0 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/ScalarNode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/ScalarNode.java @@ -26,7 +26,7 @@ import org.elasticsearch.util.yaml.snakeyaml.error.Mark; * Scalar nodes form the leaves in the node graph. *

*/ -public class ScalarNode extends Node { +public class ScalarNode extends YamlNode { private Character style; private String value; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/SequenceNode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/SequenceNode.java index 2de27aea1d7..a42ec91eefa 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/SequenceNode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/SequenceNode.java @@ -30,9 +30,9 @@ import java.util.List; */ public class SequenceNode extends CollectionNode { private Class listType; - private List value; + private List value; - public SequenceNode(Tag tag, boolean resolved, List value, Mark startMark, Mark endMark, + public SequenceNode(Tag tag, boolean resolved, List 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 value, Boolean flowStyle) { + public SequenceNode(Tag tag, List 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 getValue() { - for (Node node : value) { + public List getValue() { + for (YamlNode node : value) { node.setType(listType); } return value; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/Node.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/YamlNode.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/Node.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/YamlNode.java index 35b335e42f1..ce532f10bcd 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/Node.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/yaml/snakeyaml/nodes/YamlNode.java @@ -33,7 +33,7 @@ import org.elasticsearch.util.yaml.snakeyaml.error.Mark; * {@link org.elasticsearch.util.yaml.snakeyaml.constructor} package. *

*/ -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;