当前位置: 首页>>代码示例>>Java>>正文


Java XStream.fromXML方法代码示例

本文整理汇总了Java中com.thoughtworks.xstream.XStream.fromXML方法的典型用法代码示例。如果您正苦于以下问题:Java XStream.fromXML方法的具体用法?Java XStream.fromXML怎么用?Java XStream.fromXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thoughtworks.xstream.XStream的用法示例。


在下文中一共展示了XStream.fromXML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: closeOrder

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
 * 微信订单关闭,商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口.<br>
 * <span style="color:red;">订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。</span>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_3">普通商户关闭订单接口</a> <br>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/native_sl.php?chapter=9_3">服务商关闭订单接口</a>
 * @param data   参数对象 {@link CloseOrderInput}
 * @param apiKey 微信API秘钥
 * @return 订单关闭结果对象 {@link CloseOrderOutput}
 */
public static CloseOrderOutput closeOrder(CloseOrderInput data, String apiKey){

    CloseOrderOutput output = null;

    try {
        Object input = WechatUtil.buildRequest(data,CloseOrderInput.class,apiKey);
        XStream xStream = XStreamCreator.create(CloseOrderInput.class);
        String xml = xStream.toXML(input);
        log.info("微信关闭订单请求数据[closeOrder]->xmlRequest:\n {}",xml);

        String xmlResponse = ConnUtil.connRemoteWithXml(xml,close_order);

        log.info("微信关闭订单响应数据[closeOrder]->xmlResponse:\n {}",ThlwsBeanUtil.formatXml(xmlResponse));
        XStream xStreamOut = XStreamCreator.create(CloseOrderOutput.class);
        output = (CloseOrderOutput) xStreamOut.fromXML(xmlResponse);

    } catch (Exception e) {
        log.error("微信关闭订单[closeOrder]失败:{}",e.getMessage());
    }
    return output;
}
 
开发者ID:thlws,项目名称:payment-wechat,代码行数:31,代码来源:WechatCore.java

示例2: orderQuery

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
 * 微信订单查询,除核心参数外(appid,mch_id等为核心参数)业务参数 transaction_id ,out_trade_no 二选一即可<br>
 *
 * 需要调用查询接口的情况<br>
 *
 *  <ol>
 *      <li>当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;</li>
 *      <li>调用支付接口后,返回系统错误或未知交易状态情况;</li>
 *      <li>调用刷卡支付API,返回USERPAYING的状态;</li>
 *      <li>调用关单或撤销接口API之前,需确认支付状态;</li>
 *  </ol>
 *
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_2">https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_2</a>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/native_sl.php?chapter=9_2">https://pay.weixin.qq.com/wiki/doc/api/native_sl.php?chapter=9_2</a>
 * @param data  查询参数对象 {@link OrderQueryInput}
 * @param apiKey API秘钥
 * @return 订单查询结果对象 {@link OrderQueryOutput}
 */
public static OrderQueryOutput orderQuery(OrderQueryInput data, String apiKey){

    OrderQueryOutput output = null;

    try {
        Object input = WechatUtil.buildRequest(data,OrderQueryInput.class,apiKey);
        XStream xStream =  XStreamCreator.create(OrderQueryInput.class);
        String xml = xStream.toXML(input);
        log.info("微信订单查询请求数据[orderQuery]->xmlRequest:\n {}",xml);

        String xmlResponse = ConnUtil.connRemoteWithXml(xml,pay_orderquery);
        log.info("微信订单查询响应数据[orderQuery]->response xmlResponse:\n {}",ThlwsBeanUtil.formatXml(xmlResponse));
        XStream xStreamOut =  XStreamCreator.create(OrderQueryOutput.class);
        output = (OrderQueryOutput) xStreamOut.fromXML(xmlResponse);
    } catch (Exception e) {
       log.error("微信订单查询失败:{}",e.getMessage());
    }

    return  output;
}
 
开发者ID:thlws,项目名称:payment-wechat,代码行数:39,代码来源:WechatCore.java

示例3: reverse

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
 * 微信撤销订单<br>
 * 使用情境<br>
 * <p>支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。</p>
 * 注意 <br>
 * <p>7天以内的交易单可调用撤销,其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】,  没有明确的支付结果再调用【撤销订单API】</p>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3">普通商户撤销接口</a>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_11&index=3">服务商撤销接口</a>
 * @param data        撤销参数对象 {@link WechatReverseInput}
 * @param apiKey      API秘钥
 * @param p12FilePath p12文件路径
 * @return 撤销结果对象 {@link WechatReverseOutput}
 */
