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


Java XStream.alias方法代碼示例

本文整理匯總了Java中com.thoughtworks.xstream.XStream.alias方法的典型用法代碼示例。如果您正苦於以下問題:Java XStream.alias方法的具體用法?Java XStream.alias怎麽用?Java XStream.alias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.thoughtworks.xstream.XStream的用法示例。


在下文中一共展示了XStream.alias方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: loadConfigFiles

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * Load in the configuration files
 * @throws SimulatorException 
 * 
 */
public SpaceSettlersConfig loadConfigFiles(JSAPResult parserConfig) throws SimulatorException {
	String configFile = parserConfig.getString("configPath") + parserConfig.getString("simulatorConfigFile");

	XStream xstream = new XStream();
	xstream.alias("SpaceSettlersConfig", SpaceSettlersConfig.class);
	xstream.alias("HighLevelTeamConfig", HighLevelTeamConfig.class);
	xstream.alias("BaseConfig", BaseConfig.class);
	xstream.alias("AsteroidConfig", RandomAsteroidConfig.class);
	xstream.alias("FixedAsteroidConfig", FixedAsteroidConfig.class);
	xstream.alias("FlagConfig", FlagConfig.class);

	try { 
		simConfig = (SpaceSettlersConfig) xstream.fromXML(new File(configFile));
	} catch (Exception e) {
		throw new SimulatorException("Error parsing config file at string " + e.getMessage());
	}
	return simConfig;
}
 
開發者ID:CatherineHa,項目名稱:Proj4,代碼行數:24,代碼來源:SpaceSettlersSimulator.java

示例3: 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

示例4: initialize

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * Demonstrates one way to read in knowledge from a file
 */
@Override
public void initialize(Toroidal2DPhysics space) {
	asteroidToShipMap = new HashMap<UUID, Ship>();
	aimingForBase = new HashMap<UUID, Boolean>();
	
	XStream xstream = new XStream();
	xstream.alias("ExampleKnowledge", ExampleKnowledge.class);

	try { 
		myKnowledge = (ExampleKnowledge) xstream.fromXML(new File(knowledgeFile));
	} 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
		myKnowledge = new ExampleKnowledge();
	}
}
 
開發者ID:amymcgovern,項目名稱:spacesettlers,代碼行數:20,代碼來源:PacifistHeuristicAsteroidCollectorTeamClient.java

示例5: 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

示例6: 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

示例7: configXStream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public void configXStream(XStream xstream) {
	xstream.alias("body", BDLPrimitiveXML.class);
	xstream.alias("switch", BDLPrimitiveXML.class);
	xstream.alias("guard", BDLPrimitiveXML.class);
	xstream.alias("cnd", BDLConditionXML.class);
	xstream.alias("action", BDLActionXML.class);		
	
	xstream.registerConverter(BDLPrimitiveXMLConverter.INSTANCE);
	xstream.registerConverter(BDLConditionXMLConverter.INSTANCE);
	xstream.registerConverter(BDLActionXMLConverter.INSTANCE);
}
 
開發者ID:kefik,項目名稱:BDL-4J,代碼行數:12,代碼來源:BDLParserXMLConfig.java

示例8: toPojo

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static CompNFSe toPojo(String xml) {
  XStream xstream = new XStream();
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.autodetectAnnotations(true);
  xstream.ignoreUnknownElements();
  xstream.alias("CompNfse", CompNFSe.class);
  xstream.alias("Nfse", NFSe.class);
  CompNFSe compNfse = (CompNFSe) xstream.fromXML(xml);
  return compNfse;
}
 
開發者ID:pablopdomingos,項目名稱:nfse,代碼行數:11,代碼來源:CompNFSe.java

示例9: customizeXstream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 *
 * @param xstream
 */
@Override
public void customizeXstream(XStream xstream) {
    xstream.registerConverter(new ShrimpSpeciesNodeXMLConverter());
    xstream.alias("ShrimpSpeciesNode", ShrimpSpeciesNode.class);

    xstream.registerConverter(new SquidSpeciesModelXMLConverter());
    xstream.alias("SquidSpeciesModel", SquidSpeciesModel.class);

    xstream.registerConverter(new ConstantNodeXMLConverter());
    xstream.alias("ConstantNode", ConstantNode.class);

    xstream.registerConverter(new VariableNodeForSummaryXMLConverter());
    xstream.alias("VariableNodeForSummary", VariableNodeForSummary.class);
    xstream.alias("VariableNodeForPerSpotTaskExpressions", VariableNodeForPerSpotTaskExpressions.class);
    xstream.alias("VariableNodeForIsotopicRatios", VariableNodeForIsotopicRatios.class);

    xstream.registerConverter(new OperationXMLConverter());
    xstream.alias("Operation", Operation.class);
    xstream.registerConverter(new FunctionXMLConverter());
    xstream.alias("Operation", Function.class);
    xstream.alias("Operation", OperationOrFunctionInterface.class);

    xstream.registerConverter(new ExpressionTreeXMLConverter());
    xstream.alias("ExpressionTree", ExpressionTree.class);
    xstream.alias("ExpressionTree", ExpressionTreeInterface.class);

    // Note: http://cristian.sulea.net/blog.php?p=2014-11-12-xstream-object-references
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.autodetectAnnotations(true);
}
 
