Jaxb通配符umarshalling编组

时间:2013-04-12 14:19:01

标签: java jaxb

首先抱歉我的英语不好。我想要解组,而不是编组以下课程。

@XmlSeeAlso({B1.class, C1.class})
public abstract class A1 implements Serializable {

private String parameterName;

  public A1 () {
  }


  public A1 (String parameterName) {
      this.parameterName = parameterName;
  }

  public String getParameterName() {
      return parameterName;
  }
}

子类

public class B1 extends A1{
@SuppressWarnings("rawtypes")
private Collection dataSource = new ArrayList();

public B1 () {

}


@SuppressWarnings("rawtypes")
public B1 (String parameterName, Collection dataSource) {
    super(parameterName);
    this.dataSource = dataSource;
}


@SuppressWarnings("rawtypes")
public B1 (Collection dataSource) {
    super("B");
    this.dataSource = dataSource;
}

@SuppressWarnings("rawtypes")
public Collection getDataSource() {
    return dataSource;
}

public class C1 extends A1 {

private String imagePath;


public C1() {

}

protected C1(String parameterName) {
    super(parameterName);
}


public C1 (String parameterName, String imagePath) {
    super(parameterName);
    this.imagePath = imagePath;
}

public String getImagePath() {
    return imagePath;
}

子类在集合

List<? extends A1>

解组和编组后,fieds将为null(例如:parameterName)。该应用程序不会抛出任何异常。

0 个答案:

没有答案