我有以下课程
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
@XmlRootElement(name = "SegmentFilter")
public class SegmentFilter {
@XmlElementRefs({
@XmlElementRef(name = "StopRange", type = JAXBElement.class),
@XmlElementRef(name = "OverlapRange", type = JAXBElement.class),
@XmlElementRef(name = "DateRange", type = JAXBElement.class),
@XmlElementRef(name = "DurationRange", type = JAXBElement.class),
@XmlElementRef(name = "EmployeeSelector", type = JAXBElement.class),
@XmlElementRef(name = "SegmentCode", type = JAXBElement.class),
@XmlElementRef(name = "StartRange", type = JAXBElement.class)
})
@XmlMixed
protected List<Serializable> content;
@XmlAttribute(name = "IncludeDetailSegments")
protected Boolean includeDetailSegments;
@XmlAttribute(name = "IncludeGeneralSegments")
protected Boolean includeGeneralSegments;
public List<Serializable> getContent() {
if (content == null) {
content = new ArrayList<Serializable>();
}
return this.content;
}
public boolean isIncludeDetailSegments() {
if (includeDetailSegments == null) {
return true;
} else {
return includeDetailSegments;
}
}
public void setIncludeDetailSegments(Boolean value) {
this.includeDetailSegments = value;
}
public boolean isIncludeGeneralSegments() {
if (includeGeneralSegments == null) {
return true;
} else {
return includeGeneralSegments;
}
}
public void setIncludeGeneralSegments(Boolean value) {
this.includeGeneralSegments = value;
}
}
有人可以帮我用实际的Java代码代替ref吗...
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
@XmlRootElement(name = "SegmentFilter")
public class SegmentFilter {
public DateTimeRangeType StopRange;
public DateTimeRangeType StartRange;
//and so on with getters and setters
@XmlAttribute(name = "IncludeDetailSegments")
protected Boolean includeDetailSegments;
@XmlAttribute(name = "IncludeGeneralSegments")
protected Boolean includeGeneralSegments;
public List<Serializable> getContent() {
if (content == null) {
content = new ArrayList<Serializable>();
}
return this.content;
}
public boolean isIncludeDetailSegments() {
if (includeDetailSegments == null) {
return true;
} else {
return includeDetailSegments;
}
}
public void setIncludeDetailSegments(Boolean value) {
this.includeDetailSegments = value;
}
public boolean isIncludeGeneralSegments() {
if (includeGeneralSegments == null) {
return true;
} else {
return includeGeneralSegments;
}
}
public void setIncludeGeneralSegments(Boolean value) {
this.includeGeneralSegments = value;
}
}
如果我用复杂对象的实际xsd删除类型,例如在本例中的DateTimeRangeType,我可以使用eclipse生成jaxb类,这是下面的xsd,在较早的情况下,当没有类型并且所有元素都在主父类中定义,它可以获取xsd格式,但是在类型指向复杂类型的xsd的情况下似乎不起作用
<xs:element name="SegmentFilter">
<xs:annotation>
<xs:documentation>
SegmentFilter is a root-level element used
in a SegmentFilter request.
</xs:documentation>
</xs:annotation>
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="EmployeeSelector"
type="EmployeeSelectorType" minOccurs="0" />
<xs:element name="DateRange"
type="DateRangeType"/>
<xs:element name="DurationRange"
type="FromToTimeRangeType"/>
<xs:element name="SegmentCode"
type="EmptySKType"/>
<xs:element name="OverlapRange"
type="DateTimeRangeType"/>
<xs:element name="StartRange"
type="DateTimeRangeType"/>
<xs:element name="StopRange"
type="DateTimeRangeType"/>
</xs:sequence>
<xs:attribute name="IncludeDetailSegments"
default="true" type="xs:boolean"/>
<xs:attribute name="IncludeGeneralSegments"
default="true" type="xs:boolean"/>
</xs:complexType>
</xs:element>