Java Code Examples for com.thoughtworks.xstream.XStream#registerConverter()
The following examples show how to use
com.thoughtworks.xstream.XStream#registerConverter() .
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: BeanDefinitionWriterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
private XStream createStream() { XStream stream = new XStream(); stream.registerConverter(new BeanDefinitionConverter(stream.getMapper())); stream.registerConverter(new BeanDefinitionHolderConverter(stream.getMapper())); stream.registerConverter(new TypedStringValueConverter()); stream.registerConverter(new ManagedCollectionConverter(stream.getMapper())); stream.registerConverter(new ManagedMapConverter(stream.getMapper())); stream.registerConverter(new RuntimeBeanReferenceConverter()); stream.alias("map", ManagedMap.class); stream.alias("list", ManagedList.class); stream.alias("set", ManagedSet.class); stream.alias("array", ManagedArray.class); stream.aliasType("bean", BeanDefinition.class); stream.alias("bean", BeanDefinitionHolder.class); stream.alias("ref", RuntimeBeanReference.class); return stream; }
Example 2
Source File: AnalysisFraction.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @param xstream */ public void customizeXstream(XStream xstream) { xstream.registerConverter(new AnalysisFractionXMLConverter()); xstream.registerConverter(new MineralStandardModelXMLConverter()); xstream.registerConverter(new InitialPbModelETXMLConverter()); xstream.registerConverter(new ValueModelXMLConverter()); xstream.registerConverter(new MeasuredRatioModelXMLConverter()); // alias necessary to elide fully qualified name in xml8 xstream.alias("AnalysisFraction", AnalysisFraction.class); xstream.alias("MeasuredRatioModel", MeasuredRatioModel.class); xstream.alias("InitialPbModelET", InitialPbModelET.class); xstream.alias("ValueModel", ValueModel.class); setClassXMLSchemaURL(); }
Example 3
Source File: InitialPbModel.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * * @param xstream */ public void customizeXstream ( XStream xstream ) { xstream.registerConverter( new InitialPbModelXMLConverter() ); xstream.registerConverter( new ValueModelXMLConverter() ); xstream.alias( "InitialPbModel", InitialPbModel.class ); xstream.alias( "ValueModel", ValueModel.class ); setClassXMLSchemaURL(); }
Example 4
Source File: ConfigDescriptionReader.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void registerConverters(XStream xstream) { xstream.registerConverter(new NodeValueConverter()); xstream.registerConverter(new NodeListConverter()); xstream.registerConverter(new NodeAttributesConverter()); xstream.registerConverter(new ConfigDescriptionConverter()); xstream.registerConverter(new ConfigDescriptionParameterConverter()); xstream.registerConverter(new ConfigDescriptionParameterGroupConverter()); xstream.registerConverter(new FilterCriteriaConverter()); }
Example 5
Source File: TracerUPbModel.java From ET_Redux with Apache License 2.0 | 5 votes |
@Override protected void customizeXstream(XStream xstream) { xstream.registerConverter(new ValueModelXMLConverter()); xstream.registerConverter(new TracerUPbModelXMLConverter()); xstream.alias("TracerUPbModel", TracerUPbModel.class); xstream.alias("ValueModel", ValueModel.class); setClassXMLSchemaURL("URI_TracerUPbModelXMLSchema"); }
Example 6
Source File: ConfigDescriptionReader.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Override public void registerConverters(XStream xstream) { xstream.registerConverter(new NodeValueConverter()); xstream.registerConverter(new NodeListConverter()); xstream.registerConverter(new NodeAttributesConverter()); xstream.registerConverter(new ConfigDescriptionConverter()); xstream.registerConverter(new ConfigDescriptionParameterConverter()); xstream.registerConverter(new ConfigDescriptionParameterGroupConverter()); xstream.registerConverter(new FilterCriteriaConverter()); }
Example 7
Source File: DataFieldConverterTest.java From Digital with GNU General Public License v3.0 | 5 votes |
private XStream getxStream() { XStream xStream = new XStream(); xStream.registerConverter(new DataFieldConverter()); xStream.alias("dataField", DataField.class); xStream.alias("test", Test.class); return xStream; }
Example 8
Source File: JsonSerializer.java From Chronicle-Map with Apache License 2.0 | 5 votes |
private static <K, V> XStream xStream(Map<K, V> map, List jsonConverters) { try { final XStream xstream = new XStream(new JettisonMappedXmlDriver()); xstream.setMode(XStream.NO_REFERENCES); xstream.alias("cmap", map.getClass()); registerChronicleMapConverter(map, xstream); xstream.registerConverter(new ByteBufferConverter()); xstream.registerConverter(new ValueConverter()); xstream.registerConverter(new StringBuilderConverter()); xstream.registerConverter(new CharSequenceConverter()); for (Object c : jsonConverters) { if (c instanceof Converter) { xstream.registerConverter((Converter) c); } else { LOG.warn("Skipping Converter of type class=" + c.getClass().getName() + " as " + " expecting an object of type com.thoughtworks.xstream.converters" + ".Converter"); } } return xstream; } catch (NoClassDefFoundError e) { throw new RuntimeException(logErrorSuggestXStreem, e); } }
Example 9
Source File: PbBlank.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * registers converter for argument <code>xstream</code> and sets aliases to * make the XML file more human-readable * * @pre argument <code>xstream</code> is a valid <code>XStream</code> @post * argument <code>xstream</code> is customized to produce a cleaner output * <code>file</code> * * @param xstream <code>XStream</code> to be customized */ public void customizeXstream(XStream xstream) { xstream.registerConverter(new PbBlankXMLConverter()); xstream.registerConverter(new ValueModelXMLConverter()); xstream.alias("PbBlank", PbBlank.class); xstream.alias("ValueModel", ValueModel.class); setClassXMLSchemaURL(); }
Example 10
Source File: XmlObjectSerializerIgnoreMissingFieldsServiceImpl.java From rice with Educational Community License v2.0 | 5 votes |
public XmlObjectSerializerIgnoreMissingFieldsServiceImpl() { xstream = new XStream(new ProxyAwareJavaReflectionProvider()) { @Override protected MapperWrapper wrapMapper(MapperWrapper next) { return new MapperWrapper(next) { @Override public boolean shouldSerializeMember(Class definedIn, String fieldName) { if (definedIn == Object.class) { return false; } return super.shouldSerializeMember(definedIn, fieldName); } }; } }; xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider() )); try { Class<?> objListProxyClass = Class.forName("org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl"); xstream.addDefaultImplementation(ArrayList.class, objListProxyClass); } catch ( Exception ex ) { // Do nothing - this will blow if the OJB class does not exist, which it won't in some installs } xstream.registerConverter(new DateTimeConverter()); }
Example 11
Source File: SerializationService.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private XStream getXStream(Schema schema) { XStream xstream = new XStream(new DomDriver()); xstream.registerConverter(new DatabaseMetaConverter()); xstream.registerConverter(new AggListConverter(aggList)); xstream.registerConverter(new AttributeConverter(schema)); xstream.registerConverter(new MeasureConverter(schema)); return xstream; }
Example 12
Source File: ReplaceableConverterTest.java From saros with GNU General Public License v2.0 | 5 votes |
@Test public void reset() { /* Mocks */ Converter c1 = EasyMock.createMock(Converter.class); expect(c1.canConvert(Dummy.class)).andStubReturn(true); c1.marshal( isA(Object.class), isA(HierarchicalStreamWriter.class), isA(MarshallingContext.class)); EasyMock.expectLastCall().once(); EasyMock.replay(c1); /* XStream config */ XStream xstream = XStreamFactory.getSecureXStream(new DomDriver()); ReplaceableConverter resetable = new ReplaceableConverter(c1); xstream.registerConverter(resetable); /* Test it */ assertFalse("ReplaceableConverter was not properly set up", resetable.isReset()); assertNotNull("Converter cannot convert", xstream.toXML(new Dummy())); resetable.reset(); assertTrue("ReplaceableConverter was not properly reset", resetable.isReset()); /* * This call should not reach the converter. */ xstream.toXML(new Dummy()); /* * Verify that the converter was used exactly once, i.e. it was not * called while it was inactive. */ EasyMock.verify(c1); }
Example 13
Source File: PhysicalPlanWriter.java From PoseidonX with Apache License 2.0 | 5 votes |
/** * 将执行计划序列化成字符串 */ public static String createStringPlan(PhysicalPlan plan) { XStream xstream = new XStream(new DomDriver(XML_CHARSET)); xstream.autodetectAnnotations(true); PhysicalPlanLoader.setAlias(xstream); xstream.registerConverter(new MapConverter(new DefaultMapper(new ClassLoaderReference(PhysicalPlanWriter.class.getClassLoader())))); return xstream.toXML(plan); }
Example 14
Source File: ReplaceableSingleValueConverterTest.java From saros with GNU General Public License v2.0 | 5 votes |
@Test public void replace() { /* Mocks */ Converter c1 = EasyMock.createMock(Converter.class); expect(c1.canConvert(Dummy.class)).andStubReturn(true); Converter c2 = EasyMock.createMock(Converter.class); expect(c2.canConvert(Dummy.class)).andStubReturn(true); c2.marshal( isA(Object.class), isA(HierarchicalStreamWriter.class), isA(MarshallingContext.class)); EasyMock.expectLastCall().once(); EasyMock.replay(c1, c2); /* XStream config */ XStream xstream = XStreamFactory.getSecureXStream(new DomDriver()); ReplaceableConverter resetable = new ReplaceableConverter(c1); xstream.registerConverter(resetable); /* Test it */ resetable.reset(); assertTrue("ReplaceableConverter was not properly reset", resetable.isReset()); /* * This call should not reach any of the converters. */ xstream.toXML(new Dummy()); resetable.replace(c2); assertNotNull("Converter was not reactivated", xstream.toXML(new Dummy())); /* * Verify that the first converter is not called, and the second exactly * once */ EasyMock.verify(c1, c2); }
Example 15
Source File: NodeReferenceConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream( XStream xstream, ReferencedGraphDocumentConverter refConverter) { xstream.aliasType(NODE_REF_TAG, GraphNode.class); xstream.registerConverter(new NodeReferenceConverter(refConverter)); }
Example 16
Source File: InetAddressConverterTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override protected void registerConverters(XStream xstream) { super.registerConverters(xstream); xstream.registerConverter(new Inet4AddressConverter()); }
Example 17
Source File: ViewExtensionConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.registerConverter(new ViewExtensionConverter()); }
Example 18
Source File: VersionedExternalizable.java From sakai with Educational Community License v2.0 | 4 votes |
protected static XStream getXStream() { final XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library xstream.registerConverter(new Converter(xstream.getMapper(), xstream.getReflectionProvider())); return xstream; }
Example 19
Source File: ValueModelReferenced.java From ET_Redux with Apache License 2.0 | 1 votes |
/** * registers converter for argument <code>xstream</code> and sets aliases to * make the XML file more human-readable * * @pre argument <code>xstream</code> is a valid <code>XStream</code> @post * argument <code>xstream</code> is customized to produce a cleaner output * <code>file</code> * * @param xstream <code>XStream</code> to be customized */ @Override public void customizeXstream(XStream xstream) { xstream.registerConverter(new ValueModelReferencedXMLConverter()); xstream.alias("ValueModelReferenced", ValueModelReferenced.class); setClassXMLSchemaURL(); }
Example 20
Source File: ValueModel.java From ET_Redux with Apache License 2.0 | 1 votes |
/** * registers converter for argument <code>xstream</code> and sets aliases to * make the XML file more human-readable * * @pre argument <code>xstream</code> is a valid <code>XStream</code> @post * argument <code>xstream</code> is customized to produce a cleaner output * <code>file</code> * * @param xstream <code>XStream</code> to be customized */ public void customizeXstream(XStream xstream) { xstream.registerConverter(new ValueModelXMLConverter()); xstream.alias("ValueModel", ValueModel.class); setClassXMLSchemaURL(); }