gpt4 book ai didi

io.jenkins.plugins.casc.snakeyaml.Yaml类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 17:26:31 28 4
gpt4 key购买 nike

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

Yaml介绍

[英]Public YAML interface. Each Thread must have its own instance.
[中]公共YAML接口。每个线程都必须有自己的实例。

代码示例

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

private static Stream<? extends Map.Entry<String, Object>> entries(Reader config) {
  return ((Map<String, Object>) new Yaml().loadAs(config, Map.class)).entrySet().stream();
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Serialize a sequence of Java objects into a YAML stream.
 *
 * @param data
 *            Iterator with Objects
 * @param output
 *            stream to write to
 */
public void dumpAll(Iterator<? extends Object> data, Writer output) {
  dumpAll(data, output, null);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * <p>
 * Serialize a Java object into a YAML string. Override the default root tag
 * with <code>Tag.MAP</code>.
 * </p>
 * <p>
 * This method is similar to <code>Yaml.dump(data)</code> except that the
 * root tag for the whole document is replaced with <code>Tag.MAP</code> tag
 * (implicit !!map).
 * </p>
 * <p>
 * Block Mapping is used as the collection style. See 10.2.2. Block Mappings
 * (http://yaml.org/spec/1.1/#id934537)
 * </p>
 *
 * @param data
 *            Java object to be serialized to YAML
 * @return YAML String
 */
public String dumpAsMap(Object data) {
  return dumpAs(data, Tag.MAP, FlowStyle.BLOCK);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse the only YAML document in a stream and produce the corresponding
 * Java object.
 *
 * @param io
 *            data to load from (BOM must not be present)
 * @param <T>
 *           the class of the instance to be created
 * @return parsed object
 */
@SuppressWarnings("unchecked")
public <T> T load(Reader io) {
  return (T) loadFromReader(new StreamReader(io), Object.class);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse all YAML documents in a String and produce corresponding Java
 * objects. (Because the encoding in known BOM is not respected.) The
 * documents are parsed only when the iterator is invoked.
 *
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @return an Iterable over the parsed Java objects in this String in proper
 *         sequence
 */
public Iterable<Object> loadAll(String yaml) {
  return loadAll(new StringReader(yaml));
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Create Yaml instance. It is safe to create a few instances and use them
 * in different Threads.
 *
 * @param constructor
 *            BaseConstructor to construct incoming documents
 * @param representer
 *            Representer to emit outgoing objects
 */
public Yaml(BaseConstructor constructor, Representer representer) {
  this(constructor, representer, initDumperOptions(representer));
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse the only YAML document in a String and produce the corresponding
 * Java object. (Because the encoding in known BOM is not respected.)
 *
 * @param <T>
 *            Class is defined by the second argument
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @param type
 *            Class of the object to be created
 * @return parsed object
 */
@SuppressWarnings("unchecked")
public <T> T loadAs(String yaml, Class<T> type) {
  return (T) loadFromReader(new StreamReader(yaml), type);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse all YAML documents in a stream and produce corresponding Java
 * objects. The documents are parsed only when the iterator is invoked.
 *
 * @param yaml
 *            YAML data to load from (BOM is respected to detect encoding and removed from the data)
 * @return an Iterable over the parsed Java objects in this stream in proper
 *         sequence
 */
public Iterable<Object> loadAll(InputStream yaml) {
  return loadAll(new UnicodeReader(yaml));
}

代码示例来源:origin: io.jenkins/configuration-as-code

private static Stream<? extends Map.Entry<String, Object>> entries(Reader config) {
  return ((Map<String, Object>) new Yaml().loadAs(config, Map.class)).entrySet().stream();
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse the only YAML document in a String and produce the corresponding
 * Java object. (Because the encoding in known BOM is not respected.)
 *
 * @param yaml
 *            YAML data to load from (BOM must not be present)
 * @param <T>
 *           the class of the instance to be created
 * @return parsed object
 */
@SuppressWarnings("unchecked")
public <T> T load(String yaml) {
  return (T) loadFromReader(new StreamReader(yaml), Object.class);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Serialize a sequence of Java objects into a YAML String.
 *
 * @param data
 *            Iterator with Objects
 * @return YAML String with all the objects in proper sequence
 */
public String dumpAll(Iterator<? extends Object> data) {
  StringWriter buffer = new StringWriter();
  dumpAll(data, buffer, null);
  return buffer.toString();
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse the only YAML document in a stream and produce the corresponding
 * Java object.
 *
 * @param <T>
 *            Class is defined by the second argument
 * @param io
 *            data to load from (BOM must not be present)
 * @param type
 *            Class of the object to be created
 * @return parsed object
 */
@SuppressWarnings("unchecked")
public <T> T loadAs(Reader io, Class<T> type) {
  return (T) loadFromReader(new StreamReader(io), type);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Serialize a Java object into a YAML String.
 *
 * @param data
 *            Java object to be Serialized to YAML
 * @return YAML String
 */
public String dump(Object data) {
  List<Object> list = new ArrayList<Object>(1);
  list.add(data);
  return dumpAll(list.iterator());
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse the only YAML document in a stream and produce the corresponding
 * Java object.
 *
 * @param io
 *            data to load from (BOM is respected to detect encoding and removed from the data)
 * @param <T>
 *           the class of the instance to be created
 * @return parsed object
 */
@SuppressWarnings("unchecked")
public <T> T load(InputStream io) {
  return (T) loadFromReader(new StreamReader(new UnicodeReader(io)), Object.class);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Serialize a Java object into a YAML stream.
 *
 * @param data
 *            Java object to be serialized to YAML
 * @param output
 *            stream to write to
 */
public void dump(Object data, Writer output) {
  List<Object> list = new ArrayList<Object>(1);
  list.add(data);
  dumpAll(list.iterator(), output, null);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

/**
 * Parse the only YAML document in a stream and produce the corresponding
 * Java object.
 *
 * @param <T>
 *            Class is defined by the second argument
 * @param input
 *            data to load from (BOM is respected to detect encoding and removed from the data)
 * @param type
 *            Class of the object to be created
 * @return parsed object
 */
@SuppressWarnings("unchecked")
public <T> T loadAs(InputStream input, Class<T> type) {
  return (T) loadFromReader(new StreamReader(new UnicodeReader(input)), type);
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

list.add(data);
StringWriter buffer = new StringWriter();
dumpAll(list.iterator(), buffer, rootTag);
representer.setDefaultFlowStyle(oldStyle);
return buffer.toString();

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com