本文整理汇总了Java中com.thoughtworks.xstream.XStream类的典型用法代码示例。如果您正苦于以下问题:Java XStream类的具体用法?Java XStream怎么用?Java XStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XStream类属于com.thoughtworks.xstream包,在下文中一共展示了XStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
// instantiate and add feature extractors
if (featureExtractionFile == null) {
try {
featureExtractors = FeatureExtractorFactory.createAllFeatureExtractors();
} catch (IOException e) {
e.printStackTrace();
}
} else {
// load the settings from a file
// initialize the XStream if a xml file is given:
XStream xstream = XStreamFactory.createXStream();
featureExtractors = (List<FeatureExtractor1<Token>>) xstream.fromXML(new File(featureExtractionFile));
}
}
示例2: replaceAllObsoleteControls
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
public static boolean replaceAllObsoleteControls(XmlDocument xml, Node wizardNode, XStream x)
{
boolean modified = false;
modified |= replaceItemFinder(xml, wizardNode, x);
modified |= replaceResourceSelector(xml, wizardNode, x);
modified |= replaceGoogleBooks(xml, wizardNode, x);
modified |= replaceYouTube(xml, wizardNode, x);
modified |= replaceFlickr(xml, wizardNode, x);
modified |= replaceITunesU(xml, wizardNode, x);
modified |= replaceFileUpload(xml, wizardNode, x);
modified |= replaceLinks(xml, wizardNode, x);
modified |= replacePackageUploader(xml, wizardNode, x);
modified |= replaceMyPages(xml, wizardNode, x);
return modified;
}
示例3: queryMicroMch
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
/***
* build request data for wechat ~ query submch
* api:https://api.mch.weixin.qq.com/secapi/mch/submchmanage?action=query
* @param o the o
* @param apiKey the api key
* @param p12FilePath the p 12 file path
* @return string
* @author HanleyTang
*/
public static String queryMicroMch(MicroMchInput o, String apiKey, String p12FilePath){
String result = "";
try {
Map<String, Object> mapData = ThlwsBeanUtil.ObjectToMap(o);
mapData = ThlwsBeanUtil.dataFilter(mapData);
String sign = WechatUtil.sign(mapData,apiKey);
mapData.put("sign", sign);
MicroMchInput xwr = (MicroMchInput) ThlwsBeanUtil.mapToObject(mapData,MicroMchInput.class);
xwr.setNonce_str(ThlwsBeanUtil.getRandomString(32));
XStream xStream = XStreamCreator.create(MicroMchInput.class);
String xml = xStream.toXML(xwr);
log.info("查询小微收款人资料[submchmanage?action=query] xml request:\n {}",xml);
result =ConnUtil.encryptPost(xml, micro_mch_qry, o.getMch_id(), p12FilePath);
log.info("查询小微收款人资料[submchmanage?action=query] xml response:\n {}",result);
} catch (Exception e) {
log.error("queryMicroMch error:{}",e.getMessage());
}
return result;
}
示例4: exportExtras
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
@Override
public void exportExtras(ItemConverterInfo info, XStream xstream, SubTemporaryFile extrasFolder) throws IOException
{
final ConverterParams params = info.getParams();
final boolean attachments = !params.hasFlag(ConverterParams.NO_ITEMSATTACHMENTS);
if( attachments )
{
final Item item = info.getItem();
final List<WorkflowMessage> messages = workflowService.getMessages(item.getItemId());
final SubTemporaryFile workflowDir = new SubTemporaryFile(extrasFolder, FOLDER_NAME);
for( WorkflowMessage msg : messages )
{
final String uuid = msg.getUuid();
final WorkflowMessageFile wfFile = new WorkflowMessageFile(uuid);
final SubTemporaryFile messageDir = new SubTemporaryFile(workflowDir, uuid);
fileSystemService.copyToStaging(wfFile, messageDir, false);
}
}
}
示例5: getXStream
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
private synchronized XStream getXStream()
{
if( xstream == null )
{
xstream = new XmlServiceImpl.ExtXStream(getClass().getClassLoader()) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.registerConverter(new WorkflowNodeConverter());
xstream.registerConverter(new BaseEntityXmlConverter(registry));
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
}
return xstream;
}
示例6: getTeamClientConfig
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
/**
* Make the team client from the configuration file
*
* @param teamConfig
* @return
* @throws SimulatorException
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
*/
public TeamClientConfig getTeamClientConfig(HighLevelTeamConfig teamConfig, String configPath) throws SimulatorException {
String fileName = configPath + teamConfig.getConfigFile();
XStream xstream = new XStream();
xstream.alias("TeamClientConfig", TeamClientConfig.class);
TeamClientConfig lowLevelTeamConfig;
try {
lowLevelTeamConfig = (TeamClientConfig) xstream.fromXML(new File(fileName));
} catch (Exception e) {
throw new SimulatorException("Error parsing config team config file " + fileName + " at string " + e.getMessage());
}
return lowLevelTeamConfig;
}
示例7: 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();
}
示例8: load
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
public static void load( File folder ) {
if (!folder.isDirectory())
folder = folder.getParentFile();
TweedSettings.folder = folder;
try {
File def = new File( folder, "tweed.xml" );
if (!def.exists())
settings = new TweedSettings();
else
settings = (TweedSettings) new XStream(new PureJavaReflectionProvider()).fromXML( def );
TweedFrame.instance.tweed.initFrom( folder.toString() );
} catch ( Throwable th ) {
settings = new TweedSettings();
save(true);
th.printStackTrace();
}
writeRecentFiles();
}
示例9: loadDefault
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
public static void loadDefault() {
if (recentFiles == null) {
try {
recentFiles = (RecentFiles) new XStream().fromXML( RECENT_FILE_LOCATION );
}
catch (Throwable th) {
System.out.println( "couldn't load recent project list" );
recentFiles = new RecentFiles();
}
}
if (!recentFiles.f.isEmpty()) {
File last = recentFiles.f.get( 0 );
if (last.exists())
load( last );
else {
JOptionPane.showMessageDialog( null, "Can't find last project " + last.getName() );
recentFiles.f.remove( 0 );
}
}
}
示例10: runExtras
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
void runExtras(ItemConverterInfo info, XStream xs, SubTemporaryFile extrasFolder, boolean doImport)
throws IOException
{
Map<String, ItemExtrasConverter> convertersMap = itemExtrasTracker.getBeanMap();
for( ItemExtrasConverter converter : convertersMap.values() )
{
if( doImport )
{
converter.importExtras(info, xs, extrasFolder);
}
else
{
converter.exportExtras(info, xs, extrasFolder);
}
}
}
示例11: create
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
/**
* Parse icon_associations.xml to build the list of Associations
*
* @return
*/
public static Associations create() {
final URL associationsXml = AssociationsFactory.class.getResource("/icon_associations.xml");
final XStream xStream = new XStream();
xStream.alias("associations", Associations.class);
xStream.alias("regex", RegexAssociation.class);
xStream.alias("type", TypeAssociation.class);
if (StaticPatcher.isClass("com.intellij.psi.PsiClass")) {
xStream.alias("psi", PsiElementAssociation.class);
} else {
xStream.alias("psi", TypeAssociation.class);
}
xStream.useAttributeFor(Association.class, "icon");
xStream.useAttributeFor(Association.class, "name");
xStream.useAttributeFor(RegexAssociation.class, "pattern");
xStream.useAttributeFor(TypeAssociation.class, "type");
if (StaticPatcher.isClass("com.intellij.psi.PsiClass")) {
xStream.useAttributeFor(PsiElementAssociation.class, "type");
}
return (Associations) xStream.fromXML(associationsXml);
}
示例12: getXStream
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
private synchronized XStream getXStream()
{
if( xstream == null )
{
xstream = new XmlServiceImpl.ExtXStream(getClass().getClassLoader()) {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
xstream.alias("com.tle.core.oauth.beans.OAuthToken", OAuthToken.class);
xstream.alias("com.tle.core.oauth.beans.OAuthClient", OAuthClient.class);
xstream.registerConverter(new ClientXStreamConverter());
}
return xstream;
}
示例13: 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;
}
示例14: parse
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
@Override
public Suite parse(InputStream suiteInputStream) throws Exception
{
XStream xStream = new XStream(new StaxDriver());
xStream.addPermission(NoTypePermission.NONE);
xStream.allowTypesByWildcard(new String[]{
"com.surenpi.autotest.suite.runner.**"
});
xStream.aliasSystemAttribute(null, "class");
xStream.alias("suite", Suite.class);
xStream.aliasField("pageConfig", Suite.class, "xmlConfPath");
xStream.useAttributeFor(Suite.class, "xmlConfPath");
xStream.aliasField("pages", Suite.class, "pageList");
xStream.useAttributeFor(Suite.class, "pagePackage");
xStream.useAttributeFor(Suite.class, "rows");
xStream.useAttributeFor(Suite.class, "afterSleep");
xStream.alias("page", SuitePage.class);
xStream.aliasField("class", SuitePage.class, "pageCls");
xStream.useAttributeFor(SuitePage.class, "pageCls");
xStream.aliasField("actions", SuitePage.class, "actionList");
xStream.useAttributeFor(SuitePage.class, "repeat");
xStream.alias("action", SuiteAction.class);
xStream.useAttributeFor(SuiteAction.class, "field");
xStream.useAttributeFor(SuiteAction.class, "name");
Object obj = xStream.fromXML(suiteInputStream);
return (Suite) obj;
}
示例15: doExport
import com.thoughtworks.xstream.XStream; //导入依赖的package包/类
@Override
public void doExport(TemporaryFileHandle staging, Institution institution, ConverterParams params)
throws IOException
{
if( !params.hasFlag(ConverterParams.NO_ITEMS) )
{
final SubTemporaryFile allBookmarksExportFolder = new SubTemporaryFile(staging,
MY_FAVOURITES_IMPORT_EXPORT_FOLDER);
// write out the format details
xmlHelper.writeExportFormatXmlFile(allBookmarksExportFolder, true);
final XStream locXstream = getXStream();
List<Bookmark> bookmarks = bookmarkDao.listAll();
for( Bookmark bookmark : bookmarks )
{
initialiserService.initialise(bookmark);
final BucketFile bucketFolder = new BucketFile(allBookmarksExportFolder, bookmark.getId());
xmlHelper.writeXmlFile(bucketFolder, bookmark.getId() + ".xml", bookmark, locXstream);
}
}
}