1 29 30 package com.caucho.jaxb.skeleton; 31 import com.caucho.jaxb.*; 32 import javax.xml.bind.*; 33 import javax.xml.datatype.*; 34 import javax.xml.namespace.*; 35 import javax.xml.stream.*; 36 import java.util.*; 37 import java.text.*; 38 39 import java.lang.reflect.*; 40 import java.io.*; 41 42 import com.caucho.vfs.WriteStream; 43 44 47 public class XMLGregorianCalendarProperty extends CDataProperty { 48 private DatatypeFactory _datatypeFactory; 49 50 public static final XMLGregorianCalendarProperty PROPERTY 51 = new XMLGregorianCalendarProperty(); 52 53 protected String write(Object in) 54 throws IOException, XMLStreamException 55 { 56 return ((XMLGregorianCalendar) in).toXMLFormat(); 57 } 58 59 protected Object read(String in) 60 throws IOException, XMLStreamException, JAXBException 61 { 62 return getDatatypeFactory().newXMLGregorianCalendar(in); 63 } 64 65 public String getSchemaType() 66 { 67 return "xsd:dateTime"; 68 } 69 70 private DatatypeFactory getDatatypeFactory() 71 throws JAXBException 72 { 73 if (_datatypeFactory == null) { 74 try { 75 _datatypeFactory = DatatypeFactory.newInstance(); 76 } 77 catch (DatatypeConfigurationException e) { 78 throw new JAXBException(e); 79 } 80 } 81 82 return _datatypeFactory; 83 } 84 } 85 86 87 | Popular Tags |