2014-04-10 7 views
0
)

XStream을 통해 XML에 Jtree를 serialize하고자합니다.Java Xstream 사용자 지정 변환기 (Jtree

JTree를이 같은 사용자 개체로 구성

public class Chapter{ 

private int id;  
private String iconName; 
/** 
* @return the id 
*/ 
public int getId() { 
    return id; 
} 

/** 
* @param id the id to set 
*/ 
public void setId(int id) { 
    this.id = id; 
} 

@Override 
public String toString() { 
    return this.getTitel(); 
} 

/** 
* @return the icon 
*/ 
public String getIcon() { 
    return iconName; 
} 

/** 
* @param icon the icon to set 
*/ 
public void setIcon(String icon) { 
    this.iconName = icon; 
} 

} 

트리의 구조가 다음과 같습니다

<chapter> 
<id>1</id> 
    <chapter> 
    <id>1</id> 
     <chapter> 
     <id>1.1</id> 
     <chapter> 
    <chapter> 
    <id>2</id> 
    </chapter> 
    </chapter> 
.... 
</chapter> 
: 내가 그런 XML 문자열을 원하는 어떤

root 
    +chapter 1 
     -chapter 1.1 
     -chapter 1.2 
      -chapter 1.2.1 
    .... 
     +chapter 10 

어떻게해야합니까? Xml 문자열을 직렬화 할 필요가 없습니다.

감사합니다.

답변