org.yaml.snakeyaml.nodes.Tag.startsWith()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.yaml.snakeyaml.nodes.Tag.startsWith()方法的一些代码示例,展示了Tag.startsWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.startsWith()方法的具体详情如下:
包路径:org.yaml.snakeyaml.nodes.Tag
类名称:Tag
方法名:startsWith

Tag.startsWith介绍

暂无

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Get the constructor to construct the Node. For implicit tags if the
 * runtime class is known a dedicated Construct implementation is used.
 * Otherwise the constructor is chosen by the tag.
 *
 * @param node {@link Node} to construct an instance from
 * @return {@link Construct} implementation for the specified node
 */
protected Construct getConstructor(Node node) {
  if (node.useClassConstructor()) {
    return yamlClassConstructors.get(node.getNodeId());
  } else {
    Construct constructor = yamlConstructors.get(node.getTag());
    if (constructor == null) {
      for (String prefix : yamlMultiConstructors.keySet()) {
        if (node.getTag().startsWith(prefix)) {
          return yamlMultiConstructors.get(prefix);
        }
      }
      return yamlConstructors.get(null);
    }
    return constructor;
  }
}

代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser

MergeContext(Class<?> keyNodeType, Tag templateInclude)
{
  this.keyNodeType = keyNodeType;
  if (templateInclude != null && templateInclude.startsWith(INCLUDE_APPLIED_TAG))
  {
    this.templateInclude = templateInclude;
  }
}

代码示例来源:origin: org.raml/raml-parser

MergeContext(Class<?> keyNodeType, Tag templateInclude)
{
  this.keyNodeType = keyNodeType;
  if (templateInclude != null && (templateInclude.startsWith(INCLUDE_APPLIED_TAG) || templateInclude.startsWith(INCLUDE_COMPOUND_APPLIED_TAG)))
  {
    this.templateInclude = templateInclude;
  }
}

代码示例来源:origin: org.raml/raml-parser

@Override
public boolean handles(Tag tag)
{
  return tag.startsWith(INCLUDE_COMPOUND_APPLIED_TAG);
}

代码示例来源:origin: org.raml/raml-parser

public static boolean isNonStringTag(Tag tag)
  {
    return tag != null && !STR.equals(tag) && !tag.startsWith(INCLUDE_APPLIED_TAG);
  }
}

代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser

@Override
public boolean handles(Tag tag)
{
  return INCLUDE_TAG.equals(tag) || tag.startsWith(INCLUDE_APPLIED_TAG);
}

代码示例来源:origin: org.raml/raml-parser

@Override
public boolean handles(Tag tag)
{
  return INCLUDE_TAG.equals(tag) || tag.startsWith(INCLUDE_APPLIED_TAG);
}

代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser

private boolean isCustomTag(Tag tag)
{
  return tag != null && !STR.equals(tag) && !tag.startsWith(INCLUDE_APPLIED_TAG);
}

代码示例来源:origin: org.raml/raml-parser

@Override
public void beforeProcessingResolvedNode(Tag tag, Node originalNode, Node resolvedNode)
{
  if (tag.startsWith(INCLUDE_COMPOUND_APPLIED_TAG))
  {
    List<IncludeInfo> includes = unmarshall(tag);
    for (IncludeInfo include : includes)
    {
      contextPath.push(include);
    }
  }
}

代码示例来源:origin: org.raml/raml-parser

@Override
public void afterProcessingResolvedNode(Tag tag, Node originalNode, Node resolvedNode)
{
  if (tag.startsWith(INCLUDE_COMPOUND_APPLIED_TAG))
  {
    List<IncludeInfo> includes = unmarshall(tag);
    for (IncludeInfo include : includes)
    {
      contextPath.pop();
    }
  }
}

代码示例来源:origin: org.raml/raml-parser

/**
 * Calculates the relative path of an include applied tag with respect
 *  to the current context
 *
 *  e.g.:
 *    context: a/b/c/x.raml
 *    tag:     a/b/c/d/y.raml
 *    result:  d/y.raml
 *
 * @param tag include applied tag
 * @return the relative path part of the tag
 */
