當前位置: 首頁>>代碼示例>>Java>>正文


Java XStream類代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:floschne,項目名稱:NLP_ProjectNER,代碼行數:19,代碼來源:NERAnnotator.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:ReplaceDeletedControlsXmlMigration.java

示例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;

}
 
開發者ID:thlws,項目名稱:payment-wechat,代碼行數:33,代碼來源:WechatClient.java

示例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);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:20,代碼來源:WorkflowCommentFileConverter.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:ItemConverter.java

示例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;
}
 
開發者ID:amymcgovern,項目名稱:spacesettlers,代碼行數:26,代碼來源:SpaceSettlersSimulator.java

示例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();
}
 
開發者ID:CatherineHa,項目名稱:Proj4,代碼行數:23,代碼來源:ExampleGAClient.java

示例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();
}
 
開發者ID:twak,項目名稱:chordatlas,代碼行數:27,代碼來源:TweedSettings.java

示例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 );
			}
		}
	}
 
開發者ID:twak,項目名稱:chordatlas,代碼行數:23,代碼來源:TweedSettings.java

示例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);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:ItemConverter.java

示例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);
}
 
開發者ID:mallowigi,項目名稱:a-file-icon-idea,代碼行數:30,代碼來源:Associations.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:OAuthTokenConverter.java

示例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;
}
 
開發者ID:thlws,項目名稱:payment-wechat,代碼行數:31,代碼來源:WechatCore.java

示例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;
}
 
開發者ID:LinuxSuRen,項目名稱:phoenix.webui.suite.runner,代碼行數:34,代碼來源:XStreamSuiteParser.java

示例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);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:FavouriteItemsConverter.java


注:本文中的com.thoughtworks.xstream.XStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。