update xmlrootelement annotation
This commit is contained in:
@@ -164,7 +164,9 @@ public class SimpleHttpClient implements HttpClient {
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
is.close();
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
HttpResponse response = new HttpResponse();
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.Serializable;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
@@ -17,6 +18,7 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class XmlResult implements Serializable {
|
||||
|
||||
|
||||
@@ -77,14 +77,16 @@ public final class XmlStream {
|
||||
Source source = new StreamSource(content);
|
||||
XmlRootElement rootElement = clazz
|
||||
.getAnnotation(XmlRootElement.class);
|
||||
if (rootElement == null) {
|
||||
if (rootElement == null || rootElement.name().equals(
|
||||
XmlRootElement.class.getMethod("name")
|
||||
.getDefaultValue().toString())) {
|
||||
JAXBElement<T> jaxbElement = unmarshaller.unmarshal(source,
|
||||
clazz);
|
||||
return jaxbElement.getValue();
|
||||
} else {
|
||||
return (T) unmarshaller.unmarshal(source);
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
} finally {
|
||||
if (content != null) {
|
||||
@@ -253,7 +255,10 @@ public final class XmlStream {
|
||||
try {
|
||||
XmlRootElement rootElement = clazz
|
||||
.getAnnotation(XmlRootElement.class);
|
||||
if (rootElement == null) {
|
||||
if (rootElement == null
|
||||
|| rootElement.name().equals(
|
||||
XmlRootElement.class.getMethod("name")
|
||||
.getDefaultValue().toString())) {
|
||||
marshaller.marshal(new JAXBElement<T>(new QName(
|
||||
ROOT_ELEMENT_XML), clazz, t), os);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user