0

これは、プロパティオブジェクトのマーシャリングに関するものではないことに注意してください。

プロパティ形式にマーシャルしたいのですが。例:

class Foo { String a = "aaa"; Item i = new Item(); }
class Item { String val = "Value"; }

marshall( new 

の中へ

a = Hello
i.value = Value

このアプローチには限界があることは知っていますが、それは問題ありません。

これらの線に沿って何かがありますか?

そうでない場合は、オブジェクトのクエリとそのオブジェクトツリー内の「文字列キー」の識別の両方を実行できる単純な式言語libがありますか?

BeanUtilsを確認しました-何もありません。

4

1 に答える 1

1

これにはobjectprops(http://code.google.com/p/objectprops/)を使用できます。

ObjectPropertiesStore store = new ObjectPropertiesStore();

// write the object to the store        
store.writeObject(new Foo());

// let's get the Properties object and print the contents to System.out
Properties properties = store.getDatabase();
properties.store( System.out, "My test");

または、commons-langのReflectionToStringBuilderを使用してこれを簡単な方法で実装し、自分で実装したカスタムToStringStyleを渡して、結果の文字列をPropertiesオブジェクトにロードすることもできます。

于 2012-09-29T06:47:33.140 に答える