org.simpleframework.xml.transform.RegistryMatcher Java Examples
The following examples show how to use
org.simpleframework.xml.transform.RegistryMatcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleXmlParser.java From openkeepass with Apache License 2.0 | 6 votes |
public ByteArrayOutputStream toXml(Object objectToSerialize) { try { RegistryMatcher matcher = new RegistryMatcher(); matcher.bind(Boolean.class, BooleanSimpleXmlAdapter.class); matcher.bind(GregorianCalendar.class, CalendarSimpleXmlAdapter.class); matcher.bind(UUID.class, UUIDSimpleXmlAdapter.class); matcher.bind(byte[].class, ByteSimpleXmlAdapter.class); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); TreeStrategyWithoutArrayLength strategy = new TreeStrategyWithoutArrayLength(); Serializer serializer = new Persister(strategy, matcher); serializer.write(objectToSerialize, outputStream); return outputStream; } catch (Exception e) { throw new KeePassDatabaseUnwriteableException("Could not serialize object to xml", e); } }
Example #2
Source File: SimpleXmlParser.java From openkeepass with Apache License 2.0 | 6 votes |
private Serializer createSerializer(ProtectionStrategy protectionStrategy) { RegistryMatcher matcher = new RegistryMatcher(); matcher.bind(Boolean.class, BooleanSimpleXmlAdapter.class); matcher.bind(GregorianCalendar.class, CalendarSimpleXmlAdapter.class); matcher.bind(UUID.class, UUIDSimpleXmlAdapter.class); matcher.bind(byte[].class, ByteSimpleXmlAdapter.class); Registry registry = new Registry(); PropertyValueXmlAdapter converter = new PropertyValueXmlAdapter(protectionStrategy); try { registry.bind(PropertyValue.class, converter); Strategy strategy = new RegistryStrategy(registry); return new Persister(strategy, matcher); } catch (Exception e) { throw new KeePassDatabaseUnreadableException("Could not register xml converter", e); } }
Example #3
Source File: ConfigurationLoaderImpl.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
/** * Retrieve a {@link Serializer} instance suitable for deserialising a * {@link ConfigurationReport}. * * @return a new {@link Serializer} instance */ private Serializer getSerializer() { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); RegistryMatcher matcher = new RegistryMatcher(); matcher.bind(Timestamp.class, new DateFormatConverter(format)); Strategy strategy = new AnnotationStrategy(); Serializer serializer = new Persister(strategy, matcher); return serializer; }
Example #4
Source File: ScapManager.java From uyuni with GNU General Public License v2.0 | 4 votes |
private static Persister createXmlPersister() { RegistryMatcher registryMatcher = new RegistryMatcher(); registryMatcher.bind(Date.class, DateFormatTransformer.createXmlDateTransformer()); return new Persister(registryMatcher); }