kiedy JAXB unmarshaller.unmarshal zwraca JAXBElement <MySchemaObject> lub MySchemaObject?

Mam dwa kody, w dwóch różnych projektach java, robiące prawie to samo (unmarshalling wejścia usługi sieciowej zgodnie z plikiem xsd).

Ale w jednym przypadku powinienem to napisać: (Wejście jest nazwą zastępczą) (elementem jest wejście OMElement)

<code>ClassLoader clInput = input.ObjectFactory.class.getClassLoader();
JAXBContext jc = JAXBContext.newInstance("input", clInput);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Input input = (Input)unmarshaller.unmarshal( element.getXMLStreamReader() );
</code>

w innej bibliotece muszę użyć JAXBElement.getValue (), ponieważ jest to JAXBElement, który jest zwracany, a prosty (wejściowy) rzut po prostu ulega awarii:

<code>Input input = (Input)unmarshaller.unmarshal( element.getXMLStreamReader() ).getValue();
</code>

Czy wiesz, co prowadzi do takiej różnicy?

questionAnswers(5)

yourAnswerToTheQuestion