From: Toby Ho <air...@gm...> - 2005-12-16 23:49:11
|
I did reproduce the first problem with the -1. I'm working on the fix. Thanks for letting me know. toby On 12/16/05, Toby Ho <air...@gm...> wrote: > Sorry, I meant to say 'what if both the JavaBean property and field is > present?', i.e. You have the field, plus the getters and setters. > > toby > > On 12/16/05, Toby Ho <air...@gm...> wrote: > > Hi skimo, > > > > Yeah, I'm sorry but I have to tell you it IS because of the missing > > setter/getters. I had thought that the JavaBean convention was so > > prevalent that everyone's using them by default(eclipse generates them > > for you), so I only planned to support them. I could extend it to > > handle fields as well, but we might run into issues if for example > > what if both the JavaBean and field is present? Which one should JYaml > > read from/write to? It could be even worst if the setter or getter > > does something funky before it sets the field value, if it actually > > sets it at all. What are your thoughts? > > > > toby > > > > > > > > On 12/16/05, Sven Verdoolaege <ski...@ko...> wrote: > > > On Wed, Dec 14, 2005 at 01:48:58PM -0500, Toby Ho wrote: > > > > Hi all, > > > > > > > > I have released Jyaml - a Java library (loader/dumper) for Yaml, > > > > continuing the work of Rolf Veen. > > > > > > > > > > I can't get it to work: > > > > > > test.java: > > > import org.ho.yml.YmlDecoder; > > > import java.io.FileNotFoundException; > > > > > > public class test { > > > public static void main(String[] args) { > > > try { > > > PDG pdg =3D YmlDecoder.loadObjectFromFileOfType( > > > "test.yaml", PDG.class); > > > } catch(FileNotFoundException ex){ > > > System.out.println("error"); > > > } > > > } > > > } > > > > > > > > > bash-3.00$ cat test.yaml > > > --- > > > cacheline: -1 > > > bash-3.00$ java test > > > test > > > Exception in thread "main" org.ho.yml.YmlParserException: org.ho.yml.= YmlParserException: Error near line 2: yaml.parser.SyntaxException: no valu= e after ':' > > > at org.ho.yml.YmlDecoder.readObjectOfType(YmlDecoder.java:152= ) > > > at org.ho.yml.YmlDecoder.loadObjectFromFileOfType(YmlDecoder.= java:198) > > > at test.main(test.java:8) > > > Caused by: org.ho.yml.YmlParserException: Error near line 2: yaml.par= ser.SyntaxException: no value after ':' > > > at org.ho.yml.SYamlParserEvent.error(SYamlParserEvent.java:64= ) > > > at org.ho.yml.YmlDecoder.firstDocument(YmlDecoder.java:114) > > > at org.ho.yml.YmlDecoder.readObjectOfType(YmlDecoder.java:139= ) > > > ... 2 more > > > > > > Then if I change the value from -1 to 0, I get: > > > bash-3.00$ cat test.yaml > > > --- > > > cacheline: 0 > > > bash-3.00$ java test > > > test > > > Exception in thread "main" org.ho.yml.YmlParserException: org.ho.yml.= YmlParserException: Error setting cacheline property on PDG@1a758cb with va= lue 0 > > > java.lang.NullPointerException > > > at org.ho.yml.YmlDecoder.readObjectOfType(YmlDecoder.java:152= ) > > > at org.ho.yml.YmlDecoder.loadObjectFromFileOfType(YmlDecoder.= java:198) > > > at test.main(test.java:8) > > > Caused by: org.ho.yml.YmlParserException: Error setting cacheline pro= perty on PDG@1a758cb with value 0 > > > java.lang.NullPointerException > > > at org.ho.yml.states.MapState.setProperty(MapState.java:205) > > > at org.ho.yml.states.MapState.nextOnContent(MapState.java:75) > > > at org.ho.yml.SYamlParserEvent.content(SYamlParserEvent.java:= 59) > > > at yaml.parser.YamlParser.sendEvents(YamlParser.java:110) > > > at yaml.parser.YamlParser.loose_value_inline(YamlParser.java:= 693) > > > at yaml.parser.YamlParser.loose_value(YamlParser.java:642) > > > at yaml.parser.YamlParser.nmap_entry(YamlParser.java:823) > > > at yaml.parser.YamlParser.nmap(YamlParser.java:797) > > > at yaml.parser.YamlParser.value_nested(YamlParser.java:748) > > > at yaml.parser.YamlParser.value_na(YamlParser.java:651) > > > at org.ho.yml.YmlDecoder.firstDocument(YmlDecoder.java:111) > > > at org.ho.yml.YmlDecoder.readObjectOfType(YmlDecoder.java:139= ) > > > ... 2 more > > > > > > Why does it bomb out when my class doesn't have the field ? > > > It should either ignore the field or store it somewhere so you > > > can output it again if I ever try to write my object again. > > > > > > Even when my class _does_ have the field, it still bombs out > > > with the same error message: > > > > > > PDG.java: > > > public class PDG { > > > public String cacheline; > > > } > > > > > > Don't tell me I need to add get and set methods. > > > Java reflection should be able to get at this field and allow > > > you to set it with the value you found. > > > > > > skimo > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: Splunk Inc. Do you grep through lo= g files > > > for problems? Stop! Download the new AJAX search engine that makes > > > searching your log files as easy as surfing the web. DOWNLOAD SPLUN= K! > > > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > > > _______________________________________________ > > > Yaml-core mailing list > > > Yam...@li... > > > https://lists.sourceforge.net/lists/listinfo/yaml-core > > > > > > |