@Test public void testWrite() { final XmlObjectWriter writer = new XmlObjectWriter(); TestObject obj = new TestObject(); PFDateTime dt = PFDateTime.now(ZoneId.of("UTC")).withDate(2010, Month.AUGUST, 29, 23, 8, 17, 123); obj.date = dt.getUtilDate(); assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"1283116097123\"/>", writer.writeToXml(obj)); final XmlRegistry reg = new XmlRegistry(); reg.registerConverter(Date.class, new ISODateConverter()); writer.setXmlRegistry(reg); obj.date = dt.getUtilDate(); assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08:17.123\"/>", writer.writeToXml(obj)); dt = dt.withMilliSecond(0); obj.date = dt.getUtilDate(); assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08:17\"/>", writer.writeToXml(obj)); dt = dt.withSecond(0); obj.date = dt.getUtilDate(); assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08\"/>", writer.writeToXml(obj)); dt = dt.withMinute(0); obj.date = dt.getUtilDate(); assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:00\"/>", writer.writeToXml(obj)); dt = dt.withHour(0); obj.date = dt.getUtilDate(); assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29\"/>", writer.writeToXml(obj)); }
public XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter) { if (this == baseRegistry) { throw new IllegalStateException("Couldn't register type as attribute for base registry (singleton). This registry is unmodifiable"); } internalRegisterConverter(type, converter); return this; }
XmlRegistry { public XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter) { if (this == baseRegistry) { throw new IllegalStateException("Couldn't register type as attribute for base registry (singleton). This registry is unmodifiable"); } internalRegisterConverter(type, converter); return this; } }
XmlRegistry { public XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter) { if (this == baseRegistry) { throw new IllegalStateException("Couldn't register type as attribute for base registry (singleton). This registry is unmodifiable"); } internalRegisterConverter(type, converter); return this; } XmlRegistry(); }
XmlRegistry { public XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter) { if (this == baseRegistry) { throw new IllegalStateException("Couldn't register type as attribute for base registry (singleton). This registry is unmodifiable"); } internalRegisterConverter(type, converter); return this; } XmlRegistry(); static XmlRegistry baseRegistry(); IConverter< ? > getConverter(final Class< ? > clazz); boolean asAttributeAsDefault(final Class< ? > type); String getAliasForClass(final Class< ? > type); Class< ? > getClassForAlias(final String alias); XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter); XmlRegistry registerAlias(final Class< ? > type, final String alias); XmlRegistry registerTypeAsAttribute(final Class< ? > type); }
XmlRegistry { public XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter) { if (this == baseRegistry) { throw new IllegalStateException("Couldn't register type as attribute for base registry (singleton). This registry is unmodifiable"); } internalRegisterConverter(type, converter); return this; } XmlRegistry(); static XmlRegistry baseRegistry(); IConverter< ? > getConverter(final Class< ? > clazz); boolean asAttributeAsDefault(final Class< ? > type); String getAliasForClass(final Class< ? > type); Class< ? > getClassForAlias(final String alias); XmlRegistry registerConverter(final Class< ? > type, final IConverter< ? > converter); XmlRegistry registerAlias(final Class< ? > type, final String alias); XmlRegistry registerTypeAsAttribute(final Class< ? > type);  }