0
snakeyaml 1.11 및 yaml에 대한 것입니다.Snakeyaml : 제네릭 확장 맵의 속성
확장 된 제네릭 맵이있는 속성을 사용하여 bean을 덤프하면 snakeyaml이 중단됩니다. 여기
public static class MyStupidHash<T> extends java.util.HashMap<String, T>
{
}
덤프 할 수없는 특성 snakeyam와 콩입니다 : 여기
가 확장 된 일반 맵
public class FactoryOfStupid
{
public MyStupidHash<Integer> getStupid()
{
return new MyStupidHash<Integer>();
}
}
을 내가 snakeyaml와 FactoryOfStupid 개체를 덤프 때, 나는 얻을 :
java.lang.ArrayIndexOutOfBoundsException: 1
at org.yaml.snakeyaml.representer.Representer.checkGlobalTag(Representer.java:204)
at org.yaml.snakeyaml.representer.Representer.representJavaBeanProperty(Representer.java:144)
at org.yaml.snakeyaml.representer.Representer.representJavaBean(Representer.java:83)
at org.yaml.snakeyaml.representer.Representer$RepresentJavaBean.representData(Representer.java:49)
at org.yaml.snakeyaml.representer.BaseRepresenter.representData(BaseRepresenter.java:109)
at org.yaml.snakeyaml.representer.BaseRepresenter.represent(BaseRepresenter.java:65)
at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:270)
at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:261)
at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:233)
at org.yaml.snakeyaml.Yaml.dump(Yaml.java:209)
다음은 모두 junit 테스트입니다.
/*
*/
package unitaire;
import java.util.HashMap;
import org.junit.*;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
/**
*
* @author herve
*/
public class YamlRepresenterUnitTest
{
public YamlRepresenterUnitTest()
{
}
@BeforeClass
public static void setUpClass() throws Exception
{
}
@AfterClass
public static void tearDownClass() throws Exception
{
}
@Before
public void setUp()
{
}
@After
public void tearDown()
{
}
@Test
public void onMyStupidHash() throws Exception
{
MyStupidHash<Integer> shash;
Yaml yaml;
String txt;
DumperOptions options;
FactoryOfStupid fact;
fact = new FactoryOfStupid();
shash = fact.getStupid();
shash.put("toto", new Integer(10));
options = new DumperOptions();
options.setAllowReadOnlyProperties(true);
yaml = new Yaml(options);
txt = yaml.dump(fact);
System.out.println("txt="+txt);
}
public static class MyStupidHash<T> extends java.util.HashMap<String, T>
{
}
public class FactoryOfStupid
{
public MyStupidHash<Integer> getStupid()
{
return new MyStupidHash<Integer>();
}
}
}
이런 종류의 것들을 덤프하기 위해 snakeyaml에 기적적인 옵션이 있습니까?
감사합니다.