public static WechatReverseOutput reverse(WechatReverseInput data, String apiKey, String p12FilePath){

    WechatReverseOutput output = null;

    try {
        Object input = WechatUtil.buildRequest(data,WechatReverseInput.class,apiKey);
        XStream xStream = XStreamCreator.create(WechatReverseInput.class);
        String xml = xStream.toXML(input);
        log.info("微信撤销订单请求数据[reverse]->xmlRequest:\n {}",xml);

        String xmlResponse = ConnUtil.encryptPost(xml, pay_reverse, data.getMch_id(), p12FilePath);
        log.info("微信撤销订单响应数据[reverse]->xmlResponse:\n {}",ThlwsBeanUtil.formatXml(xmlResponse));
        XStream xStreamOut = XStreamCreator.create(WechatReverseOutput.class);
        output = (WechatReverseOutput) xStreamOut.fromXML(xmlResponse);

    } catch (Exception e) {
        log.error("微信撤销订单[reverse]失败:{}",e.getMessage());
    }
    return output;

}
 
开发者ID:thlws,项目名称:payment-wechat,代码行数:35,代码来源:WechatCore.java

示例4: loadXML

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public static SPStoryWorldData loadXML(File xmlFile) throws FileNotFoundException {
	
	
	FileReader reader = new FileReader(xmlFile);
	XStream xstream = new XStream(new DomDriver());
	xstream.autodetectAnnotations(true);
	xstream.alias(SPStoryWorldData.class.getAnnotation(XStreamAlias.class).value(), SPStoryWorldData.class);
	Object obj = xstream.fromXML(reader);
	try {
		reader.close();
	} catch (IOException e) {
	}
	if (!(obj instanceof SPStoryWorldData)) throw new RuntimeException("file " + xmlFile.getAbsolutePath() + " doesn't contain a xml with SPStoryWorldData");
	SPStoryWorldData data = (SPStoryWorldData) obj;
	data.file = xmlFile.getAbsolutePath();
	return data;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:18,代码来源:SPStoryWorldData.java

示例5: initialize

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
 * Initialize the population by either reading it from the file or making a new one from scratch
 * 
 * @param space
 */
@Override
public void initialize(Toroidal2DPhysics space) {
	XStream xstream = new XStream();
	xstream.alias("ExampleGAPopulation", ExampleGAPopulation.class);

	// try to load the population from the existing saved file.  If that failes, start from scratch
	try { 
		population = (ExampleGAPopulation) xstream.fromXML(new File(getKnowledgeFile()));
	} catch (XStreamException e) {
		// if you get an error, handle it other than a null pointer because
		// the error will happen the first time you run
		System.out.println("No existing population found - starting a new one from scratch");
		population = new ExampleGAPopulation(populationSize);
	}

	currentPolicy = population.getFirstMember();
}
 
开发者ID:amymcgovern,项目名称:spacesettlers,代码行数:23,代码来源:ExampleGAClient.java

示例6: createCloner

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@Override
public <T> Function<T, T> createCloner(ClassLoader classLoader)
{
	final XStream xstream = new XStream() {
		@Override
		protected MapperWrapper wrapMapper(MapperWrapper next) {
			return new HibernateMapper(next);
		}
	};
	xstream.setClassLoader(classLoader);
	xstream.autodetectAnnotations(true);
	xstream.registerConverter(new HibernateProxyConverter());
	xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
	xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
	xstream.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
	xstream.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
	return t -> (T) xstream.fromXML(xstream.toXML(t));
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:InitialiserServiceImpl.java

示例7: refund

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
 * 微信退款,必须指定p12文件路径,否则无法完成退款动作,目前已知退款和撤销接口需要提供p12文件 <br>
 * 使用该接口注意事项<br>
 * <ol>
 *     <li>交易时间超过一年的订单无法提交退款;</li>
 *     <li>微信支付退款支持单笔交易分多次退款,多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。申请退款总金额不能超过订单金额。 一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号;</li>
 *     <li>请求频率限制:150qps,即每秒钟正常的申请退款请求次数不超过150次错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款申请请求不超过6次;</li>
 *     <li>每个支付订单的部分退款次数不能超过50次;</li>
 * </ol>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_4">https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_4</a>
 * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/native_sl.php?chapter=9_4">https://pay.weixin.qq.com/wiki/doc/api/native_sl.php?chapter=9_4</a>
 * @param data        退款参数对象 {@link WechatRefundInput}
 * @param apiKey      微信API秘钥
 * @param p12FilePath 微信p12文件路径
 * @return 微信退款结果对象 {@link WechatRefundOutput}
 */
public static WechatRefundOutput refund(WechatRefundInput data, String apiKey, String p12FilePath){

    WechatRefundOutput output = null;

    try {
        Object input = WechatUtil.buildRequest(data,WechatRefundInput.class,apiKey);
        XStream xStream = XStreamCreator.create(WechatRefundInput.class);
        String xml = xStream.toXML(input);
        log.info("微信退款请求数据[refund]->xmlRequest:\n {}",xml);

        String xmlResponse = ConnUtil.encryptPost(xml, pay_refund, data.getMch_id(), p12FilePath);
        log.info("微信退款响应数据[refund]->xmlResponse:\n {}",ThlwsBeanUtil.formatXml(xmlResponse));
        XStream xStreamOut = XStreamCreator.create(WechatRefundOutput.class);
        output = (WechatRefundOutput) xStreamOut.fromXML(xmlResponse);

    } catch (Exception e) {
        log.error("微信退款[refund]失败:{}",e.getMessage());
    }
    return output;

}
 
开发者ID:thlws,项目名称:payment-wechat,代码行数:38,代码来源:WechatCore.java

示例8: fromXml

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T fromXml(Class<T> clazz, InputStream is) {
  XStream xstream = XStreamInitializer.getInstance();
  xstream.alias("xml", clazz);
  xstream.processAnnotations(clazz);
  return (T) xstream.fromXML(is);
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:8,代码来源:ApiTestModule.java

示例9: toPojo

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public static GerarNFSeResposta toPojo(String xml) {
  XStream xstream = new XStream();
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.autodetectAnnotations(true);
  xstream.ignoreUnknownElements();
  xstream.alias("GerarNfseResposta", GerarNFSeResposta.class);
  xstream.alias("Nfse", NFSe.class);
  GerarNFSeResposta gerarNfseResposta = (GerarNFSeResposta) xstream.fromXML(xml);
  return gerarNfseResposta;
}
 
开发者ID:pablopdomingos,项目名称:nfse,代码行数:11,代码来源:GerarNFSeResposta.java

示例10: fromXML

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
/**
 * 从xml字符串创建bean对象
 */
public static <T extends WxPayBaseResult> T fromXML(String xmlString, Class<T> clz) {
  XStream xstream = XStreamInitializer.getInstance();
  xstream.processAnnotations(clz);
  T result = (T) xstream.fromXML(xmlString);
  result.setXmlString(xmlString);
  return result;
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:11,代码来源:WxPayBaseResult.java

示例11: launchGame

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
private void launchGame () {
    XStream xstream = new XStream(new DomDriver());
    FXConverters.configure(xstream);
    xstream.setMode(XStream.SINGLE_NODE_XPATH_RELATIVE_REFERENCES);
    myGame.createAndSortGlobals();
    String xml = xstream.toXML(myGame);

    IGame game = (IGame) xstream.fromXML(xml);
    new GamePlayer(game);
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:11,代码来源:AuthoringView.java

示例12: load

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void load(SummarySectionsConfig element)
{
	super.load(element);
	if( element.getConfiguration() != null )
	{
		try
		{
			XStream xstream = new XStream();
			HashMap<String, String> fromXML = (HashMap<String, String>) xstream.fromXML(element.getConfiguration());

			boolean desc = fromXML.containsKey(DESCRIPTION_LENGTH_KEY);
			if( desc )
			{
				maxLengthDesc.set(fromXML.get(DESCRIPTION_LENGTH_KEY), 355);
			}
			limitDesc.setSelected(desc);
			maxLengthDesc.setEnabled(desc);

			boolean title = fromXML.containsKey(TITLE_LENGTH_KEY);
			if( title )
			{
				maxLengthTitle.set(fromXML.get(TITLE_LENGTH_KEY), 200);
			}
			limitTitle.setSelected(title);
			maxLengthTitle.setEnabled(title);
		}
		catch( StreamException e )
		{
			limitDesc.setSelected(false);
			maxLengthDesc.setEnabled(false);

			limitTitle.setSelected(false);
			maxLengthTitle.setEnabled(false);
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:39,代码来源:BasicConfig.java

示例13: deserialize

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public Object deserialize(String string) {
	XStream xstream = new XStream();
	return xstream.fromXML(string);
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:5,代码来源:XmlSerializer.java

示例14: getSpriteModel

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public List<Sprite> getSpriteModel(File file){
	XStream xstream = new XStream(new DomDriver());
	List<Sprite> sprites = (List<Sprite>)xstream.fromXML(file);
	return sprites;
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:6,代码来源:XStreamHandler.java

示例15: getTargets

import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public static Object getTargets(byte[] inputData) throws IOException {
    XStream xstream = new XStream(new DomDriver("UTF-8"));
    return xstream.fromXML(new GZIPInputStream(new ByteArrayInputStream(inputData)));
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:5,代码来源:Operation.java


注:本文中的com.thoughtworks.xstream.XStream.fromXML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。