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


Java DumperOptions.setDefaultFlowStyle方法代碼示例

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


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

示例1: YamlSnakeYaml

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public YamlSnakeYaml() {

		// Representer
		ExtensibleRepresenter representer = new ExtensibleRepresenter();

		// Install Java / Apache Cassandra serializers
		addDefaultSerializers(representer);

		// Install MongoDB / BSON serializers
		tryToAddSerializers("io.datatree.dom.adapters.YamlSnakeYamlBsonSerializers", representer);

		// Create flow-style YAML mapper
		DumperOptions optionsNormal = new DumperOptions();
		optionsNormal.setDefaultFlowStyle(FlowStyle.FLOW);
		mapper = new Yaml(representer, optionsNormal);

		// Create "pretty" YAML mapper
		DumperOptions optionsPretty = new DumperOptions();
		optionsPretty.setDefaultFlowStyle(FlowStyle.BLOCK);
		prettyMapper = new Yaml(representer, optionsPretty);
	}
 
開發者ID:berkesa,項目名稱:datatree-adapters,代碼行數:22,代碼來源:YamlSnakeYaml.java

示例2: reload

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void reload() {
	Config.createConfigFile(this.file);

	DumperOptions dumperOptions = new DumperOptions();
	dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	Yaml yaml = new Yaml(dumperOptions);
	try {
		this.list = yaml.loadAs(Utils.readFile(file), Map.class);
	} catch (IOException e) {
		e.printStackTrace();
	}

	if (this.list == null) {
		this.list = useSynchronization ? new Hashtable<>() : new HashMap<>();
	} else {
		this.list = useSynchronization ? new Hashtable<>(this.list) : new HashMap<>(this.list);
	}
}
 
開發者ID:Him188,項目名稱:JPRE,代碼行數:21,代碼來源:YamlConfig.java

示例3: addServerId

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public static void addServerId(String serverId) throws IOException {

        FileWriter writer = new FileWriter(ConfigurationConstants.CONFIG_FILE_NAME);

        DumperOptions options=new DumperOptions();
        options.setIndent(1);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

        Yaml yaml=new Yaml(new NullRepresenter(),options);
        String conf = yaml.dump(configuration);
        yaml.dump(conf, writer);

        //remove |- literal from the config file
        File file = new File(ConfigurationConstants.CONFIG_FILE_NAME);
        String s1 = FileUtils.readFileToString(file);
        String substring = s1.substring(1, s1.length() - 1);
        FileUtils.writeStringToFile(file,substring);
    }
 
開發者ID:rndsolutions,項目名稱:hawkcd,代碼行數:19,代碼來源:Config.java

示例4: configYamlFormat

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private static void configYamlFormat(final ToolBelt belt, final AppConfig config) {
    DumperOptions dumperOptions = new DumperOptions();
    dumperOptions.setDefaultFlowStyle(
            "BLOCK".equalsIgnoreCase(config.getString("RD_YAML_FLOW", "BLOCK")) ?
            DumperOptions.FlowStyle.BLOCK :
            DumperOptions.FlowStyle.FLOW
    );
    dumperOptions.setPrettyFlow(config.getBool("RD_YAML_PRETTY", true));
    Representer representer = new Representer();
    representer.addClassTag(JobItem.class, Tag.MAP);
    representer.addClassTag(ScheduledJobItem.class, Tag.MAP);
    representer.addClassTag(DateInfo.class, Tag.MAP);
    representer.addClassTag(Execution.class, Tag.MAP);
    belt.formatter(new YamlFormatter(representer, dumperOptions));
    belt.channels().infoEnabled(false);
    belt.channels().warningEnabled(false);
    belt.channels().errorEnabled(false);
}
 
開發者ID:rundeck,項目名稱:rundeck-cli,代碼行數:19,代碼來源:Main.java

