本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例13: deserialize
import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public Object deserialize(String string) {
XStream xstream = new XStream();
return xstream.fromXML(string);
}
示例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;
}
示例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)));
}