當前位置: 首頁>>代碼示例>>Java>>正文


Java Yaml.dumpAsMap方法代碼示例

本文整理匯總了Java中org.yaml.snakeyaml.Yaml.dumpAsMap方法的典型用法代碼示例。如果您正苦於以下問題:Java Yaml.dumpAsMap方法的具體用法?Java Yaml.dumpAsMap怎麽用?Java Yaml.dumpAsMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.yaml.snakeyaml.Yaml的用法示例。


在下文中一共展示了Yaml.dumpAsMap方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toYAML

import org.yaml.snakeyaml.Yaml; //導入方法依賴的package包/類
/**
 * Marshals the supplied {@link Object} to YAML in the context of
 * the supplied {@link Context} and returns the result.
 *
 * <p>This method never returns {@code null}.</p>
 *
 * <p>This method may call the {@link #createYaml()} method.</p>
 *
 * @param context the {@link Context} representing the write
 * operation; must not be {@code null}
 *
 * @param data the {@link Object} to convert to its YAML
 * representation; may be {@code null}
 *
 * @return a non-{@code null} {@link String} consisting of the
 * appropriate YAML represesentation of the supplied {@code data}
 *
 * @exception IOException if a YAML serialization error occurs
 *
 * @exception NullPointerException if {@code context} is {@code
 * null}
 *
 * @see #createYaml()
 *
 * @see Yaml#dumpAsMap(Object)
 */
protected final String toYAML(final Context context, final Object data) throws IOException {
  Objects.requireNonNull(context);
  Yaml yaml = context.get(Yaml.class.getName(), Yaml.class);
  if (yaml == null) {
    yaml = this.createYaml();
    if (yaml == null) {
      throw new IllegalStateException("createYaml() == null");
    }
    context.put(Yaml.class.getName(), yaml);
  }
  return yaml.dumpAsMap(data);
}
 
開發者ID:microbean,項目名稱:microbean-helm,代碼行數:39,代碼來源:AbstractChartWriter.java


注:本文中的org.yaml.snakeyaml.Yaml.dumpAsMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。