Java Code Examples for com.thoughtworks.xstream.XStream#aliasType()
The following examples show how to use
com.thoughtworks.xstream.XStream#aliasType() .
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: EPSettingsManager.java From olat with Apache License 2.0 | 6 votes |
public void setSavedFilterSettings(final Identity ident, final List<EPFilterSettings> filterList) { final PropertyManager pm = PropertyManager.getInstance(); PropertyImpl p = pm.findProperty(ident, null, null, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS); if (p == null) { p = pm.createUserPropertyInstance(ident, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS, null, null, null, null); } // don't persist filters without a name for (final Iterator<EPFilterSettings> iterator = filterList.iterator(); iterator.hasNext();) { final EPFilterSettings epFilterSettings = iterator.next(); if (!StringHelper.containsNonWhitespace(epFilterSettings.getFilterName())) { iterator.remove(); } } final XStream xStream = XStreamHelper.createXStreamInstance(); xStream.aliasType(EP_FILTER_SETTINGS, EPFilterSettings.class); final String filterListXML = xStream.toXML(filterList); p.setTextValue(filterListXML); pm.saveProperty(p); }
Example 3
Source File: EPSettingsManager.java From olat with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public List<EPFilterSettings> getSavedFilterSettings(final Identity ident) { final PropertyManager pm = PropertyManager.getInstance(); final PropertyImpl p = pm.findProperty(ident, null, null, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS); List<EPFilterSettings> result = new ArrayList<EPFilterSettings>(); if (p == null) { result.add(new EPFilterSettings()); } else { final XStream xStream = XStreamHelper.createXStreamInstance(); xStream.aliasType(EP_FILTER_SETTINGS, EPFilterSettings.class); try { result = (List<EPFilterSettings>) xStream.fromXML(p.getTextValue()); } catch (final Exception e) { // it's not a live critical part log.warn("Cannot read filter settings", e); } } return result; }
Example 4
Source File: EPSettingsManager.java From olat with Apache License 2.0 | 6 votes |
public void setSavedFilterSettings(final Identity ident, final List<EPFilterSettings> filterList) { final PropertyManager pm = PropertyManager.getInstance(); PropertyImpl p = pm.findProperty(ident, null, null, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS); if (p == null) { p = pm.createUserPropertyInstance(ident, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS, null, null, null, null); } // don't persist filters without a name for (final Iterator<EPFilterSettings> iterator = filterList.iterator(); iterator.hasNext();) { final EPFilterSettings epFilterSettings = iterator.next(); if (!StringHelper.containsNonWhitespace(epFilterSettings.getFilterName())) { iterator.remove(); } } final XStream xStream = XStreamHelper.createXStreamInstance(); xStream.aliasType(EP_FILTER_SETTINGS, EPFilterSettings.class); final String filterListXML = xStream.toXML(filterList); p.setTextValue(filterListXML); pm.saveProperty(p); }
Example 5
Source File: EPSettingsManager.java From olat with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public List<EPFilterSettings> getSavedFilterSettings(final Identity ident) { final PropertyManager pm = PropertyManager.getInstance(); final PropertyImpl p = pm.findProperty(ident, null, null, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS); List<EPFilterSettings> result = new ArrayList<EPFilterSettings>(); if (p == null) { result.add(new EPFilterSettings()); } else { final XStream xStream = XStreamHelper.createXStreamInstance(); xStream.aliasType(EP_FILTER_SETTINGS, EPFilterSettings.class); try { result = (List<EPFilterSettings>) xStream.fromXML(p.getTextValue()); } catch (final Exception e) { // it's not a live critical part log.warn("Cannot read filter settings", e); } } return result; }
Example 6
Source File: FileDocumentReferenceConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.aliasType(FILE_DOC_REF_TAG, FileDocumentReference.class); xstream.registerConverter(new FileDocumentReferenceConverter()); }
Example 7
Source File: ImmutableListConverterTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override protected void registerConverters(XStream xstream) { super.registerConverters(xstream); xstream.aliasType("ImmutableList", ImmutableList.class); xstream.registerConverter(new ImmutableListConverter(xstream.getMapper())); }
Example 8
Source File: XmlSerializer.java From brooklyn-server with Apache License 2.0 | 4 votes |
public XmlSerializer(ClassLoader loader, Map<String, String> deserializingClassRenames) { this.deserializingClassRenames = deserializingClassRenames; xstream = new XStream() { @Override protected MapperWrapper wrapMapper(MapperWrapper next) { return XmlSerializer.this.wrapMapperForNormalUsage( super.wrapMapper(next) ); } }; XStream.setupDefaultSecurity(xstream); xstream.allowTypesByWildcard(new String[] { "**" }); if (loader!=null) { xstream.setClassLoader(loader); } xstream.registerConverter(newCustomJavaClassConverter(), XStream.PRIORITY_NORMAL); // list as array list is default xstream.alias("map", Map.class, LinkedHashMap.class); xstream.alias("set", Set.class, LinkedHashSet.class); xstream.registerConverter(new StringKeyMapConverter(xstream.getMapper()), /* priority */ 10); xstream.alias("MutableMap", MutableMap.class); xstream.alias("MutableSet", MutableSet.class); xstream.alias("MutableList", MutableList.class); // Needs an explicit MutableSet converter! // Without it, the alias for "set" seems to interfere with the MutableSet.map field, so it gets // a null field on deserialization. xstream.registerConverter(new MutableSetConverter(xstream.getMapper())); xstream.aliasType("ImmutableList", ImmutableList.class); xstream.registerConverter(new ImmutableListConverter(xstream.getMapper())); xstream.registerConverter(new ImmutableSetConverter(xstream.getMapper())); xstream.registerConverter(new ImmutableMapConverter(xstream.getMapper())); xstream.registerConverter(new EnumCaseForgivingConverter()); xstream.registerConverter(new Inet4AddressConverter()); // See ObjectWithDefaultStringImplConverter (and its usage) for why we want to auto-detect // annotations (usages of this is in the camp project, so we can't just list it statically // here unfortunately). xstream.autodetectAnnotations(true); }
Example 9
Source File: AbstractTypeConverter.java From depan with Apache License 2.0 | 4 votes |
/** * Register this {@link Converter} for its type with * the indicated alias. */ public void registerWithTag(XStream xstream, String typeTag) { xstream.aliasType(typeTag, getType()); xstream.registerConverter(this); }
Example 10
Source File: CameraPosConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.aliasType(CAMERA_POS_TAG, CameraPosPreference.class); xstream.registerConverter(new CameraPosConverter()); }
Example 11
Source File: ResourceDocumentReferenceConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.aliasType(RSRC_DOC_REF_TAG, ResourceDocumentReference.class); xstream.registerConverter(new ResourceDocumentReferenceConverter()); }
Example 12
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 13
Source File: EdgeReferenceConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream( XStream xstream, ReferencedGraphDocumentConverter refConverter) { xstream.aliasType(EDGE_REF_TAG, GraphEdge.class); xstream.registerConverter( new EdgeReferenceConverter(xstream.getMapper(), refConverter)); }
Example 14
Source File: GraphModelReferenceConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.aliasType(GRAPH_REF_TAG, GraphModelReference.class); xstream.registerConverter(new GraphModelReferenceConverter()); }
Example 15
Source File: RelationSetConverters.java From depan with Apache License 2.0 | 4 votes |
protected static void configXStream( XStream xstream, String typeTag, AbstractTypeConverter converter) { xstream.aliasType(typeTag, converter.getType()); xstream.registerConverter(converter); }
Example 16
Source File: CameraDirConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.aliasType(CAMERA_DIR_TAG, CameraDirPreference.class); xstream.registerConverter(new CameraDirConverter()); }
Example 17
Source File: Point2DConverter.java From depan with Apache License 2.0 | 4 votes |
public static void configXStream(XStream xstream) { xstream.aliasType(POS_TAG, Point2D.class); xstream.registerConverter(new Point2DConverter()); }