Java Code Examples for com.thoughtworks.xstream.XStream#aliasField()

The following examples show how to use com.thoughtworks.xstream.XStream#aliasField() . 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: XStreamTransformer.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
/**
 * 会自动注册该类及其子类.
 *
 * @param clz 要注册的类
 */
private static void registerClass(Class<?> clz) {
  XStream xstream = XStreamInitializer.getInstance();

  xstream.processAnnotations(clz);
  xstream.processAnnotations(getInnerClasses(clz));
  if (clz.equals(WxMpXmlMessage.class)) {
    // 操蛋的微信,模板消息推送成功的消息是MsgID,其他消息推送过来是MsgId
    xstream.aliasField("MsgID", WxMpXmlMessage.class, "msgId");
  }

  register(clz, xstream);
}
 
Example 2
Source File: XStreamTransformer.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
/**
 * 会自动注册该类及其子类.
 *
 * @param clz 要注册的类
 */
private static void registerClass(Class<?> clz) {
  XStream xstream = XStreamInitializer.getInstance();

  xstream.processAnnotations(clz);
  xstream.processAnnotations(getInnerClasses(clz));
  if (clz.equals(WxMaMessage.class)) {
    // 操蛋的微信,模板消息推送成功的消息是MsgID,其他消息推送过来是MsgId
    xstream.aliasField("MsgID", WxMaMessage.class, "msgId");
  }

  register(clz, xstream);
}
 
Example 3
Source File: XStreamTransformer.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
/**
 * 会自动注册该类及其子类.
 *
 * @param clz 要注册的类
 */
private static void registerClass(Class<?> clz) {
  XStream xstream = XStreamInitializer.getInstance();

  xstream.processAnnotations(clz);
  xstream.processAnnotations(getInnerClasses(clz));
  if (clz.equals(WxOpenXmlMessage.class)) {
    // 操蛋的微信,模板消息推送成功的消息是MsgID,其他消息推送过来是MsgId
    xstream.aliasField("MsgID", WxOpenXmlMessage.class, "msgId");
  }

  register(clz, xstream);
}
 
Example 4
Source File: InitializerSerializer.java    From openmrs-module-initializer with MIT License 5 votes vote down vote up
/**
 * @return Deserializer for {@link GlobalPropertiesConfig}
 */
public static XStream getGlobalPropertiesConfigSerializer() {
	final XStream xs = new InitializerSerializer();
	xs.alias("config", GlobalPropertiesConfig.class);
	xs.alias("globalProperty", GlobalProperty.class);
	xs.aliasField("value", GlobalProperty.class, "propertyValue");
	return xs;
}
 
Example 5
Source File: XStreamTransformer.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: XmlApiRequest.java    From engage-api-client with Apache License 2.0 5 votes vote down vote up
private XStream initializeXStream() {
	XStream xStream = xStreamFactory.createXStream();
	
	xStream.processAnnotations(XmlApiRequestEnvelope.class);
	
	XmlApiProperties apiProperties = annotationUtility.getApiProperties(apiCommand);
			
	xStream.aliasField(apiProperties.value(), XmlApiRequestBody.class, "apiCommand");
	xStream.processAnnotations(apiCommand.getClass());
	xStream.aliasSystemAttribute(null, "class");
	return xStream;
}
 
Example 7
Source File: DefaultSchemaManager.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
protected static XStream createXStream() {
    XStream xstream = new XStream(new DomDriver("UTF-8"));
    xstream.alias("schema", PersistedSchema.class);
    xstream.alias("schemas", PersistedSchemas.class);
    xstream.addImplicitCollection(PersistedSchemas.class, "list");
    xstream.aliasField("names", PersistedSchema.class, "schemas");
    xstream.useAttributeFor(PersistedSchemas.class, "version");   
    return xstream;
}
 
Example 8
Source File: DexterParamsXMLParser.java    From dexter with Apache License 2.0 4 votes vote down vote up
public static DexterParamsXMLParser load(String xmlConfig) {
	logger.info("loading configuration from {} ", xmlConfig);
	XStream xstream = new XStream(new StaxDriver());
	xstream.alias("config", DexterParamsXMLParser.class);
	xstream.alias("model", Model.class);
	xstream.alias("labels", Labels.class);
	xstream.alias("index", Index.class);

	xstream.alias("thresholds", Thresholds.class);

	xstream.addImplicitCollection(Thresholds.class, "thresholds");
	xstream.alias("threshold", Threshold.class);
	xstream.alias("spotFilter", SpotFilter.class);
	xstream.alias("spotFilters", SpotFilters.class);

	xstream.addImplicitCollection(SpotFilters.class, "spotFilters");
	xstream.aliasField("class", SpotFilter.class, "clazz");

	xstream.alias("graph", Graph.class);
	xstream.alias("graphs", Graphs.class);
	xstream.addImplicitCollection(Graphs.class, "graphs");

	xstream.alias("rankers", Rankers.class);
	xstream.addImplicitCollection(Models.class, "models");
	xstream.aliasField("default", Models.class, "defaultModel");

	xstream.aliasField("default", Disambiguators.class,
			"defaultDisambiguator");

	xstream.aliasField("default", Spotters.class, "defaultSpotter");

	xstream.aliasField("default", Taggers.class, "defaultTagger");

	xstream.addImplicitCollection(Rankers.class, "rankers");
	xstream.alias("ranker", Ranker.class);
	xstream.aliasField("class", Ranker.class, "clazz");

	xstream.alias("params", Params.class);
	xstream.alias("param", Param.class);

	xstream.addImplicitCollection(Params.class, "params");

	xstream.alias("libs", Libs.class);

	xstream.addImplicitCollection(RelatednessFunctions.class,
			"relatednessFunctions");
	xstream.aliasField("default", RelatednessFunctions.class,
			"defaultFunction");

	xstream.alias("relatednessFunctions", RelatednessFunctions.class);
	xstream.alias("relatednessFunction", RelatednessFunction.class);

	xstream.addImplicitCollection(Caches.class, "caches");
	xstream.alias("caches", Caches.class);
	xstream.alias("cache", Cache.class);

	xstream.alias("disambiguators", Disambiguators.class);
	xstream.addImplicitCollection(Disambiguators.class, "disambiguators");
	xstream.alias("disambiguator", Disambiguator.class);

	xstream.alias("spotters", Spotters.class);
	xstream.addImplicitCollection(Spotters.class, "spotters");
	xstream.alias("spotter", Spotter.class);

	xstream.alias("filter", Filter.class);
	xstream.addImplicitCollection(Filter.class, "filters");

	xstream.aliasField("class", RelatednessFunction.class, "clazz");
	xstream.aliasField("class", Disambiguator.class, "clazz");
	xstream.aliasField("class", Spotter.class, "clazz");

	xstream.alias("taggers", Taggers.class);
	xstream.addImplicitCollection(Taggers.class, "taggers");
	xstream.alias("tagger", Tagger.class);

	xstream.alias("spotRepository", SpotRepository.class);

	String xml = IOUtils.getFileAsString(xmlConfig);
	DexterParamsXMLParser config = (DexterParamsXMLParser) xstream
			.fromXML(xml);
	return config;
}