public String resolveRelativePath(Tag tag)
{
  if (tag == null || !tag.startsWith(INCLUDE_APPLIED_TAG))
  {
    throw new IllegalArgumentException("Tag must be an include applied");
  }
  String partentPath = getPartentPath();
  String includePath = new IncludeInfo(tag).getIncludeName();
  if (includePath.startsWith(partentPath))
  {
    includePath = includePath.substring(partentPath.length());
  }
  return includePath;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Get the constructor to construct the Node. For implicit tags if the
 * runtime class is known a dedicated Construct implementation is used.
 * Otherwise the constructor is chosen by the tag.
 *
 * @param node
 *            Node to be constructed
 * @return Construct implementation for the specified node
 */
protected Construct getConstructor(Node node) {
  if (node.useClassConstructor()) {
    return yamlClassConstructors.get(node.getNodeId());
  } else {
    Construct constructor = yamlConstructors.get(node.getTag());
    if (constructor == null) {
      for (String prefix : yamlMultiConstructors.keySet()) {
        if (node.getTag().startsWith(prefix)) {
          return yamlMultiConstructors.get(prefix);
        }
      }
      return yamlConstructors.get(null);
    }
    return constructor;
  }
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Get the constructor to construct the Node. For implicit tags if the
 * runtime class is known a dedicated Construct implementation is used.
 * Otherwise the constructor is chosen by the tag.
 * 
 * @param node
 *            Node to be constructed
 * @return Construct implementation for the specified node
 */
protected Construct getConstructor(Node node) {
  if (node.useClassConstructor()) {
    return yamlClassConstructors.get(node.getNodeId());
  } else {
    Construct constructor = yamlConstructors.get(node.getTag());
    if (constructor == null) {
      for (String prefix : yamlMultiConstructors.keySet()) {
        if (node.getTag().startsWith(prefix)) {
          return yamlMultiConstructors.get(prefix);
        }
      }
      return yamlConstructors.get(null);
    }
    return constructor;
  }
}

代码示例来源:origin: org.raml/raml-parser

private int getLineOffset(ScalarNode schemaNode)
{
  boolean isInclude = schemaNode.getTag().startsWith(INCLUDE_APPLIED_TAG);
  return isInclude ? -1 : schemaNode.getStartMark().getLine();
}

代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser

private int getLineOffset(ScalarNode schemaNode)
{
  boolean isInclude = schemaNode.getTag().startsWith(INCLUDE_APPLIED_TAG);
  return isInclude ? -1 : schemaNode.getStartMark().getLine();
}

代码示例来源:origin: pl.droidsonroids.yaml/snakeyaml

/**
 * Get the constructor to construct the Node. For implicit tags if the
 * runtime class is known a dedicated Construct implementation is used.
 * Otherwise the constructor is chosen by the tag.
 * 
 * @param node
 *            Node to be constructed
 * @return Construct implementation for the specified node
 */
protected Construct getConstructor(Node node) {
  if (node.useClassConstructor()) {
    return yamlClassConstructors.get(node.getNodeId());
  } else {
    Construct constructor = yamlConstructors.get(node.getTag());
    if (constructor == null) {
      for (String prefix : yamlMultiConstructors.keySet()) {
        if (node.getTag().startsWith(prefix)) {
          return yamlMultiConstructors.get(prefix);
        }
      }
      return yamlConstructors.get(null);
    }
    return constructor;
  }
}

代码示例来源:origin: org.raml/raml-parser

private void updateIncludeTag(Node templateValue, Tag parentTag)
{
  if (parentTag.startsWith(INCLUDE_APPLIED_TAG))
  {
    Tag currentTag = templateValue.getTag();
    if (currentTag.startsWith(INCLUDE_APPLIED_TAG))
    {
      String parentTagValue = parentTag.getValue();
      String currentTagValue = currentTag.getValue();
      templateValue.setTag(new Tag(INCLUDE_COMPOUND_APPLIED_TAG //
                     + parentTagValue.length() + SEPARATOR + parentTagValue //
                     + SEPARATOR //
                     + currentTagValue.length() + SEPARATOR + currentTagValue));
    }
    else
    {
      templateValue.setTag(parentTag);
    }
  }
}

代码示例来源:origin: org.raml/raml-parser

@Override
public void beforeProcessingResolvedNode(Tag tag, Node originalValueNode, Node resolvedNode)
{
  if (IncludeResolver.INCLUDE_TAG.equals(tag))
  {
    if (originalValueNode.getNodeId() != NodeId.scalar)
    {
      //invalid include
      return;
    }
    contextPath.push((ScalarNode) originalValueNode);
  }
  else if (tag.startsWith(IncludeResolver.INCLUDE_APPLIED_TAG))
  {
    contextPath.push(tag);
  }
}

代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser

@Override
public void beforeProcessingResolvedNode(Tag tag, Node originalValueNode, Node resolvedNode)
{
  if (IncludeResolver.INCLUDE_TAG.equals(tag))
  {
    if (originalValueNode.getNodeId() != NodeId.scalar)
    {
      //invalid include
      return;
    }
    contextPath.push((ScalarNode) originalValueNode);
  }
  else if (tag.startsWith(IncludeResolver.INCLUDE_APPLIED_TAG))
  {
    contextPath.push(tag);
  }
}

代码示例来源:origin: org.raml/raml-parser

private Node resolveInclude(Node node, Tag tag)
{
  if (node.getNodeId() == scalar && node.getTag().equals(INCLUDE_TAG))
  {
    if (tag != null && tag.startsWith(INCLUDE_APPLIED_TAG))
    {
      // for multiple levels of includes in the same template recalculate path using
      //  parent include applied tag path
      ScalarNode scalarNode = (ScalarNode) node;
      String parentPath = includeResolver.getContextPath().resolveRelativePath(tag);
      String includePathRecalculated = ContextPath.getPartentPath(parentPath) + scalarNode.getValue();
      node = new ScalarNode(scalarNode.getTag(), includePathRecalculated, node.getStartMark(), node.getEndMark(), scalarNode.getStyle());
    }
    return includeResolver.resolve(node, resourceLoader, nodeNandler);
  }
  return node;
}

相关文章