Tabnine Logo
Node
Code IndexAdd Tabnine to your IDE (free)

How to use
Node
in
org.yaml.snakeyaml.nodes

Best Java code snippets using org.yaml.snakeyaml.nodes.Node (Showing top 20 results out of 432)

Refine searchRefine arrow

  • MappingNode
  • NodeTuple
  • Tag
  • YAMLException
  • SafeConstructor
  • Constructor
origin: redisson/redisson

valueNode.setType(property.getType());
final boolean typeDetected = (memberDescription != null)
    ? memberDescription.setupPropertyType(key, valueNode)
    : false;
if (!typeDetected && valueNode.getNodeId() != NodeId.scalar) {
    if (valueNode.getNodeId() == NodeId.sequence) {
      Class<?> t = arguments[0];
      SequenceNode snode = (SequenceNode) valueNode;
      snode.setListType(t);
    } else if (Set.class.isAssignableFrom(valueNode.getType())) {
      Class<?> t = arguments[0];
      MappingNode mnode = (MappingNode) valueNode;
      mnode.setOnlyKeyType(t);
      mnode.setUseClassConstructor(true);
    } else if (Map.class.isAssignableFrom(valueNode.getType())) {
      Class<?> ketType = arguments[0];
      Class<?> valueType = arguments[1];
    : constructObject(valueNode);
if (property.getType() == String.class && Tag.BINARY.equals(valueNode.getTag())
    && value instanceof byte[]) {
  value = new String((byte[]) value);
throw new ConstructorException(
    "Cannot create property=" + key + " for JavaBean=" + object,
    node.getStartMark(), e.getMessage(), valueNode.getStartMark(), e);
origin: redisson/redisson

public AnchorNode(Node realNode) {
  super(realNode.getTag(), realNode.getStartMark(), realNode.getEndMark());
  this.realNode = realNode;
}
origin: redisson/redisson

if (node.getNodeId() == NodeId.sequence) {
      if (member != null) {
        if (t.equals(member.getClass()))
          if (childNode.getNodeId() == NodeId.mapping) {
            childNode.setTag(Tag.MAP);
  Class<?> t = arguments[0];
  MappingNode mnode = (MappingNode) node;
  Iterator<NodeTuple> iter = mnode.getValue().iterator();
  Set<?> set = (Set<?>) object;
  for (Object member : set) {
    NodeTuple tuple = iter.next();
    Node keyNode = tuple.getKeyNode();
    if (t.equals(member.getClass())) {
      if (keyNode.getNodeId() == NodeId.mapping) {
        keyNode.setTag(Tag.MAP);
  Class<?> valueType = arguments[1];
  MappingNode mnode = (MappingNode) node;
  for (NodeTuple tuple : mnode.getValue()) {
    resetTag(keyType, tuple.getKeyNode());
    resetTag(valueType, tuple.getValueNode());
origin: redisson/redisson

private void resetTag(Class<? extends Object> type, Node node) {
  Tag tag = node.getTag();
  if (tag.matches(type)) {
    if (Enum.class.isAssignableFrom(type)) {
      node.setTag(Tag.STR);
    } else {
      node.setTag(Tag.MAP);
    }
  }
}
origin: redisson/redisson

private Construct getConstructor(Node node) {
  Class<?> cl = getClassForNode(node);
  node.setType(cl);
  // call the constructor as if the runtime class is defined
  Construct constructor = yamlClassConstructors.get(node.getNodeId());
  return constructor;
}
origin: redisson/redisson

Iterator<NodeTuple> iter = node.getValue().iterator();
while (iter.hasNext()) {
  final NodeTuple nodeTuple = iter.next();
  final Node keyNode = nodeTuple.getKeyNode();
  final Node valueNode = nodeTuple.getValueNode();
  if (keyNode.getTag().equals(Tag.MERGE)) {
    iter.remove();
    switch (valueNode.getNodeId()) {
    case mapping:
      MappingNode mn = (MappingNode) valueNode;
      mergeNode(mn, false, key2index, values);
      break;
    case sequence:
        if (!(subnode instanceof MappingNode)) {
          throw new ConstructorException("while constructing a mapping",
              node.getStartMark(),
              "expected a mapping for merging, but found "
                  + subnode.getNodeId(),
              subnode.getStartMark());
        mergeNode(mnode, false, key2index, values);
          node.getStartMark(),
          "expected a mapping or list of mappings for merging, but found "
              + valueNode.getNodeId(),
          valueNode.getStartMark());
origin: redisson/redisson

if (!(node instanceof SequenceNode)) {
  throw new ConstructorException("while constructing an ordered map",
      node.getStartMark(), "expected a sequence, but found " + node.getNodeId(),
      node.getStartMark());
  if (!(subnode instanceof MappingNode)) {
    throw new ConstructorException("while constructing an ordered map",
        node.getStartMark(),
        "expected a mapping of length 1, but found " + subnode.getNodeId(),
        subnode.getStartMark());
  if (mnode.getValue().size() != 1) {
    throw new ConstructorException("while constructing an ordered map",
        node.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();
  Object key = constructObject(keyNode);
  Object value = constructObject(valueNode);
  omap.put(key, value);
origin: redisson/redisson

protected void processDuplicateKeys(MappingNode node) {
  List<NodeTuple> nodeValue = node.getValue();
  Map<Object, Integer> keys = new HashMap<Object, Integer>(nodeValue.size());
  TreeSet<Integer> toRemove = new TreeSet<Integer>();
  int i = 0;
  for (NodeTuple tuple : nodeValue) {
    Node keyNode = tuple.getKeyNode();
    if (!keyNode.getTag().equals(Tag.MERGE)) {
      Object key = constructObject(keyNode);
      if (key != null) {
        try {
              node.getStartMark(), "found unacceptable key " + key,
              tuple.getKeyNode().getStartMark(), e);
        if (!isAllowDuplicateKeys()) {
          throw new DuplicateKeyException(node.getStartMark(), key,
              tuple.getKeyNode().getStartMark());
origin: redisson/redisson

protected void constructSet2ndStep(MappingNode node, Set<Object> set) {
  List<NodeTuple> nodeValue = node.getValue();
  for (NodeTuple tuple : nodeValue) {
    Node keyNode = tuple.getKeyNode();
    Object key = constructObject(keyNode);
    if (key != null) {
      try {
        key.hashCode();// check circular dependencies
      } catch (Exception e) {
        throw new ConstructorException("while constructing a Set", node.getStartMark(),
            "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
      }
    }
    if (keyNode.isTwoStepsConstruction()) {
      /*
       * if keyObject is created it 2 steps we should postpone putting
       * it into the set because it may have different hash after
       * initialization compared to clean just created one. And set of
       * course does not observe value hashCode changes.
       */
      sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key));
    } else {
      set.add(key);
    }
  }
}
origin: alien4cloud/alien4cloud

private MappingTarget mapMappingNode(MappingNode mappingNode, ParsingContextExecution context) {
  String key = ParserUtils.getScalar(mappingNode.getValue().get(0).getKeyNode(), context);
  IMappingBuilder mappingBuilder = mappingBuilders.get(key);
  if (mappingBuilder != null) {
    log.debug("Mapping yaml key <" + key + "> using mapping builder " + mappingBuilder.getClass().getName());
    return mappingBuilder.buildMapping(mappingNode, context);
  }
  context.getParsingErrors().add(new ParsingError(ErrorCode.SYNTAX_ERROR, "No mapping target found for key",
      mappingNode.getValue().get(0).getKeyNode().getStartMark(), key, mappingNode.getValue().get(0).getKeyNode().getEndMark(), ""));
  return null;
}
origin: redisson/redisson

private void serializeNode(Node node, Node parent) throws IOException {
  if (node.getNodeId() == NodeId.anchor) {
    node = ((AnchorNode) node).getRealNode();
  } else {
    this.serializedNodes.add(node);
    switch (node.getNodeId()) {
    case scalar:
      ScalarNode scalarNode = (ScalarNode) node;
      Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
      Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
      ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
          .getTag().equals(defaultTag));
      ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
          scalarNode.getValue(), null, null, scalarNode.getStyle());
      this.emitter.emit(event);
    case sequence:
      SequenceNode seqNode = (SequenceNode) node;
      boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
          null, true));
      this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
          implicitS, null, null, seqNode.getFlowStyle()));
      List<Node> list = seqNode.getValue();
    default:// instance of MappingNode
      Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
      boolean implicitM = node.getTag().equals(implicitTag);
      this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
          implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
origin: alien4cloud/alien4cloud

private void processTypeMappingKeys(MappingNode mappingNode, ParsingContextExecution context, INodeParser<?> parser) {
  for (NodeTuple tuple : mappingNode.getValue()) {
    if (Tag.MERGE.equals(tuple.getKeyNode().getTag())) {
      MappingNode toMerge = (MappingNode) tuple.getValueNode();
      processTypeMappingKeys(toMerge, context, parser);
    } else {
      // process a mapping
      map(tuple, (TypeNodeParser) parser, context);
    }
  }
}
origin: com.hotels/shunting-yard-replicator

@Override
protected NodeTuple representJavaBeanProperty(
  Object javaBean,
  Property property,
  Object propertyValue,
  Tag customTag) {
 NodeTuple nodeTuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
 Node valueNode = nodeTuple.getValueNode();
 if (Tag.NULL.equals(valueNode.getTag())) {
  return null; // skip 'null' values
 }
 if (valueNode instanceof CollectionNode) {
  if (Tag.SEQ.equals(valueNode.getTag())) {
   SequenceNode seq = (SequenceNode) valueNode;
   if (seq.getValue().isEmpty()) {
    return null; // skip empty lists
   }
  }
  if (Tag.MAP.equals(valueNode.getTag())) {
   MappingNode seq = (MappingNode) valueNode;
   if (seq.getValue().isEmpty()) {
    return null; // skip empty maps
   }
  }
 }
 Object name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, property.getName());
 return new NodeTuple(representData(name), valueNode);
}
origin: com.sap.cloud.yaas.raml-parser/raml-parser

  NodeTuple tagInclude(NodeTuple tuple)
  {
    if (Tag.NULL.equals(tuple.getValueNode().getTag()))
    {
      return tuple;
    }
    if (templateInclude != null)
    {
      tuple.getValueNode().setTag(templateInclude);
    }
    return tuple;
  }
}
origin: info.magnolia.core/magnolia-configuration

@Override
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
  List<NodeTuple> nodeValue = node.getValue();
  for (NodeTuple tuple : nodeValue) {
    if (Tag.INT.equals(tuple.getKeyNode().getTag())) {
      tuple.getKeyNode().setTag(Tag.STR);
    }
  }
  super.constructMapping2ndStep(node, mapping);
}
origin: takari/polyglot-maven

@Override
protected Object constructJavaBean2ndStep(MappingNode node, Object object) {
 Class<?> type = node.getType();
  for (NodeTuple valueNode : node.getValue()) {
   Node keyNode = valueNode.getKeyNode();
   Node childValueNode = valueNode.getValueNode();
   if (keyNode instanceof ScalarNode && "configuration".equals(((ScalarNode) keyNode).getValue())) {
    childValueNode.setTag(XPP3DOM_TAG);
origin: org.raml/raml-parser

private String getTemplateName(Node templateReferenceNode)
{
  Node templateNameNode = templateReferenceNode;
  if (templateReferenceNode.getNodeId() == mapping)
  {
    templateNameNode = ((MappingNode) templateReferenceNode).getValue().get(0).getKeyNode();
  }
  return ((ScalarNode) templateNameNode).getValue();
}
origin: redisson/redisson

public void setTypes(Class<? extends Object> keyType, Class<? extends Object> valueType) {
  for (NodeTuple nodes : value) {
    nodes.getValueNode().setType(valueType);
    nodes.getKeyNode().setType(keyType);
  }
}
origin: apache/incubator-shardingsphere

  private boolean isEmptyMappingNode(final Node valueNode) {
    return Tag.MAP.equals(valueNode.getTag()) && ((MappingNode) valueNode).getValue().isEmpty();
  }
}
origin: redisson/redisson

protected void composeMappingChildren(List<NodeTuple> children, MappingNode node) {
  Node itemKey = composeKeyNode(node);
  if (itemKey.getTag().equals(Tag.MERGE)) {
    node.setMerged(true);
  }
  Node itemValue = composeValueNode(node);
  children.add(new NodeTuple(itemKey, itemValue));
}
org.yaml.snakeyaml.nodesNode

Javadoc

Base class for all nodes.

The nodes form the node-graph described in the YAML Specification.

While loading, the node graph is usually created by the org.yaml.snakeyaml.composer.Composer, and later transformed into application specific Java classes by the classes from the org.yaml.snakeyaml.constructor package.

Most used methods

  • getStartMark
  • getTag
    Tag of this node. Every node has a tag assigned. The tag is either local or global.
  • getNodeId
    For error reporting.
  • getType
  • getEndMark
  • setTag
  • isTwoStepsConstruction
    Indicates if this node must be constructed in two steps. Two-step construction is required whenever
  • setType
  • setTwoStepsConstruction
  • useClassConstructor
  • isResolved
    Indicates if the tag was added by org.yaml.snakeyaml.resolver.Resolver.
  • setUseClassConstructor
  • isResolved,
  • setUseClassConstructor

Popular in Java

  • Making http requests using okhttp
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JCheckBox (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now