1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
61 import javax.imageio.ImageIO; |
61 import javax.imageio.ImageIO; |
62 import javax.imageio.ImageWriter; |
62 import javax.imageio.ImageWriter; |
63 import javax.imageio.stream.ImageOutputStream; |
63 import javax.imageio.stream.ImageOutputStream; |
64 import javax.xml.bind.ValidationEvent; |
64 import javax.xml.bind.ValidationEvent; |
65 import javax.xml.bind.helpers.ValidationEventImpl; |
65 import javax.xml.bind.helpers.ValidationEventImpl; |
66 import javax.xml.datatype.DatatypeConfigurationException; |
|
67 import javax.xml.datatype.DatatypeConstants; |
66 import javax.xml.datatype.DatatypeConstants; |
68 import javax.xml.datatype.DatatypeFactory; |
|
69 import javax.xml.datatype.Duration; |
67 import javax.xml.datatype.Duration; |
70 import javax.xml.datatype.XMLGregorianCalendar; |
68 import javax.xml.datatype.XMLGregorianCalendar; |
71 import javax.xml.namespace.QName; |
69 import javax.xml.namespace.QName; |
72 import javax.xml.stream.XMLStreamException; |
70 import javax.xml.stream.XMLStreamException; |
73 import javax.xml.transform.OutputKeys; |
71 import javax.xml.transform.OutputKeys; |
566 return cal.toXMLFormat(); |
564 return cal.toXMLFormat(); |
567 } |
565 } |
568 |
566 |
569 public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException { |
567 public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException { |
570 try { |
568 try { |
571 return datatypeFactory.newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) |
569 return DatatypeConverterImpl.getDatatypeFactory() |
|
570 .newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) |
572 } catch (Exception e) { |
571 } catch (Exception e) { |
573 UnmarshallingContext.getInstance().handleError(e); |
572 UnmarshallingContext.getInstance().handleError(e); |
574 return null; |
573 return null; |
575 } |
574 } |
576 } |
575 } |
836 return duration.toString(); |
835 return duration.toString(); |
837 } |
836 } |
838 |
837 |
839 public Duration parse(CharSequence lexical) { |
838 public Duration parse(CharSequence lexical) { |
840 TODO.checkSpec("JSR222 Issue #42"); |
839 TODO.checkSpec("JSR222 Issue #42"); |
841 return datatypeFactory.newDuration(lexical.toString()); |
840 return DatatypeConverterImpl.getDatatypeFactory().newDuration(lexical.toString()); |
842 } |
841 } |
843 }); |
842 }); |
844 primaryList.add( |
843 primaryList.add( |
845 new StringImpl<Void>(Void.class) { |
844 new StringImpl<Void>(Void.class) { |
846 // 'void' binding isn't defined by the spec, but when the JAX-RPC processes user-defined |
845 // 'void' binding isn't defined by the spec, but when the JAX-RPC processes user-defined |
874 if (text instanceof Base64Data) { |
873 if (text instanceof Base64Data) { |
875 Base64Data base64Data = (Base64Data) text; |
874 Base64Data base64Data = (Base64Data) text; |
876 return base64Data.getExact(); |
875 return base64Data.getExact(); |
877 } else { |
876 } else { |
878 return DatatypeConverterImpl._parseBase64Binary(text.toString()); |
877 return DatatypeConverterImpl._parseBase64Binary(text.toString()); |
879 } |
|
880 } |
|
881 |
|
882 |
|
883 /** |
|
884 * Cached instance of {@link DatatypeFactory} to create |
|
885 * {@link XMLGregorianCalendar} and {@link Duration}. |
|
886 */ |
|
887 private static final DatatypeFactory datatypeFactory = init(); |
|
888 |
|
889 private static DatatypeFactory init() { |
|
890 try { |
|
891 return DatatypeFactory.newInstance(); |
|
892 } catch (DatatypeConfigurationException e) { |
|
893 throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e); |
|
894 } |
878 } |
895 } |
879 } |
896 |
880 |
897 private static void checkXmlGregorianCalendarFieldRef(QName type, |
881 private static void checkXmlGregorianCalendarFieldRef(QName type, |
898 XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ |
882 XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{ |