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


Java DumperOptions.setAllowReadOnlyProperties方法代码示例

本文整理汇总了Java中org.yaml.snakeyaml.DumperOptions.setAllowReadOnlyProperties方法的典型用法代码示例。如果您正苦于以下问题:Java DumperOptions.setAllowReadOnlyProperties方法的具体用法?Java DumperOptions.setAllowReadOnlyProperties怎么用?Java DumperOptions.setAllowReadOnlyProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.yaml.snakeyaml.DumperOptions的用法示例。


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

示例1: testDump

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDump() {
    Blog blog = new Blog("Test Me!");
    blog.addPost(new Post("Title1", "text 1"));
    blog.addPost(new Post("Title2", "text text 2"));
    blog.numbers.add(19);
    blog.numbers.add(17);
    TreeSet<String> labels = new TreeSet<String>();
    labels.add("Java");
    labels.add("YAML");
    labels.add("SnakeYAML");
    blog.setLabels(labels);
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(blog);
    // System.out.println(output);
    assertEquals(Util.getLocalResource("issues/issue73-1.txt"), output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:19,代码来源:SetAsSequenceTest.java

示例2: testBean2

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testBean2() {
    IncompleteBean bean = new IncompleteBean();
    bean.setName("lunch");
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dumpAsMap(bean);
    // System.out.println(output);
    assertEquals("id: 10\nname: lunch\n", output);
    //
    Yaml loader = new Yaml();
    try {
        loader.loadAs(output, IncompleteBean.class);
        fail("Setter is missing.");
    } catch (YAMLException e) {
        String message = e.getMessage();
        assertTrue(
                message,
                message.contains("Unable to find property 'id' on class: org.yaml.snakeyaml.issues.issue47.IncompleteBean"));
    }
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:22,代码来源:ReadOnlyPropertiesTest.java

示例3: toYaml

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
private String toYaml(Object obj) {
	DumperOptions options = new DumperOptions();
	options.setAllowReadOnlyProperties(true);
	options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	options.setIndent(4);
	return new Yaml(options).dump(obj);
}
 
开发者ID:xusida,项目名称:yaml-format,代码行数:8,代码来源:FormatYamlAction.java

示例4: testDumpCustomJavaClass

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDumpCustomJavaClass() {
    Hero hero = new Hero("Galain Ysseleg", -3, 2);
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(hero);
    assertEquals("!!examples.Hero {hp: -3, name: Galain Ysseleg, sp: 2}\n", output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:9,代码来源:DumpExampleTest.java

示例5: testRepresenter

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testRepresenter() {
    Dice dice = new Dice(3, 6);
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(dice);
    assertEquals("!!examples.Dice {a: 3, b: 6}\n", output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:9,代码来源:DiceExampleTest.java

示例6: testDumpFlow

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDumpFlow() {
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(new SetRepresenter(), options);
    String output = yaml.dump(createBlog());
    // System.out.println(output);
    assertEquals(Util.getLocalResource("issues/issue73-dump7.txt"), output);
    //
    check(output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:11,代码来源:DumpSetAsSequenceExampleTest.java

示例7: testDumpBlock

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testDumpBlock() {
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    options.setDefaultFlowStyle(FlowStyle.BLOCK);
    Yaml yaml = new Yaml(new SetRepresenter(), options);
    String output = yaml.dump(createBlog());
    // System.out.println(output);
    assertEquals(Util.getLocalResource("issues/issue73-dump8.txt"), output);
    //
    check(output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:12,代码来源:DumpSetAsSequenceExampleTest.java

示例8: test2beans

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void test2beans() {
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    Person person = new Person("Alan", "Gutierrez", 9);
    String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
    assertEquals(etalon, yaml.dump(person));
    Horse horse = new Horse("Tom", person);
    String etalon2 = "!!org.yaml.snakeyaml.issues.issue8.PrattleRepresenterTest$Horse\nname: Tom\nowner: {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
    assertEquals(etalon2, yaml.dump(horse));
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:12,代码来源:PrattleRepresenterTest.java

示例9: testMap

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testMap() throws Exception {
    BeanWithMap fact = new BeanWithMap();
    GenericMap<Integer> shash = fact.getMap();
    shash.put("toto", new Integer(10));
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    // String txt = yaml.dump(fact);
    // assertTrue(txt.contains("org.yaml.snakeyaml.issues.issue143.GenericMapTest"));
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:11,代码来源:GenericMapTest.java

示例10: testRepresenterNoConstructorAvailable

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testRepresenterNoConstructorAvailable() {
    MyBean2 bean = new MyBean2("Gnome", true);
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    assertEquals("!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean2 {valid: true}\n",
            yaml.dump(bean));
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:9,代码来源:RepresenterTest.java

示例11: testRepresentor

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testRepresentor() {
    IncompleteJavaBean bean = new IncompleteJavaBean();
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(bean);
    String className = this.getClass().getPackage().getName();
    assertEquals("!!" + className + ".IncompleteJavaBean {name: No name}\n", output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:10,代码来源:IncompleteBeanConstructorTest.java

示例12: testNoTemplate

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public void testNoTemplate() {
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dumpAsMap(createBean());
    // System.out.println(output);
    assertEquals(Util.getLocalResource("template/etalon1.yaml"), output);
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:9,代码来源:VelocityTest.java

示例13: serializeObject

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
public static String serializeObject(Object obj) {
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(false);
    options.setIndent(4);
    Yaml yaml = new Yaml(new OptimizationRepresenter(), options);

    return yaml.dump(obj);
}
 
开发者ID:openea,项目名称:eva2,代码行数:9,代码来源:BeanSerializer.java

示例14: createYaml

import org.yaml.snakeyaml.DumperOptions; //导入方法依赖的package包/类
/**
 * Creates and returns a new {@link Yaml} instance for (optional)
 * use in writing {@link ConfigOrBuilder} and {@link
 * MetadataOrBuilder} objects.
 *
 * <p>This method never returns {@code null}.</p>
 *
 * <p>Overrides of this method must not return {@code null}.</p>
 *
 * <p>Behavior is undefined if overrides of this method interact
 * with other methods defined by this class.</p>
 *
 * @return a non-{@code null} {@link Yaml} instance
 */
protected Yaml createYaml() {
  final Representer representer = new TerseRepresenter();
  representer.setPropertyUtils(new CustomPropertyUtils());
  final DumperOptions options = new DumperOptions();
  options.setAllowReadOnlyProperties(true);
  return new Yaml(new Constructor(), representer, options);
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:22,代码来源:AbstractChartWriter.java


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