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


Java ScannerException类代码示例

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


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

示例1: testProduceDataSetUsingNotYamlStream

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
@Test
public void testProduceDataSetUsingNotYamlStream() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new YamlDataSetProducer(jsonStream);
    producer.setConsumer(consumer);

    // WHEN
    try {
        producer.produce();
        fail("DataSetException expected");
    } catch (final DataSetException e) {
        // THEN
        assertThat(e.getCause(), instanceOf(ScannerException.class));
    }
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:17,代码来源:YamlDataSetProducerTest.java

示例2: load

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
/**
 * Loads messages
 *
 * @throws FatalNovaGuildsException when something goes wrong
 */
public void load() throws FatalNovaGuildsException {
	setupDirectories();

	try {
		detectLanguage();
		messages = Lang.loadConfiguration(messagesFile);

		//Fork, edit and compile NovaGuilds on your own if you want not to use the original prefix
		restorePrefix();

		prefix = Message.CHAT_PREFIX.get();
		prefixColor = ChatColor.getByChar(ChatColor.getLastColors(prefix).charAt(1));

		LoggerUtils.info("Messages loaded: " + Config.LANG_NAME.getString());
	}
	catch(ScannerException | IOException e) {
		throw new FatalNovaGuildsException("Failed to load messages", e);
	}
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:25,代码来源:MessageManager.java

示例3: getErrorMessage

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
public String getErrorMessage(Throwable e) {
    String errorMessage = e.getMessage();
    if (e instanceof ScannerException &&
            (errorMessage.startsWith(MAPPING_VALUES_NOT_ALLOWED_HERE_ERROR) ||
                    errorMessage.startsWith(SCANNING_A_SIMPLE_KEY_ERROR))) {
        errorMessage += KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG;
    } else if (e instanceof ConstructorException && errorMessage.startsWith(CANNOT_CREATE_PROPERTY_ERROR)) {
        if (errorMessage.contains(UNABLE_TO_FIND_PROPERTY_ERROR)) {
            //parse for undefined property name
            String truncatedErrorMessage = errorMessage.substring(errorMessage.indexOf(TRUNCATION_BEGINNING),
                    errorMessage.indexOf(TRUNCATION_END));
            String undefinedProperty = truncatedErrorMessage.substring(truncatedErrorMessage.indexOf("\'") + 1,
                    truncatedErrorMessage.lastIndexOf("\'"));
            errorMessage += "Property \'" + undefinedProperty + "\' is not supported by CloudSlang. Check that \'" +
                    undefinedProperty + "\' is indented properly.";

        } else if (errorMessage.contains(MAP_CONSTRUCTOR_NOT_FOUND_ERROR)) {
            errorMessage += KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG;
        }
    }
    return errorMessage;
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:23,代码来源:ParserExceptionHandler.java

示例4: testBadResource

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
@Test
public void testBadResource() throws Exception {
	this.processor.setResources(new ByteArrayResource(
			"foo: bar\ncd\nspam:\n  foo: baz".getBytes()));
	this.exception.expect(ScannerException.class);
	this.exception.expectMessage("line 3, column 1");
	this.processor.process(new MatchCallback() {
		@Override
		public void process(Properties properties, Map<String, Object> map) {
		}
	});
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:YamlProcessorTests.java

示例5: testBadResource

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
@Test
public void testBadResource() throws Exception {
	YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
	factory.setResources(new ByteArrayResource(
			"foo: bar\ncd\nspam:\n  foo: baz".getBytes()));
	this.exception.expect(ScannerException.class);
	this.exception.expectMessage("line 3, column 1");
	factory.getObject();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:YamlPropertiesFactoryBeanTests.java

示例6: findRuntime

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
@VisibleForTesting
static String findRuntime(StageFlexibleConfiguration config) throws IOException {
  try {
    // verification for app.yaml that contains runtime:java
    Path appYaml = config.getAppEngineDirectory().toPath().resolve(APP_YAML);
    return new AppYaml(appYaml).getRuntime();
  } catch (ScannerException | ParserException ex) {
    throw new AppEngineException("Malformed 'app.yaml'.", ex);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-plugins-core,代码行数:11,代码来源:CloudSdkAppEngineFlexibleStaging.java

示例7: getProperties

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
/**
 * Get {@link Properties} for a given {@code inputStream} treating it as a YAML file.
 *
 * @param inputStream input stream representing YAML file
 * @return properties representing values from {@code inputStream}
 * @throws IllegalStateException when unable to read properties
 */
@Override
public Properties getProperties(InputStream inputStream) {
  requireNonNull(inputStream);

  Yaml yaml = new Yaml();

  Properties properties = new Properties();

  try (Reader reader = new UnicodeReader(inputStream)) {

    Object object = yaml.load(reader);

    if (object != null) {
      Map<String, Object> yamlAsMap = convertToMap(object);
      properties.putAll(flatten(yamlAsMap));
    }

    return properties;

  } catch (IOException | ScannerException e) {
    throw new IllegalStateException("Unable to load yaml configuration from provided stream", e);
  }
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:31,代码来源:YamlBasedPropertiesProvider.java

示例8: getValueFromAppYaml

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
/**
 * Returns the value of a key-value pair for a given {@code key}, on the file located at {@code
 * appYamlPathString}.
 *
 * @return a String with the value, or an empty Optional if app.yaml isn't a regular file, or if
 *     there is any error getting the value
 * @throws MalformedYamlFileException when an app.yaml isn't syntactically well formed
 */
private Optional<String> getValueFromAppYaml(
    @NotNull String appYamlPathString, @NotNull String key) throws MalformedYamlFileException {
  Yaml yamlParser = new Yaml();

  Path appYamlPath = Paths.get(appYamlPathString);
  if (!Files.isRegularFile(appYamlPath)) {
    return Optional.empty();
  }

  try (BufferedReader reader = Files.newBufferedReader(appYamlPath, Charset.defaultCharset())) {
    Object parseResult = yamlParser.load(reader);

    if (!(parseResult instanceof Map)) {
      return Optional.empty();
    }

    // It's possible to get rid of this unchecked cast using a loadAs(file,
    // AppEngineYamlWebApp.class) sort of approach.
    Map<String, String> yamlMap = (Map<String, String>) parseResult;

    return yamlMap.containsKey(key) ? Optional.of(yamlMap.get(key)) : Optional.empty();
  } catch (ScannerException se) {
    throw new MalformedYamlFileException(se);
  } catch (InvalidPathException | IOException ioe) {
    return Optional.empty();
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:36,代码来源:DefaultAppEngineProjectService.java

示例9: yamlToYamlObject

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
public static YamlCluster yamlToYamlObject(String ymlString) throws KaramelException {
  try {
    Yaml yaml = new Yaml(new Constructor(YamlCluster.class));
    Object document = yaml.load(ymlString);
    return ((YamlCluster) document);
  } catch (ScannerException ex) {
    throw new KaramelException("Syntax error in the yaml!!", ex);
  }
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:10,代码来源:ClusterDefinitionService.java

示例10: ParseConfigException

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
public ParseConfigException(ScannerException e) {
  Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL,
      "Could not parse your halconfig: " + e.getMessage()).build();
  getProblems().add(problem);
}
 
开发者ID:spinnaker,项目名称:halyard,代码行数:6,代码来源:ParseConfigException.java

示例11: YAMLException

import org.yaml.snakeyaml.scanner.ScannerException; //导入依赖的package包/类
public YAMLException(ScannerException e, VirtualFile yaml) {
    super(e.getMessage() + " (in file " + yaml.relativePath() + " line " + (e.getProblemMark().getLine() + 1) + ", column " + (e.getProblemMark().getColumn() + 1) + ")", e);
    this.e = e;
    this.yaml = yaml;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:6,代码来源:YAMLException.java


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