org.yaml.snakeyaml.error.Mark.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(103)

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

Mark.<init>介绍

暂无

代码示例

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

public Mark getMark() {
  return new Mark(name, this.index, this.line, this.column, this.dataWindow, this.pointer);
}

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

public Mark getMark() {
  return new Mark(name, this.line, this.column, this.dataWindow, this.pointer);
}

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

public Mark getMark() {
  return new Mark(name, this.index, this.line, this.column, this.buffer, this.pointer);
}

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

public Mark getMark() {
  return new Mark(name, this.index, this.line, this.column, this.buffer, this.pointer);
}

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

private Mark getSafeNodeEndMark(Node node) {
    return node == null ? new Mark("", -1, -1, -1, "", -1) : node.getEndMark();
  }
}

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

private Mark getSafeNodeStartMark(Node node) {
  return node == null ? new Mark("", -1, -1, -1, "", -1) : node.getStartMark();
}

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

private DefinitionVersionInfo getToscaDefinitionVersion(List<NodeTuple> topLevelNodes, ParsingContextExecution context) throws ParsingException {
  boolean first = true;
  for (NodeTuple node : topLevelNodes) {
    Node key = node.getKeyNode();
    if (key instanceof ScalarNode) {
      ScalarNode scalarKey = (ScalarNode) key;
      if (scalarKey.getValue().equals("tosca_definitions_version")) {
        if (!first) {
          // TOSCA definition version must be the first yaml element
          context.getParsingErrors()
              .add(new ParsingError(ParsingErrorLevel.WARNING, ErrorCode.TOSCA_VERSION_NOT_FIRST,
                  "File is not a valid tosca definition file.", node.getKeyNode().getStartMark(),
                  "tosca_definitions_version must be the first element of the document.", node.getValueNode().getEndMark(), null));
        }
        return new DefinitionVersionInfo(ParserUtils.getScalar(node.getValueNode(), context), node);
      }
    }
    first = false;
  }
  throw new ParsingException(null, new ParsingError(ErrorCode.MISSING_TOSCA_VERSION, "File is not a valid tosca definition file.",
      new Mark("root", 0, 0, 0, null, 0), "Unable to find the mandatory tosca_definitions_version.", new Mark("root", 0, 0, 0, null, 0), null));
}

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

@Override
protected INodeParser<ArchiveRoot> getParser(Node rootNode, ParsingContextExecution context) throws ParsingException {
  if (rootNode instanceof MappingNode) {
    // try to find the tosca version
    DefinitionVersionInfo definitionVersionInfo = getToscaDefinitionVersion(((MappingNode) rootNode).getValue(), context);
    // call the parser for the given tosca version
    Map<String, INodeParser> registry = parserRegistriesByVersion.get(definitionVersionInfo.definitionVersion);
    if (registry == null) {
      throw new ParsingException(context.getFileName(),
          new ParsingError(ErrorCode.UNKNOWN_TOSCA_VERSION, "Definition version is not supported",
              definitionVersionInfo.definitionVersionTuple.getKeyNode().getStartMark(), "Version is not supported by Alien4Cloud",
              definitionVersionInfo.definitionVersionTuple.getValueNode().getStartMark(), definitionVersionInfo.definitionVersion));
    }
    context.setRegistry(registry);
    context.setDefinitionVersion(definitionVersionInfo.definitionVersion);
    return registry.get(DEFINITION_TYPE);
  } else {
    throw new ParsingException(null,
        new ParsingError(ErrorCode.SYNTAX_ERROR, "File is not a valid tosca definition file.", new Mark("root", 0, 0, 0, null, 0),
            "The provided yaml file doesn't follow the Top-level key definitions of a valid TOSCA Simple profile file.",
            new Mark("root", 0, 0, 0, null, 0), "TOSCA Definitions"));
  }
}

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

/**
 * Parse a yaml file into the given T instance.
 *
 * @param yamlStream Input stream that contains the yaml.
 * @param instance The instance to parse.
 * @return A parsing result that contains the parsing errors as well as the created instance.
 * @throws ParsingException In case there is a blocking issue while parsing the definition.
 */
public ParsingResult<T> parseFile(String filePath, String fileName, InputStream yamlStream, T instance) throws ParsingException {
  StreamReader sreader = new StreamReader(new UnicodeReader(yamlStream));
  Composer composer = new Composer(new ParserImpl(sreader), new Resolver());
  Node rootNode = null;
  try {
    rootNode = composer.getSingleNode();
    if (rootNode == null) {
      throw new ParsingException(fileName, new ParsingError(ErrorCode.SYNTAX_ERROR, "Empty file.", new Mark("root", 0, 0, 0, null, 0),
          "No yaml content found in file.", new Mark("root", 0, 0, 0, null, 0), filePath));
    }
  } catch (MarkedYAMLException exception) {
    throw new ParsingException(fileName, new ParsingError(ErrorCode.INVALID_YAML, exception));
  }
  try {
    return doParsing(fileName, rootNode, instance);
  } catch (ParsingException e) {
    e.setFileName(fileName);
    throw e;
  }
}

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

@Test
  public void referenceToMissingTypeShouldFail() {
    ReferencedParser referencedParser = new ReferencedParser("missingParser");
    ParsingContextExecution contextExecution = new ParsingContextExecution();
    try {
      contextExecution.init();
      contextExecution.setRegistry(Maps.newHashMap());
      Node node = Mockito.mock(Node.class);
      Mockito.when(node.getStartMark()).thenReturn(new Mark("name", 0, 10, 10, "", 0));
      Mockito.when(node.getEndMark()).thenReturn(new Mark("name", 0, 10, 10, "", 0));
      referencedParser.parse(node, contextExecution);
      assertEquals(ParsingErrorLevel.ERROR, contextExecution.getParsingErrors().get(0).getErrorLevel());
      assertEquals(ErrorCode.ALIEN_MAPPING_ERROR, contextExecution.getParsingErrors().get(0).getErrorCode());
    } finally {
      ParsingContextExecution.destroy();
    }
  }
}

相关文章