com.thoughtworks.xstream.XStream.aliasField()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中com.thoughtworks.xstream.XStream.aliasField()方法的一些代码示例,展示了XStream.aliasField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.aliasField()方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:aliasField

XStream.aliasField介绍

[英]Create an alias for a field name.
[中]为字段名创建别名。

代码示例

代码示例来源:origin: AxonFramework/AxonFramework

/**
 * 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);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * 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);
}

代码示例来源:origin: spring-projects/spring-framework

Class<?> clazz = ClassUtils.forName(className, this.beanClassLoader);
String fieldName = field.substring(idx + 1);
xstream.aliasField(alias, clazz, fieldName);

代码示例来源:origin: chanjarster/weixin-java-tools

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;
}

代码示例来源:origin: geoserver/geoserver

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);

代码示例来源:origin: apache/cloudstack

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();

代码示例来源:origin: apache/cloudstack

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();

代码示例来源:origin: apache/cloudstack

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();

代码示例来源:origin: org.axonframework/axon-core

/**
 * 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);
}

代码示例来源:origin: org.axonframework/axon-messaging

/**
 * 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);
}

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: stackoverflow.com

@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);
  }

}

代码示例来源:origin: stackoverflow.com

...
XStream xstream = new XStream(new DomDriver());

xstream.alias("myclass", MyClass.class);
xstream.aliasField("countTotal", MyClass.class, "totalCountValue");

String xml = xstream.toXML(this);
...

代码示例来源:origin: org.jvnet.hudson/xstream

/**
 * 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);
}

代码示例来源:origin: org.motechproject/commcare-case-gateway

private String convertToCloseXml(CommcareRequestData request) {
  XStream xstream = mapEnvelope();
  xstream.aliasField("close", CaseRequest.class, "closeElement");
  return xstream.toXML(request);
}

代码示例来源:origin: x-stream/xstream

/**
 * 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);
}

代码示例来源:origin: org.motechproject/commcare-case-gateway

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);
}

代码示例来源:origin: org.geoserver.community/gs-status-monitoring

@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");
}

代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio

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");
  }
}

代码示例来源:origin: me.chanjar/weixin-java-mp

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;
}

相关文章