示例5: toString

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Override
public String toString() {
    Map<String,Object> data = new LinkedHashMap<String,Object>() {{
        if (asset != null) {
            put(ASSET, asset);
        }
        put(MAIN_CLASS, mainClass);
        put(HOLLOW, hollow);
        put(PROPERTIES, properties);
        put(MODULES, bootstrapModules);
        put(BOOTSTRAP_ARTIFACTS, bootstrapArtifacts);
        put(BUNDLE_DEPENDENCIES, bundleDependencies);
        put(DEPENDENCIES, dependencies);
    }};

    DumperOptions options = new DumperOptions();
    options.setPrettyFlow(true);
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
    Yaml yaml = new Yaml(options);

    return yaml.dump(data);
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:23,代碼來源:WildFlySwarmManifest.java

示例6: testSplitLineExpectFlowSequenceItem

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testSplitLineExpectFlowSequenceItem() {

        DumperOptions options = new DumperOptions();
        options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
        options.setWidth(8);
        Yaml yaml;
        String output;

        // Split lines enabled (default)
        yaml = new Yaml(options);
        output = yaml.dump(Arrays.asList("1111111111", "2222222222"));
        assertEquals("[\"1111111111\",\n  \"2222222222\"]\n", output);
        output = yaml.dump(Arrays.asList("1", "2"));
        assertEquals("[\"1\", \"2\"]\n", output);

        // Split lines disabled
        options.setSplitLines(false);
        assertFalse(options.getSplitLines());
        yaml = new Yaml(options);
        output = yaml.dump(Arrays.asList("1111111111", "2222222222"));
        assertEquals("[\"1111111111\", \"2222222222\"]\n", output);
        output = yaml.dump(Arrays.asList("1", "2"));
        assertEquals("[\"1\", \"2\"]\n", output);
    }
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:26,代碼來源:EmitterTest.java

示例7: testWriteMultiLineList

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public void testWriteMultiLineList() {
    String one = "first\nsecond\nthird";
    String two = "one\ntwo\nthree\n";
    byte[] binary = { 8, 14, 15, 10, 126, 32, 65, 65, 65 };
    List<Object> list = new ArrayList<Object>(2);
    list.add(one);
    list.add(two);
    list.add(binary);
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(FlowStyle.BLOCK);
    Yaml yaml = new Yaml(options);
    String output = yaml.dump(list);
    // System.out.println(output);
    String etalon = "- |-\n  first\n  second\n  third\n- |\n  one\n  two\n  three\n- !!binary |-\n  CA4PCn4gQUFB\n";
    assertEquals(etalon, output);
    @SuppressWarnings("unchecked")
    List<Object> parsed = (List<Object>) yaml.load(etalon);
    assertEquals(3, parsed.size());
    assertEquals(one, parsed.get(0));
    assertEquals(two, parsed.get(1));
    assertEquals(new String(binary), new String((byte[]) parsed.get(2)));
}
 
開發者ID:bmoliveira,項目名稱:snake-yaml,代碼行數:23,代碼來源:EmitterMultiLineTest.java

示例8: initialValue

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Override
protected Yaml initialValue()
{
    Representer representer = new Representer()
    {
        {
            representers.put( Configuration.class, new Represent()
            {
                @Override
                public Node representData(Object data)
                {
                    return represent( ( (Configuration) data ).self );
                }
            } );
        }
    };

    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle( DumperOptions.FlowStyle.BLOCK );

    return new Yaml( new Constructor(), representer, options );
}
 
開發者ID:tylerhasman,項目名稱:MapleStory,代碼行數:23,代碼來源:YamlConfiguration.java

示例9: getYaml

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public static Yaml getYaml() {
    final DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
    options.setPrettyFlow(true);

    SkipNullRepresenter representer = new SkipNullRepresenter();
    representer.addClassTag(TestDefAction.class, Tag.MAP);

    return new Yaml(representer, options);
}
 
開發者ID:mcdcorp,項目名稱:opentest,代碼行數:11,代碼來源:Factory.java

示例10: reloadConfig

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Override
public void reloadConfig() {
    this.config = new Config(this.configFile);
    InputStream configStream = this.getResource("config.yml");
    if (configStream != null) {
        DumperOptions dumperOptions = new DumperOptions();
        dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(dumperOptions);
        try {
            this.config.setDefault(yaml.loadAs(Utils.readFile(this.configFile), LinkedHashMap.class));
        } catch (IOException e) {
            Server.getInstance().getLogger().logException(e);
        }
    }
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:16,代碼來源:PluginBase.java

示例11: parseContent

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private void parseContent(String content) {
    switch (this.type) {
        case Config.PROPERTIES:
            this.parseProperties(content);
            break;
        case Config.JSON:
            GsonBuilder builder = new GsonBuilder();
            Gson gson = builder.create();
            this.config = new ConfigSection(gson.fromJson(content, new TypeToken<LinkedHashMap<String, Object>>() {
            }.getType()));
            break;
        case Config.YAML:
            DumperOptions dumperOptions = new DumperOptions();
            dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
            Yaml yaml = new Yaml(dumperOptions);
            this.config = new ConfigSection(yaml.loadAs(content, LinkedHashMap.class));
            if (this.config == null) {
                this.config = new ConfigSection();
            }
            break;
        // case Config.SERIALIZED
        case Config.ENUM:
            this.parseList(content);
            break;
        default:
            this.correct = false;
    }
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:29,代碼來源:Config.java

示例12: createSimplePackage

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
private Package createSimplePackage() throws IOException {
	Package pkg = new Package();

	// Add package metadata
	PackageMetadata packageMetadata = new PackageMetadata();
	packageMetadata.setName("myapp");
	packageMetadata.setVersion("1.0.0");
	packageMetadata.setMaintainer("bob");
	pkg.setMetadata(packageMetadata);

	// Add ConfigValues
	Map<String, String> map = new HashMap<>();
	map.put("foo", "bar");
	map.put("fiz", "faz");
	DumperOptions dumperOptions = new DumperOptions();
	dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	dumperOptions.setPrettyFlow(true);
	Yaml yaml = new Yaml(dumperOptions);
	ConfigValues configValues = new ConfigValues();
	configValues.setRaw(yaml.dump(map));
	pkg.setConfigValues(configValues);

	// Add template
	Resource resource = new ClassPathResource("/org/springframework/cloud/skipper/io/generic-template.yml");
	String genericTempateData = StreamUtils.copyToString(resource.getInputStream(), Charset.defaultCharset());
	Template template = new Template();
	template.setData(genericTempateData);
	template.setName(resource.getURL().toString());
	List<Template> templateList = new ArrayList<>();
	templateList.add(template);
	pkg.setTemplates(templateList);

	return pkg;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:35,代碼來源:PackageWriterTests.java

示例13: save

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
@Override
public void save() {
	DumperOptions dumperOptions = new DumperOptions();
	dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
	Yaml yaml = new Yaml(dumperOptions);
	try {
		Utils.writeFile(file, yaml.dump(this.list));
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:Him188,項目名稱:JPRE,代碼行數:12,代碼來源:YamlConfig.java

示例14: save

import org.yaml.snakeyaml.DumperOptions; //導入方法依賴的package包/類
public boolean save(Boolean async) {
    if (this.file == null) throw new IllegalStateException("Failed to save Config. File object is undefined.");
    if (this.correct) {
        String content = "";
        switch (this.type) {
            case Config.PROPERTIES:
                content = this.writeProperties();
                break;
            case Config.JSON:
                content = new GsonBuilder().setPrettyPrinting().create().toJson(this.config);
                break;
            case Config.YAML:
                DumperOptions dumperOptions = new DumperOptions();
                dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
                Yaml yaml = new Yaml(dumperOptions);
                content = yaml.dump(this.config);
                break;
            case Config.ENUM:
                for (Object o : this.config.entrySet()) {
                    Map.Entry entry = (Map.Entry) o;
                    content += String.valueOf(entry.getKey()) + "\r\n";
                }
                break;
        }
        if (async) {
            Server.getInstance().getScheduler().scheduleAsyncTask(new FileWriteTask(this.file, content));

        } else {
            try {
                Utils.writeFile(this.file, content);
            } catch (IOException e) {
                Server.getInstance().getLogger().logException(e);
            }
        }
        return true;
    } else {
        return false;
    }
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:40,代碼來源:Config.java

示例15: 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


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