開發者ID:CIRDLES,項目名稱:Squid,代碼行數:35,代碼來源:ExpressionTree.java

示例10: main

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static void main(final String[] args) {
	final XStream xstream = new XStream(new DomDriver());
	xstream.alias("routers", List.class);
	xstream.alias("router", Entity.class);
	List<Entity> rules = new ArrayList<Entity>();
	final File file = new File("E:\\eclipseworkspace\\SFbestFramework\\src\\test\\resources\\spring\\routers.xml");

	rules = (List<Entity>) xstream.fromXML(file);
	System.out.println(rules);
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:12,代碼來源:ShardTableRuleFactoryBean.java

示例11: textMessageToXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static String textMessageToXml(Message msg) {
    if (null == msg) {
        return "";
    }
    XStream xStream = new XStream();
    xStream.alias("xml", msg.getClass());
    xStream.alias("item", new NewsItem().getClass());
    return xStream.toXML(msg);
}
 
開發者ID:MonkeysAndDogs,項目名稱:banana,代碼行數:10,代碼來源:MessageUtil.java

示例12: getXStream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@Override
public XStream getXStream()
{
	final XStream xstream = super.getXStream();
	xstream.alias("com.tle.core.oauth.beans.OAuthClient", OAuthClient.class);
	xstream.alias("com.tle.core.oauth.beans.OAuthToken", OAuthToken.class);
	return xstream;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:OAuthServiceImpl.java

示例13: openStream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
private XStream openStream() {
    XStream stream = new XStream(new StaxDriver());
    stream.alias("ZigBeeNode", ZigBeeNodeDao.class);
    stream.alias("ZigBeeDevice", ZigBeeEndpointDao.class);
    stream.alias("MacCapabilitiesType", MacCapabilitiesType.class);
    stream.alias("ServerCapabilitiesType", ServerCapabilitiesType.class);
    stream.alias("PowerSourceType", PowerSourceType.class);
    stream.alias("FrequencyBandType", FrequencyBandType.class);
    return stream;
}
 
開發者ID:zsmartsystems,項目名稱:com.zsmartsystems.zigbee,代碼行數:11,代碼來源:ZigBeeNetworkStateSerializerImpl.java

示例14: fromXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public void fromXml(String xml) throws Exception {
    XStream xStream = new XStream();
    xStream.registerConverter(new MapEntryConverter());
    xStream.alias("xml", Map.class);
    backupMap = (HashMap<String, Object>)xStream.fromXML(xml);
}
 
開發者ID:superkoh,項目名稱:k-framework,代碼行數:7,代碼來源:WXPayData.java

示例15: initXStream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
protected void initXStream() {

        _xStream = new XStream(null, new XppDriver(), new ClassLoaderReference(
                XStreamConfiguratorRegistryUtil.getConfiguratorsClassLoader(XStream.class.getClassLoader())));

        _xStream.omitField(HashMap.class, "cache_bitmask");

        Set<XStreamConfigurator> xStreamConfigurators = XStreamConfiguratorRegistryUtil.getXStreamConfigurators();

        if (SetUtil.isEmpty(xStreamConfigurators)) {
            return;
        }

        List<String> allowedTypeNames = new ArrayList<>();

        for (XStreamConfigurator xStreamConfigurator : xStreamConfigurators) {
            List<XStreamAlias> xStreamAliases = xStreamConfigurator.getXStreamAliases();

            if (ListUtil.isNotEmpty(xStreamAliases)) {
                for (XStreamAlias xStreamAlias : xStreamAliases) {
                    _xStream.alias(xStreamAlias.getName(), xStreamAlias.getClazz());
                }
            }

            List<XStreamConverter> xStreamConverters = xStreamConfigurator.getXStreamConverters();

            if (ListUtil.isNotEmpty(xStreamConverters)) {
                for (XStreamConverter xStreamConverter : xStreamConverters) {
                    _xStream.registerConverter(new ConverterAdapter(xStreamConverter), XStream.PRIORITY_VERY_HIGH);
                }
            }

            List<XStreamType> xStreamTypes = xStreamConfigurator.getAllowedXStreamTypes();

            if (ListUtil.isNotEmpty(xStreamTypes)) {
                for (XStreamType xStreamType : xStreamTypes) {
                    allowedTypeNames.add(xStreamType.getTypeExpression());
                }
            }
        }

        // For default permissions, first wipe than add default

        _xStream.addPermission(NoTypePermission.NONE);

        // Add permissions

        _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        _xStream.addPermission(XStreamStagedModelTypeHierarchyPermission.STAGED_MODELS);

        _xStream.allowTypes(_XSTREAM_DEFAULT_ALLOWED_TYPES);

        _xStream.allowTypeHierarchy(List.class);
        _xStream.allowTypeHierarchy(Map.class);
        _xStream.allowTypeHierarchy(Timestamp.class);
        _xStream.allowTypeHierarchy(Set.class);

        _xStream.allowTypes(allowedTypeNames.toArray(new String[0]));

        _xStream.allowTypesByWildcard(new String[] { "com.thoughtworks.xstream.mapper.DynamicProxyMapper*" });
    }
 
開發者ID:inofix,項目名稱:ch-inofix-timetracker,代碼行數:62,代碼來源:BaseExportImportController.java


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