/** * Create an alias for an attribute. * * @param definedIn the type where the attribute is defined * @param attributeName the name of the attribute * @param alias the alias itself * @throws InitializationException if no {@link AttributeAliasingMapper} is available * @since 1.2.2 */ public void aliasAttribute(Class definedIn, String attributeName, String alias) { aliasField(alias, definedIn, attributeName); useAttributeFor(definedIn, attributeName); }
xstream.useAttributeFor(type); if (entry.getKey() instanceof String) { if (entry.getValue() instanceof Class) { xstream.useAttributeFor((String) entry.getKey(), (Class<?>) entry.getValue()); Class<?> key = (Class<?>) entry.getKey(); if (entry.getValue() instanceof String) { xstream.useAttributeFor(key, (String) entry.getValue()); for (Object element : listValue) { if (element instanceof String) { xstream.useAttributeFor(key, (String) element);
/** * Constructor that takes a custom XStream object * @param customXstream * @throws SerializationException */ public SimpleXStreamSerializer(XStream customXstream) throws SerializationException { if (customXstream == null) { xstream = new XStream(); } else { this.xstream = customXstream; } xstream.registerConverter(new OpenmrsDynamicProxyConverter(), XStream.PRIORITY_VERY_HIGH); //this is added to read the prior simpleframework-serialized values. // TODO find a better way to do this. this.xstream.useAttributeFor(ImplementationId.class, "implementationId"); }
public static XStream configurePageLayoutXStream(XStream xStream) { xStream.useAttributeFor(Section.class, "actionName"); xStream.useAttributeFor(Section.class, "tagList"); xStream.useAttributeFor(Section.class, "numberOfEventsTriggered"); xStream.omitField(Section.class, "loadedTagList"); return xStream; }
/** * Configure x-stream for XML encoding of link * * @param xStream */ public static void configureXML(XStream xStream) { xStream.alias("atom:link", AtomLink.class); xStream.useAttributeFor(AtomLink.class, "href"); xStream.useAttributeFor(AtomLink.class, "rel"); xStream.useAttributeFor(AtomLink.class, "type"); xStream.aliasAttribute(AtomLink.class, "NAMESPACE", "xmlns:atom"); }
@SuppressWarnings("rawtypes") private void defineAttributes(Map<String, Class> attributesMap) { if(attributesMap!=null){ Set<String> attributesSet = attributesMap.keySet(); for (String attribute : attributesSet) { xstream.useAttributeFor(attribute, attributesMap.get(attribute)); } } }
private Collection<ProcessRoleConfig> getRoles(InputStream input) { if (input == null) { return null; } XStream xstream = new XStream(); xstream.aliasPackage("config", ProcessRoleConfig.class.getPackage().getName()); xstream.useAttributeFor(String.class); xstream.useAttributeFor(Boolean.class); xstream.useAttributeFor(Integer.class); return (Collection<ProcessRoleConfig>) xstream.fromXML(input); }
XStream xstream = new XStream(); xstream.registerConverter(new FlightsConverter()); xstream.alias("airport", AirportPojo.class); xstream.alias("flights", FlightsPojo.class); xstream.alias("flight", FlightPojo.class); xstream.useAttributeFor(AirportPojo.class, "flights"); AirportPojo airportPojo = (AirportPojo) xstream.fromXML(xml);
CarImpl myModel = new CarImpl(); File xmlFile = new File("model.xml"); XStream xstream = new XStream(); xstream.useAttributeFor(String.class); xstream.useAttributeFor(Integer.class); Writer writer = new FileWriter(xmlFile); writer.write(xstream.toXML(myModel)); writer.close(); CarImpl fromXML = (CarImpl) xstream.fromXML(new FileInputStream(xmlFile)); System.out.println(fromXML);
/** * Sets types to use XML attributes for. * * @see XStream#useAttributeFor(Class) */ public void setUseAttributeForTypes(Class[] types) { for (int i = 0; i < types.length; i++) { getXStream().useAttributeFor(types[i]); } }
static public void applyEnumAliases(XStream xStream) { // ScoreConfiguration xStream.alias("EnumDefinition", EnumDefinition.class); xStream.useAttributeFor(EnumDefinition.class, "name"); // ensure contained elements are added to scorersList xStream.addImplicitCollection(EnumDefinition.class, "strValues"); }
/** * Create an alias for an attribute. * * @param definedIn the type where the attribute is defined * @param attributeName the name of the attribute * @param alias the alias itself * @throws InitializationException if no {@link AttributeAliasingMapper} is available * @since 1.2.2 */ public void aliasAttribute(final Class<?> definedIn, final String attributeName, final String alias) { aliasField(alias, definedIn, attributeName); useAttributeFor(definedIn, attributeName); }
protected XStream configureXStream() { XStream stream = new XStream(); stream.addImplicitCollection(Page.class, "link"); stream.alias("results", Results.class); stream.alias("result", Page.class); stream.alias("content", Page.class); stream.alias("link", Link.class); stream.useAttributeFor(Link.class, "rel"); stream.useAttributeFor(Link.class, "href"); stream.ignoreUnknownElements(); return stream; }
XStream xs = new XStream(new DomDriver()); xs.alias("root", ParentElement.class); xs.useAttributeFor(ChildElement.class, "aaa"); // read as attribute xs.useAttributeFor(ChildElement.class, "bbb"); ParentElement parent = new ParentElement(); try { FileInputStream fis = new FileInputStream("readfile"); xs.fromXML(fis, parent); } catch (FileNotFoundException ex) { ex.printStackTrace(); }
private static XStream getConfiguredXStream(XStream xs) { // XStream xs = xstream; xs.setMode(XStream.NO_REFERENCES); xs.alias("gwcConfiguration", GeoWebCacheConfiguration.class); xs.useAttributeFor(GeoWebCacheConfiguration.class, "xmlns_xsi"); xs.aliasField("xmlns:xsi", GeoWebCacheConfiguration.class, "xmlns_xsi"); xs.useAttributeFor(GeoWebCacheConfiguration.class, "xsi_noNamespaceSchemaLocation"); xs.aliasField("xsi:noNamespaceSchemaLocation", GeoWebCacheConfiguration.class, "xsi_noNamespaceSchemaLocation"); xs.useAttributeFor(GeoWebCacheConfiguration.class, "xmlns"); xs.alias("wmsRasterFilterUpdate", WMSRasterFilterUpdate.class); return xs; }
/** * Create an alias for an attribute. * * @param definedIn the type where the attribute is defined * @param attributeName the name of the attribute * @param alias the alias itself * @throws InitializationException if no {@link AttributeAliasingMapper} is available * @since 1.2.2 */ public void aliasAttribute(Class definedIn, String attributeName, String alias) { aliasField(alias, definedIn, attributeName); useAttributeFor(definedIn, attributeName); }
/** * Create an alias for an attribute. * * @param definedIn the type where the attribute is defined * @param attributeName the name of the attribute * @param alias the alias itself * @throws InitializationException if no {@link AttributeAliasingMapper} is available * @since 1.2.2 */ public void aliasAttribute(Class definedIn, String attributeName, String alias) { aliasField(alias, definedIn, attributeName); useAttributeFor(definedIn, attributeName); }
/** * Create an alias for an attribute. * * @param definedIn the type where the attribute is defined * @param attributeName the name of the attribute * @param alias the alias itself * @throws InitializationException if no {@link AttributeAliasingMapper} is available * @since 1.2.2 */ public void aliasAttribute(Class definedIn, String attributeName, String alias) { aliasField(alias, definedIn, attributeName); useAttributeFor(definedIn, attributeName); }
public static XStream getXstream() { XStream xstream = new XStream(); xstream.alias("stream-element", StreamElement4Rest.class); xstream.alias("field", Field4Rest.class); xstream.useAttributeFor(StreamElement4Rest.class,"timestamp"); xstream.addImplicitCollection(StreamElement4Rest.class, "fields"); xstream.registerConverter(new Field4RestConverter()); xstream.alias("strcture", DataField.class); return xstream; }
public XmlRulesDescriptorSerializer_v5_16() { super(new RulesDeployVersionConverter()); xstream.ignoreUnknownElements(); xstream.omitField(RulesDeploy_v5_16.class, "log"); xstream.setMode(XStream.NO_REFERENCES); xstream.aliasType("publisher", RulesDeploy_v5_16.PublisherType.class); xstream.aliasType(RULES_DEPLOY_DESCRIPTOR_TAG, RulesDeploy_v5_16.class); xstream.aliasType(MODULE_NAME, RulesDeploy_v5_16.WildcardPattern.class); xstream.aliasField(LAZY_MODULES_FOR_COMPILATION, RulesDeploy_v5_16.class, "lazyModulesForCompilationPatterns"); xstream.aliasField("name", RulesDeploy_v5_16.WildcardPattern.class, "value"); xstream.useAttributeFor(RulesDeploy_v5_16.WildcardPattern.class, "value"); } }