/** * Adds an alias to use for a given field in the given class. * * @param alias The alias to use instead of the original field name * @param definedIn The class that defines the field. * @param fieldName The name of the field to use the alias for * @see XStream#aliasField(String, Class, String) */ public void addFieldAlias(String alias, Class definedIn, String fieldName) { xStream.aliasField(alias, definedIn, fieldName); }
/** * 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); }
Class<?> clazz = ClassUtils.forName(className, this.beanClassLoader); String fieldName = field.substring(idx + 1); xstream.aliasField(alias, clazz, fieldName);
private static XStream config_WxMpXmlMessage() { XStream xstream = XStreamInitializer.getInstance(); xstream.processAnnotations(WxMpXmlMessage.class); xstream.processAnnotations(WxMpXmlMessage.ScanCodeInfo.class); xstream.processAnnotations(WxMpXmlMessage.SendPicsInfo.class); xstream.processAnnotations(WxMpXmlMessage.SendPicsInfo.Item.class); xstream.processAnnotations(WxMpXmlMessage.SendLocationInfo.class); xstream.aliasField("MsgID", WxMpXmlMessage.class, "msgId"); return xstream; }
xs.alias("projected", DefaultProjectedCRS.class); xs.alias("attribution", AttributionInfo.class); xs.aliasField("abstract", ResourceInfoImpl.class, "_abstract"); xs.alias("AuthorityURL", AuthorityURLInfo.class); xs.alias("Identifier", LayerIdentifierInfo.class);
xstream.alias("account", RegionAccount.class); xstream.alias("user", RegionUser.class); xstream.aliasField("id", RegionAccount.class, "uuid"); xstream.aliasField("name", RegionAccount.class, "accountName"); xstream.aliasField("accounttype", RegionAccount.class, "type"); xstream.aliasField("domainid", RegionAccount.class, "domainUuid"); xstream.aliasField("networkdomain", RegionAccount.class, "networkDomain"); xstream.aliasField("id", RegionUser.class, "uuid"); xstream.aliasField("accountId", RegionUser.class, "accountUuid"); try(ObjectInputStream in = xstream.createObjectInputStream(is);) { return (RegionAccount) in.readObject();
xstream.aliasField("id", RegionDomain.class, "uuid"); xstream.aliasField("parentdomainid", RegionDomain.class, "parentUuid"); xstream.aliasField("networkdomain", DomainVO.class, "networkDomain"); try(ObjectInputStream in = xstream.createObjectInputStream(is);) { return (RegionDomain) in.readObject();
XStream xstream = new XStream(new DomDriver()); xstream.alias("useraccount", UserAccountVO.class); xstream.aliasField("id", UserAccountVO.class, "uuid"); try(ObjectInputStream in = xstream.createObjectInputStream(is);) { return (UserAccountVO)in.readObject();
/** * Adds an alias to use for a given field in the given class. * * @param alias The alias to use instead of the original field name * @param definedIn The class that defines the field. * @param fieldName The name of the field to use the alias for * @see XStream#aliasField(String, Class, String) */ public void addFieldAlias(String alias, Class definedIn, String fieldName) { xStream.aliasField(alias, definedIn, fieldName); }
/** * Adds an alias to use for a given field in the given class. * * @param alias The alias to use instead of the original field name * @param definedIn The class that defines the field. * @param fieldName The name of the field to use the alias for * @see XStream#aliasField(String, Class, String) */ public void addFieldAlias(String alias, Class definedIn, String fieldName) { xStream.aliasField(alias, definedIn, fieldName); }
final XStream xstream = new XStream(new StaxDriver()); xstream.alias("MyCustomNote", Note.class); xstream.aliasField("toAddress", Note.class,"to"); xstream.aliasField("fromName", Note.class,"from"); xstream.aliasField("heading", Note.class,"heading"); xstream.aliasField("output", Note.class,"body");
@Component public class FooDeserializer { private final XStream xStream; public FooDeserializer() { xStream = new XStream(); xStream.aliasField("money", PurchaseOrder.class, "cash"); } public Foo xmlToFoo(String xml) { return (Foo) xStream.fromXML(xml); } }
... XStream xstream = new XStream(new DomDriver()); xstream.alias("myclass", MyClass.class); xstream.aliasField("countTotal", MyClass.class, "totalCountValue"); String xml = xstream.toXML(this); ...
/** * 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); }
private String convertToCloseXml(CommcareRequestData request) { XStream xstream = mapEnvelope(); xstream.aliasField("close", CaseRequest.class, "closeElement"); return xstream.toXML(request); }
/** * 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); }
private String convertToXml(CommcareRequestData request) { XStream xstream = mapEnvelope(); xstream.aliasField("create", CaseRequest.class, "createElement"); xstream.aliasField("update", CaseRequest.class, "updateElement"); xstream.alias("index", Index.class); xstream.omitField(Index.class, "patientTagName"); String patientCaseType = request.getCcCase().getIndex().getPatient().getCase_type(); xstream.registerConverter(new PatientConverter(patientCaseType)); xstream.aliasField("person_id", Index.class, "patient"); return xstream.toXML(request); }
@Override public void configurePersister(XStreamPersister persister, XStreamMessageConverter converter) { XStream xs = persister.getXStream(); xs.alias("metric", MetricValue.class); xs.alias("metrics", Metrics.class); xs.omitField(MetricValue.class, "value"); xs.registerConverter(new ValueHolderConverter()); xs.aliasField("value", MetricValue.class, "holder"); xs.addImplicitCollection(Metrics.class, "metrics"); }
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"); } }
private static XStream config_WxMpXmlMessage() { XStream xstream = XStreamInitializer.getInstance(); xstream.processAnnotations(WxMpXmlMessage.class); xstream.processAnnotations(WxMpXmlMessage.ScanCodeInfo.class); xstream.processAnnotations(WxMpXmlMessage.SendPicsInfo.class); xstream.processAnnotations(WxMpXmlMessage.SendPicsInfo.Item.class); xstream.processAnnotations(WxMpXmlMessage.SendLocationInfo.class); xstream.aliasField("MsgID", WxMpXmlMessage.class, "msgId"); return xstream; }