I am trying to make it simpler to play with XMLGregorianCalendar. In doing so, I have created a maiture and have transformed:
Applies the public class MyMachterMature {@Override public transform & lt ;? & Gt; Match (@SuppressWarnings ("raw type") last class type) throws an exception {if (type.equals (XMLGregorianCalendar.class)) {Return New XMLGregorianCalendarTransform (); } Return tap; }} and
public class XMLGregorianCalendarTransform tool conversion & lt; XMLGregorianCalendar & gt; {@ Override public XMLGregorianCalendar (the last string value) throws exceptions {Returns DatatypeFactory.newInstance (). NewXMLGregorianCalendar (value); } @ Override public string write (final XMLGregorianCalendar value) throws exception {return value.toXMLFormat (); }} When this code is used to deserialize, then it works very well:
final serial arrow serializer = new insistor ( New MimeTech ()); Obj = serializer.read (type, new bytereinputstream (xml.getBytes (charset name (UTF8_ENCODING)))); Unfortunately, when I try to use it to serialize it does not work, it throws fails to create an XML string for the object Org.simpleframework .xml.transform.TransformException: class com.sun.org.apache.xerces.internal.jaxp.datatyp e.XMLGregorianCalendarImpl not supported error, the method of writing my conversion is never called). Here is the code that I use to serialize:
last byteOrputationBas = new byteOnputStream (); OS = new data overputstream (Baoos); Final Serializer Serializer = New Insulator (New MimeTech ()); Serializer.write (this, OS); Os.flush (); XmlString = New String (Bao 2. Betteere (), Charset.FireName (UTF8_ACCOIDIG)); Writing method throws exceptions I have used as a reference, and it got me to work deserialization, but now I'm stuck. I'm not sure how to move forward.
Any help is appreciated.
It has been found that the answer was in question. Error XMLGregorianCalendarImpl is not supported. It does not have to check my mileage. I just had to change: if (type.equals (XMLGregorianCalendar.class)) {< / Code> to
if (XMLGregorianCalendar.class.isAssignableFrom (type)) { I hope it's someone helps.
No comments:
Post a Comment