本文整理了Java中io.konig.yaml.YamlReader
类的一些代码示例,展示了YamlReader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlReader
类的具体详情如下:
包路径:io.konig.yaml.YamlReader
类名称:YamlReader
暂无
代码示例来源:origin: io.konig/konig-yaml
@SuppressWarnings("unchecked")
public static <T> T read(Class<T> type, Reader reader) throws YamlParseException, IOException {
@SuppressWarnings("resource")
YamlReader yaml = new YamlReader(reader);
return (T) yaml.readObject(type);
}
代码示例来源:origin: io.konig/konig-yaml
private String singleQuotedString() throws YamlParseException, IOException {
assertNext('\'');
StringBuilder buffer = buffer();
int c = read();
while (c != '\'') {
// TODO: handle escaped quote
buffer.appendCodePoint(c);
c = read();
}
return buffer.toString();
}
代码示例来源:origin: io.konig/konig-yaml
public void addDeserializer(Class<?> type, YamlDeserializer deserializer) {
ClassInfo classInfo;
try {
classInfo = classInfo(type);
} catch (YamlParseException e) {
throw new RuntimeException(e);
}
classInfo.deserializer = deserializer;
}
代码示例来源:origin: io.konig/konig-yaml
private Object objectRef() throws IOException, YamlParseException {
assertNext('*');
String objectId = readWord();
Object pojo = objectMap.get(objectId);
if (pojo == null) {
fail("Object not found: *" + objectId);
}
return pojo;
}
代码示例来源:origin: io.konig/konig-yaml
int c = valueStart();
Object value = null;
value = typedObject(parser, consumer);
break;
value = objectRef();
assertLineEnd();
break;
read();
indentWidth();
c = peek();
if (c == '-') {
if (consumer.isAdder()) {
Class<?> valueType = consumer.getValueType();
Object list = valueType.newInstance();
PojoValueConsumer listConsumer = new PojoValueConsumer(list, collectionAddMethod(), collectionElementType(valueType));
value = new CollectionYamlParser(parser, listConsumer);
consumer.consume(list);
} catch (Throwable e) {
fail("Failed to consume with " + consumer, e);
value = scalarValue(javaType);
assertLineEnd();
indentWidth();
if (!isObjectItem && nextIndentWidth>parser.getIndentWidth() && !(value instanceof ObjectYamlParser)) {
return new ObjectYamlParser(parser, value, consumer, nextIndentWidth);
代码示例来源:origin: io.konig/konig-data-app-common
@Override
public void init() throws ServletException {
String configFile = getServletConfig().getInitParameter("configFile");
if (configFile == null) {
throw new ServletException("configFile init parameter is not defined");
}
try {
try (
InputStream input = getClass().getClassLoader().getResourceAsStream(configFile);
Reader reader = new InputStreamReader(input);
YamlReader yaml = new YamlReader(reader);
) {
yaml.addDeserializer(URI.class, new UriDeserializer());
dataApp = yaml.readObject(DataApp.class);
configure();
}
} catch (Throwable e) {
throw new ServletException(e);
}
}
代码示例来源:origin: io.konig/konig-yaml
private String unquotedString() throws IOException {
int c = read();
StringBuilder buffer = buffer();
while (c != -1 && c != '\n') {
buffer.appendCodePoint(c);
c = read();
}
unread(c);
return buffer.toString().trim();
}
代码示例来源:origin: io.konig/konig-yaml
public Object readObject() throws YamlParseException, IOException {
return readObject(null);
}
代码示例来源:origin: io.konig/konig-yaml
private ClassInfo classInfo(Class<?> type) throws YamlParseException {
ClassInfo info = classInfo.get(type);
if (info == null) {
info = createClassInfo(type);
classInfo.put(type, info);
}
return info;
}
代码示例来源:origin: io.konig/konig-yaml
private String fieldName(String methodName) {
StringBuilder buffer = buffer();
char c = methodName.charAt(3);
buffer.append(Character.toLowerCase(c));
for (int i=4; i<methodName.length(); i++) {
buffer.append(methodName.charAt(i));
}
return buffer.toString();
}
代码示例来源:origin: io.konig/konig-yaml
private String readWord() throws IOException {
StringBuilder buffer = buffer();
int c = read();
while (c>0 && !Character.isWhitespace(c)) {
buffer.appendCodePoint(c);
c = read();
}
unread(c);
return buffer.toString();
}
代码示例来源:origin: io.konig/konig-yaml
private String doubleQuotedString() throws YamlParseException, IOException {
assertNext('"');
StringBuilder buffer = buffer();
int c = read();
while (c != '"') {
// TODO: handle escaped quote
buffer.appendCodePoint(c);
c = read();
}
return buffer.toString();
}
内容来源于网络,如有侵权,请联系作者删除!