本文整理了Java中org.yaml.snakeyaml.error.YAMLException
类的一些代码示例,展示了YAMLException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLException
类的具体详情如下:
包路径:org.yaml.snakeyaml.error.YAMLException
类名称:YAMLException
暂无
代码示例来源:origin: redisson/redisson
@SuppressWarnings("unchecked")
public Object construct(Node node) {
SequenceNode snode = (SequenceNode) node;
if (Set.class.isAssignableFrom(node.getType())) {
if (node.isTwoStepsConstruction()) {
throw new YAMLException("Set cannot be recursive.");
} else {
return constructSet(snode);
} else if (Collection.class.isAssignableFrom(node.getType())) {
if (node.isTwoStepsConstruction()) {
return newList(snode);
} else {
return constructSequence(snode);
} else if (node.getType().isArray()) {
return c.newInstance(argumentList);
} catch (Exception e) {
throw new YAMLException(e);
return c.newInstance(argumentList.toArray());
} catch (Exception e) {
throw new YAMLException(e);
throw new YAMLException(
"No suitable constructor with " + String.valueOf(snode.getValue().size())
+ " arguments found for " + node.getType());
代码示例来源:origin: redisson/redisson
public YAMLException(JsonParser p,
org.yaml.snakeyaml.error.YAMLException src) {
super(p, src.getMessage(), src);
}
代码示例来源:origin: redisson/redisson
protected Object constructJavaBean2ndStep(MappingNode node, Object object) {
flattenMapping(node);
Class<? extends Object> beanType = node.getType();
List<NodeTuple> nodeValue = node.getValue();
throw new YAMLException(
"Keys must be scalars but found: " + tuple.getKeyNode());
String key = (String) constructObject(keyNode);
try {
TypeDescription memberDescription = typeDefinitions.get(beanType);
throw new YAMLException("No writable property '" + key + "' on class: "
+ beanType.getName());
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;
: constructObject(valueNode);
代码示例来源:origin: redisson/redisson
/**
* Fail with a reminder to provide the seconds step for a recursive
* structure
*
* @see org.yaml.snakeyaml.constructor.Construct#construct2ndStep(org.yaml.snakeyaml.nodes.Node,
* java.lang.Object)
*/
public void construct2ndStep(Node node, Object data) {
if (node.isTwoStepsConstruction()) {
throw new IllegalStateException("Not Implemented in " + getClass().getName());
} else {
throw new YAMLException("Unexpected recursive structure for Node: " + node);
}
}
}
代码示例来源:origin: pl.droidsonroids.yaml/snakeyaml
if (Properties.class.isAssignableFrom(node.getType())) {
Properties properties = new Properties();
if (!node.isTwoStepsConstruction()) {
constructMapping2ndStep(mnode, properties);
} else {
throw new YAMLException("Properties must not be recursive.");
} else if (SortedMap.class.isAssignableFrom(node.getType())) {
SortedMap<Object, Object> map = new TreeMap<Object, Object>();
if (!node.isTwoStepsConstruction()) {
constructMapping2ndStep(mnode, map);
} else if (Map.class.isAssignableFrom(node.getType())) {
if (node.isTwoStepsConstruction()) {
return createDefaultMap();
} else {
return constructMapping(mnode);
代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser
@Override
public Node resolve(Node node, ResourceLoader resourceLoader, NodeHandler nodeHandler)
{
String className = ((ScalarNode) node).getValue();
try
{
Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
JAXBContext context = JAXBContext.newInstance(clazz);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
context.generateSchema(new SchemaOutputResolver()
{
@Override
public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException
{
StreamResult result = new StreamResult(baos);
result.setSystemId("001");
return result;
}
});
String schema = baos.toString();
return new ScalarNode(Tag.STR, schema, node.getStartMark(), node.getEndMark(), ((ScalarNode) node).getStyle());
}
catch (Exception e)
{
throw new YAMLException(e);
}
}
代码示例来源:origin: redisson/redisson
public void setIndicatorIndent(int indicatorIndent) {
if (indicatorIndent < 0) {
throw new YAMLException("Indicator indent must be non-negative.");
}
if (indicatorIndent > Emitter.MAX_INDENT - 1) {
throw new YAMLException("Indicator indent must be at most Emitter.MAX_INDENT-1: " + (Emitter.MAX_INDENT - 1));
}
this.indicatorIndent = indicatorIndent;
}
代码示例来源:origin: redisson/redisson
protected Class<?> getClassForNode(Node node) {
Class<? extends Object> classForTag = typeTags.get(node.getTag());
if (classForTag == null) {
String name = node.getTag().getClassName();
Class<?> cl;
try {
cl = getClassForName(name);
} catch (ClassNotFoundException e) {
throw new YAMLException("Class not found: " + name);
}
typeTags.put(node.getTag(), cl);
return cl;
} else {
return classForTag;
}
}
代码示例来源:origin: google/cdep
@NotNull
public static CDepManifestYml convertStringToManifest(@NotNull String url, @NotNull String content) {
Invariant.registerYamlFile(url);
Yaml yaml = new Yaml(new Constructor(CDepManifestYml.class));
CDepManifestYml manifest;
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
try {
manifest = (CDepManifestYml) yaml.load(new ByteArrayInputStream(bytes));
// Try to read current version
if (manifest != null) {
manifest.sourceVersion = CDepManifestYmlVersion.vlatest;
}
} catch (YAMLException e) {
try {
manifest = V3Reader.convertStringToManifest(content);
} catch (YAMLException e2) {
if (!tryCreateSensibleParseError(e, 0)) {
// If older readers also couldn't read it then report the original exception.
require(false, e.toString());
}
return new CDepManifestYml(EMPTY_COORDINATE);
}
}
require(manifest != null, "Manifest was empty");
assert manifest != null;
manifest = new ConvertNullToDefaultRewriter().visitCDepManifestYml(manifest);
Node nodes = yaml.compose(new InputStreamReader(new ByteArrayInputStream(bytes)));
SnakeYmlUtils.mapAndRegisterNodes(url, manifest, nodes);
return manifest;
}
代码示例来源:origin: redisson/redisson
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object object) {
SequenceNode snode = (SequenceNode) node;
if (List.class.isAssignableFrom(node.getType())) {
List<Object> list = (List<Object>) object;
constructSequenceStep2(snode, list);
} else if (node.getType().isArray()) {
constructArrayStep2(snode, object);
} else {
throw new YAMLException("Immutable objects cannot be recursive.");
}
}
}
代码示例来源:origin: org.apache.cassandra/cassandra-all
public Config loadConfig(URL url) throws ConfigurationException
{
try
{
logger.debug("Loading settings from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream())
{
configBytes = ByteStreams.toByteArray(is);
}
catch (IOException e)
{
// getStorageConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor constructor = new CustomConstructor(Config.class);
PropertiesChecker propertiesChecker = new PropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = loadConfig(yaml, configBytes);
propertiesChecker.check();
return result;
}
catch (YAMLException e)
{
throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR
+ " Error: " + e.getMessage(), false);
}
}
代码示例来源:origin: redisson/redisson
for (Node child : node.getValue()) {
if (child.getType() == Object.class) {
child.setType(componentType);
throw new YAMLException("unexpected primitive type");
代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser
if (root != null && root.getNodeId() == mapping)
errorMessage.add(createErrorResult(ex.getMessage()));
代码示例来源:origin: redisson/redisson
protected Object newInstance(Class<?> ancestor, Node node, boolean tryDefault)
throws InstantiationException {
final Class<? extends Object> type = node.getType();
if (typeDefinitions.containsKey(type)) {
TypeDescription td = typeDefinitions.get(type);
final Object instance = td.newInstance(node);
if (instance != null) {
return instance;
}
}
if (tryDefault) {
/*
* Removed <code> have InstantiationException in case of abstract
* type
*/
if (ancestor.isAssignableFrom(type) && !Modifier.isAbstract(type.getModifiers())) {
try {
java.lang.reflect.Constructor<?> c = type.getDeclaredConstructor();
c.setAccessible(true);
return c.newInstance();
} catch (NoSuchMethodException e) {
throw new InstantiationException("NoSuchMethodException:"
+ e.getLocalizedMessage());
} catch (Exception e) {
throw new YAMLException(e);
}
}
}
throw new InstantiationException();
}
代码示例来源:origin: com.sap.cloud.yaas.raml-parser/raml-parser
public static void dumpFromAst(Node rootNode, Writer output)
{
if (rootNode == null)
{
throw new IllegalArgumentException("rootNode is null");
}
DumperOptions dumperOptions = new DumperOptions();
//HYBRIS start - replaced null param with rootTag
Tag rootTag = rootNode.getTag();
Serializer serializer = new Serializer(new Emitter(output, dumperOptions), new Resolver(), dumperOptions,
rootTag);
//HYBRIS end
try
{
serializer.open();
serializer.serialize(rootNode);
serializer.close();
}
catch (IOException e)
{
throw new YAMLException(e);
}
}
代码示例来源:origin: redisson/redisson
return newInstance(type, node, false);
} catch (InstantiationException e1) {
if (javaConstructor == null) {
try {
return newInstance(type, node, false);
} catch (InstantiationException ie) {
throw new YAMLException("No single argument constructor found for " + type
+ " : " + ie.getMessage());
argument = constructScalar(node);
try {
javaConstructor = type.getDeclaredConstructor(String.class);
} catch (Exception e) {
throw new YAMLException("Can't construct a java object for scalar "
+ node.getTag() + "; No String constructor found. Exception="
+ e.getMessage(), e);
代码示例来源:origin: pl.droidsonroids.yaml/snakeyaml
throw new YAMLException("No single argument constructor found for " + type);
} else if (oneArgCount == 1) {
argument = constructStandardJavaInstance(
argument = constructScalar(node);
try {
javaConstructor = type.getDeclaredConstructor(String.class);
} catch (Exception e) {
throw new YAMLException("Can't construct a java object for scalar "
+ node.getTag() + "; No String constructor found. Exception="
+ e.getMessage(), e);
代码示例来源:origin: google/cdep
private static boolean tryCreateSensibleParseError(YAMLException e, int depth) {
if (depth > 20) {
return false;
}
if (e != null) {
if (e.getCause() == null) {
if (e.getMessage().contains("Unable to find property 'lib'")) {
require(false, "Could not parse manifest. " +
"The field 'lib' could not be created. Should it be 'libs'?");
return true;
}
} else {
return tryCreateSensibleParseError((YAMLException) e.getCause(), depth + 1);
}
}
return false;
}
代码示例来源:origin: gov.nasa.jpl.imce/gov.nasa.jpl.magicdraw.projectUsageIntegrityChecker
ye.fillInStackTrace();
if (ProjectUsageIntegrityPlugin.getInstance().isShowAdvancedInformationProperty()) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
ye.printStackTrace(pw);
buff.append(sw.toString());
代码示例来源:origin: oyse/yedit
YEditLog.logger.info( "Encountered YAML syntax error:" + ex.toString() );
内容来源于网络,如有侵权,请联系作者删除!