当前位置: 首页>>代码示例>>Java>>正文


Java MarkedYAMLException类代码示例

本文整理汇总了Java中org.yaml.snakeyaml.error.MarkedYAMLException的典型用法代码示例。如果您正苦于以下问题:Java MarkedYAMLException类的具体用法?Java MarkedYAMLException怎么用?Java MarkedYAMLException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MarkedYAMLException类属于org.yaml.snakeyaml.error包,在下文中一共展示了MarkedYAMLException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: from

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
public static YamlMap from(InputStream yaml, boolean canReset) {
  InputStream input = canReset ? yaml : inMemoryCopyOf(yaml);
  YamlMap result = new YamlMap();
  try {
    for (Object data : newLoader().loadAll(input)) {
      result.putAll(new YamlMap(data));
    }
  } catch (MarkedYAMLException e) {
    try {
      input.reset();
      throw yamlSyntaxErrorPrettifier.apply(e, IOUtils.toString(input, StandardCharsets.UTF_8));
    } catch (IOException ignored) {
      // NOTREACHED
    }
  }
  return result;
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:18,代码来源:YamlMap.java

示例2: apply

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
public MarkedYAMLException apply(MarkedYAMLException e, String yaml) throws IOException {
  Optional<YamlLine> prevLine = getLine(yaml, e.getProblemMark().getLine() - 1);
  Optional<YamlLine> line = getLine(e.getProblemMark().get_snippet(0, 100), 0);
  if (prevLine.isPresent() && line.isPresent()) {
    YamlLine prev = prevLine.get();
    YamlLine current = line.get();
    if (isIncorrectIndentation(prev, current)) {
      return incorrectIndentationException(prev, current, e);
    } else if (isItemOutsideSequence(prev, current)) {
      return itemOutsideSequence(e);
    }
  }
  return e;
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:15,代码来源:YamlSyntaxErrorPrettifier.java

示例3: incorrectIndentationException

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
private MarkedYAMLException incorrectIndentationException(YamlLine prev, YamlLine current, MarkedYAMLException e) {
  Collection<Integer> validIndentations = new HashSet<>();
  if (prev.startsBlock()) {
    validIndentations.add(prev.indentation() + 2);
  } else {
    for (int indent = 0; indent <= prev.indentation(); indent += 2) {
      validIndentations.add(indent);
    }
  }
  String message = String.format("Incorrect indentation of %d %s; expected %s", current.indentation(),
      English.plural(SPACE, current.indentation()), oneOfSpaces(validIndentations));
  return new YamlSyntaxErrorException(message, e);
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:14,代码来源:YamlSyntaxErrorPrettifier.java

示例4: assertInvalidYaml

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
private void assertInvalidYaml(String expected, String format, Object... args) {
  try {
    String yaml = String.format(format, args);
    YamlMap map = YamlMap.from(yaml);
    fail("No exception for invalid YAML; " + yaml + " ->\n" + map);
  } catch (MarkedYAMLException e) {
    assertTrue("Problem doesn't contain '" + expected + "': " + e.getProblem(), e.getProblem().contains(expected));
  }
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:10,代码来源:WhenParsingInvalidYaml.java

示例5: getParameters

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
/**
 * Gets the parameters from the input string.
 * @param text The input string.
 * @param numbers The list of line numbers.
 * @return A map containing the directive parameters.
 * @throws NightingaleException Something wrong happened, to be caught in
 * the higher levels.
 */
private static Map<String, Object> getParameters(String text,
        List<Integer> numbers) throws NightingaleException {
    if (text == null) {
        return new HashMap<String, Object>();
    }

    Yaml yaml = new Yaml(
            new Constructor(),
            new Representer(),
            new DumperOptions(),
            new DirectiveResolver()
    );
    try {
        @SuppressWarnings("unchecked")
        HashMap<String, Object> map = yaml.loadAs(text, HashMap.class);
        return map;
    } catch (MarkedYAMLException exception) {
        throw new NightingaleException(
                messages.getMessage(
                        Messages.ERROR_VALIDATE_YAML_EXCEPTION,
                        CommonUtils.getCollectionElements(
                                numbers,
                                "(",
                                ")",
                                ", "
                        )
                ),
                exception
        );
    }
}
 
开发者ID:cereda,项目名称:nightingale,代码行数:40,代码来源:DirectiveUtils.java

示例6: itemOutsideSequence

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
private MarkedYAMLException itemOutsideSequence(MarkedYAMLException e) {
  return new YamlSyntaxErrorException("Item outside of sequence", e);
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:4,代码来源:YamlSyntaxErrorPrettifier.java

示例7: YamlSyntaxErrorException

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
public YamlSyntaxErrorException(String message, MarkedYAMLException cause) {
  super(cause.getContext(), cause.getContextMark(), message, cause.getProblemMark());
}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:4,代码来源:YamlSyntaxErrorException.java

示例8: newYamlError

import org.yaml.snakeyaml.error.MarkedYAMLException; //导入依赖的package包/类
public static SwaggerError newYamlError(YAMLException exception) {
    int line = (exception instanceof MarkedYAMLException)
            ? ((MarkedYAMLException) exception).getProblemMark().getLine() + 1 : 1;
    return new SwaggerError(line, IMarker.SEVERITY_ERROR, 0, processor.rewriteMessage(exception));
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:6,代码来源:SwaggerError.java


注:本文中的org.yaml.snakeyaml.error.MarkedYAMLException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。