enebo / jvyamlb forked from olabini/jvyamlb
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (5)
- Wiki (1)
- Graphs
-
Branch:
master
Thomas Enebo (author)
Fri Feb 27 07:23:53 -0800 2009
commit 25aa2d9fb3f108df16c65a0940758993e6676d8d
tree 302c7e06440060c2bbb3a995cb52d6e062237ba6
parent e0fdedcb337b8f94f7bbe08d7f85003ce9aa373d
tree 302c7e06440060c2bbb3a995cb52d6e062237ba6
parent e0fdedcb337b8f94f7bbe08d7f85003ce9aa373d
jvyamlb /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Nov 27 00:29:47 -0800 2008 | |
| |
CREDITS | Fri Apr 11 07:44:01 -0700 2008 | |
| |
LICENSE | Fri Apr 11 07:44:01 -0700 2008 | |
| |
MANIFEST.MF | ||
| |
README | Fri Apr 11 07:44:01 -0700 2008 | |
| |
build.xml | Thu Nov 27 00:33:05 -0800 2008 | |
| |
default.build.properties | Fri Apr 11 07:44:01 -0700 2008 | |
| |
lib/ | Fri Apr 11 07:44:01 -0700 2008 | |
| |
pom.xml | ||
| |
src/ |
README
= JvYAMLb - A pure Java YAML 1.1 loader and dumper Project Contact: Ola Bini <ola.bini@gmail.com> For a long time Java have lacked a good YAML loader and dumper with all the features that the SYCK using scripting communities have gotten used to. JvYAMLb aims to rectify this. It's a port from RbYAML by Ola Bini, which was a port of PyYAML3000, written by Kirill Simonov <xi@resolvent.net>. JvYAMLb is aimed at improving YAML performance in the JRuby project (http://jruby.sourceforge.net), but is also suitable for configuration and data storage in regular Java applications. JvYAMLb supports both 1.0 and 1.1 loading and dumping. == Usage To load a YAML document without any special customization, you can simply import org.jvyaml.YAML and do something like this: Map configuration = (Map)YAML.load(new FileReader("c:/projects/ourSpecificConfig.yml")); or this: List values = (List)YAML.load("--- \n- A\n- b\n- c\n"); Or if you have a YAML document that looks like this: --- !java/object:org.jruby.UserConfig userdir: d:/config/jruby prefs: - pref1.properties - values.properties - foo.xml Load it like this: org.jruby.UserConfig conf = (org.jruby.UserConfig)YAML.load(new FileReader("path.to.the.yaml.file")); conf.getUserdir(); ==> "d:/config/jruby" conf.getPrefs().iterator().next(); ==> "pref1.properties" Dumping is as easy as this: YAML.dump("str"); // -> "--- str\n" This works for complex objects too. If you want to dump to a stream instead of a String just add the stream to the dump command: YAML.dump("str",new FileWriter("test1.yml")); If you need to add parameters to either loading or dumping, just add a YAMLConfig object. For example, to dump with version 1.0 syntax (but not necessarily write a header), you can do it like this: YAML.dump("1.0",YAML.config().version("1.0")); JvYAMLb is very customizable. If you want to use a different Resolver or Constructor for your YAML document, it's very easy to change the behaviour by implementing the YAMLFactory interface. This is in fact the way JRuby returns RubyObjects instead of regular Java objects. A specialized JRubyConstructor is created, and when loading a JRubyYAMLFactory is created that uses this Constructor instead. == More information Visit http://jvyaml.dev.java.net for more information and updated versions == License JvYAMLb is distributed with a MIT license, which can be found in the file LICENSE.

