當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。