本文整理汇总了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);
}
示例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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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*" });
}