1 17 package org.apache.ws.jaxme.impl; 18 19 import java.text.Format ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import javax.xml.bind.DatatypeConverterInterface; 24 import javax.xml.bind.PropertyException; 25 import javax.xml.bind.ValidationEventHandler; 26 27 import org.apache.ws.jaxme.xs.util.XsDateFormat; 28 import org.apache.ws.jaxme.xs.util.XsDateTimeFormat; 29 import org.apache.ws.jaxme.xs.util.XsTimeFormat; 30 31 32 33 39 public abstract class JMControllerImpl { 40 45 public static final String JAXME_PRIVATE = "jaxme.private."; 46 47 50 public static final String JAXME_DATATYPE_CONVERTER = "jaxme.datatypeConverter"; 51 52 57 public static final String JAXME_FORMAT_DATETIME = "jaxme.format.dateTime"; 58 59 64 public static final String JAXME_FORMAT_DATE = "jaxme.format.date"; 65 66 71 public static final String JAXME_FORMAT_TIME = "jaxme.format.time"; 72 73 private Map privateMap; 74 private JAXBContextImpl context; 75 private DatatypeConverterInterface datatypeConverter = new DatatypeConverterImpl(); 76 private Format dateTimeFormat, dateFormat, timeFormat; 77 78 81 public void setProperty(String pProperty, Object pValue) 82 throws PropertyException { 83 if (pProperty.startsWith(JAXME_PRIVATE)) { 84 if (privateMap == null) { 85 privateMap = new HashMap (); 86 } 87 privateMap.put(pProperty, pValue); 88 return; 89 } else if (pProperty.equals(JAXME_DATATYPE_CONVERTER)) { 90 datatypeConverter = (DatatypeConverterInterface) pValue; 91 return; 92 } else if (JAXME_FORMAT_DATETIME.equals(pProperty)) { 93 setDateTimeFormat((Format ) pValue); 94 } else if (JAXME_FORMAT_DATE.equals(pProperty)) { 95 setDateFormat((Format ) pValue); 96 } else if (JAXME_FORMAT_TIME.equals(pProperty)) { 97 setTimeFormat((Format ) pValue); 98 } 99 100 throw new PropertyException("Unknown property: " + pProperty); 101 } 102 103 105 public Object getProperty(String pProperty) throws PropertyException { 106 if (pProperty.startsWith(JAXME_PRIVATE)) { 107 if (privateMap == null) { return null; } 108 return privateMap.get(pProperty); 109 } else if (pProperty.equals(JAXME_DATATYPE_CONVERTER)) { 110 return datatypeConverter; 111 } else if (JAXME_FORMAT_DATETIME.equals(pProperty)) { 112 return getDateTimeFormat(); 113 } else if (JAXME_FORMAT_DATE.equals(pProperty)) { 114 return getDateFormat(); 115 } else if (JAXME_FORMAT_TIME.equals(pProperty)) { 116 return getTimeFormat(); 117 } 118 119 throw new PropertyException("Unknown property: " + pProperty); 120 } 121 122 protected ValidationEventHandler eventHandler; 123 124 128 public ValidationEventHandler getEventHandler() { return eventHandler; } 129 130 134 public void setEventHandler(ValidationEventHandler pEventHandler) { eventHandler = pEventHandler; } 135 136 140 public void setJAXBContextImpl(JAXBContextImpl pContext) { context = pContext; } 141 145 public JAXBContextImpl getJAXBContextImpl() { return context; } 146 147 150 public void setDatatypeConverter(DatatypeConverterInterface pConverter) { datatypeConverter = pConverter; } 151 154 public DatatypeConverterInterface getDatatypeConverter() { return datatypeConverter; } 155 156 162 public void setDateTimeFormat(Format pFormat) { 163 dateTimeFormat = pFormat; 164 } 165 166 172 public Format getDateTimeFormat() { 173 if (dateTimeFormat == null) { 174 dateTimeFormat = new XsDateTimeFormat(); 175 } 176 return dateTimeFormat; 177 } 178 179 185 public void setDateFormat(Format pFormat) { 186 dateFormat = pFormat; 187 } 188 189 195 public Format getDateFormat() { 196 if (dateFormat == null) { 197 dateFormat = new XsDateFormat(); 198 } 199 return dateFormat; 200 } 201 202 208 public void setTimeFormat(Format pFormat) { 209 timeFormat = pFormat; 210 } 211 212 218 public Format getTimeFormat() { 219 if (timeFormat == null) { 220 timeFormat = new XsTimeFormat(); 221 } 222 return timeFormat; 223 } 224 } 225 | Popular Tags |