本文整理了Java中com.thoughtworks.xstream.XStream.useAttributeFor()
方法的一些代码示例,展示了XStream.useAttributeFor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.useAttributeFor()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:useAttributeFor
[英]Use an attribute for an arbitrary type.
[中]对任意类型使用属性。
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* Create an alias for an attribute.
*
* @param definedIn the type where the attribute is defined
* @param attributeName the name of the attribute
* @param alias the alias itself
* @throws InitializationException if no {@link AttributeAliasingMapper} is available
* @since 1.2.2
*/
public void aliasAttribute(Class definedIn, String attributeName, String alias) {
aliasField(alias, definedIn, attributeName);
useAttributeFor(definedIn, attributeName);
}
代码示例来源:origin: spring-projects/spring-framework
xstream.useAttributeFor(type);
if (entry.getKey() instanceof String) {
if (entry.getValue() instanceof Class) {
xstream.useAttributeFor((String) entry.getKey(), (Class<?>) entry.getValue());
Class<?> key = (Class<?>) entry.getKey();
if (entry.getValue() instanceof String) {
xstream.useAttributeFor(key, (String) entry.getValue());
for (Object element : listValue) {
if (element instanceof String) {
xstream.useAttributeFor(key, (String) element);
代码示例来源:origin: openmrs/openmrs-core
/**
* Constructor that takes a custom XStream object
* @param customXstream
* @throws SerializationException
*/
public SimpleXStreamSerializer(XStream customXstream) throws SerializationException {
if (customXstream == null) {
xstream = new XStream();
} else {
this.xstream = customXstream;
}
xstream.registerConverter(new OpenmrsDynamicProxyConverter(), XStream.PRIORITY_VERY_HIGH);
//this is added to read the prior simpleframework-serialized values.
// TODO find a better way to do this.
this.xstream.useAttributeFor(ImplementationId.class, "implementationId");
}
代码示例来源:origin: anandbagmar/WAAT
public static XStream configurePageLayoutXStream(XStream xStream) {
xStream.useAttributeFor(Section.class, "actionName");
xStream.useAttributeFor(Section.class, "tagList");
xStream.useAttributeFor(Section.class, "numberOfEventsTriggered");
xStream.omitField(Section.class, "loadedTagList");
return xStream;
}
代码示例来源:origin: org.geoserver/gs-restconfig
/**
* Configure x-stream for XML encoding of link
*
* @param xStream
*/
public static void configureXML(XStream xStream) {
xStream.alias("atom:link", AtomLink.class);
xStream.useAttributeFor(AtomLink.class, "href");
xStream.useAttributeFor(AtomLink.class, "rel");
xStream.useAttributeFor(AtomLink.class, "type");
xStream.aliasAttribute(AtomLink.class, "NAMESPACE", "xmlns:atom");
}
代码示例来源:origin: br.gov.frameworkdemoiselle.component.behave/demoiselle-behave-core
@SuppressWarnings("rawtypes")
private void defineAttributes(Map<String, Class> attributesMap) {
if(attributesMap!=null){
Set<String> attributesSet = attributesMap.keySet();
for (String attribute : attributesSet) {
xstream.useAttributeFor(attribute, attributesMap.get(attribute));
}
}
}
代码示例来源:origin: org.aperteworkflow/integration
private Collection<ProcessRoleConfig> getRoles(InputStream input) {
if (input == null) {
return null;
}
XStream xstream = new XStream();
xstream.aliasPackage("config", ProcessRoleConfig.class.getPackage().getName());
xstream.useAttributeFor(String.class);
xstream.useAttributeFor(Boolean.class);
xstream.useAttributeFor(Integer.class);
return (Collection<ProcessRoleConfig>) xstream.fromXML(input);
}
代码示例来源:origin: stackoverflow.com
XStream xstream = new XStream();
xstream.registerConverter(new FlightsConverter());
xstream.alias("airport", AirportPojo.class);
xstream.alias("flights", FlightsPojo.class);
xstream.alias("flight", FlightPojo.class);
xstream.useAttributeFor(AirportPojo.class, "flights");
AirportPojo airportPojo = (AirportPojo) xstream.fromXML(xml);
代码示例来源:origin: stackoverflow.com
CarImpl myModel = new CarImpl();
File xmlFile = new File("model.xml");
XStream xstream = new XStream();
xstream.useAttributeFor(String.class);
xstream.useAttributeFor(Integer.class);
Writer writer = new FileWriter(xmlFile);
writer.write(xstream.toXML(myModel));
writer.close();
CarImpl fromXML = (CarImpl) xstream.fromXML(new FileInputStream(xmlFile));
System.out.println(fromXML);
代码示例来源:origin: org.springframework.ws/spring-oxm
/**
* Sets types to use XML attributes for.
*
* @see XStream#useAttributeFor(Class)
*/
public void setUseAttributeForTypes(Class[] types) {
for (int i = 0; i < types.length; i++) {
getXStream().useAttributeFor(types[i]);
}
}
代码示例来源:origin: org.fuzzydb.attrs/org.fuzzydb.attrs
static public void applyEnumAliases(XStream xStream) {
// ScoreConfiguration
xStream.alias("EnumDefinition", EnumDefinition.class);
xStream.useAttributeFor(EnumDefinition.class, "name");
// ensure contained elements are added to scorersList
xStream.addImplicitCollection(EnumDefinition.class, "strValues");
}
代码示例来源:origin: x-stream/xstream
/**
* Create an alias for an attribute.
*
* @param definedIn the type where the attribute is defined
* @param attributeName the name of the attribute
* @param alias the alias itself
* @throws InitializationException if no {@link AttributeAliasingMapper} is available
* @since 1.2.2
*/
public void aliasAttribute(final Class<?> definedIn, final String attributeName, final String alias) {
aliasField(alias, definedIn, attributeName);
useAttributeFor(definedIn, attributeName);
}
代码示例来源:origin: org.jbehave/jbehave-rest
protected XStream configureXStream() {
XStream stream = new XStream();
stream.addImplicitCollection(Page.class, "link");
stream.alias("results", Results.class);
stream.alias("result", Page.class);
stream.alias("content", Page.class);
stream.alias("link", Link.class);
stream.useAttributeFor(Link.class, "rel");
stream.useAttributeFor(Link.class, "href");
stream.ignoreUnknownElements();
return stream;
}
代码示例来源:origin: stackoverflow.com
XStream xs = new XStream(new DomDriver());
xs.alias("root", ParentElement.class);
xs.useAttributeFor(ChildElement.class, "aaa"); // read as attribute
xs.useAttributeFor(ChildElement.class, "bbb");
ParentElement parent = new ParentElement();
try {
FileInputStream fis = new FileInputStream("readfile");
xs.fromXML(fis, parent);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
代码示例来源:origin: org.geowebcache/gwc-rest
private static XStream getConfiguredXStream(XStream xs) {
// XStream xs = xstream;
xs.setMode(XStream.NO_REFERENCES);
xs.alias("gwcConfiguration", GeoWebCacheConfiguration.class);
xs.useAttributeFor(GeoWebCacheConfiguration.class, "xmlns_xsi");
xs.aliasField("xmlns:xsi", GeoWebCacheConfiguration.class, "xmlns_xsi");
xs.useAttributeFor(GeoWebCacheConfiguration.class, "xsi_noNamespaceSchemaLocation");
xs.aliasField("xsi:noNamespaceSchemaLocation", GeoWebCacheConfiguration.class,
"xsi_noNamespaceSchemaLocation");
xs.useAttributeFor(GeoWebCacheConfiguration.class, "xmlns");
xs.alias("wmsRasterFilterUpdate", WMSRasterFilterUpdate.class);
return xs;
}
代码示例来源:origin: com.haulmont.thirdparty/xstream
/**
* Create an alias for an attribute.
*
* @param definedIn the type where the attribute is defined
* @param attributeName the name of the attribute
* @param alias the alias itself
* @throws InitializationException if no {@link AttributeAliasingMapper} is available
* @since 1.2.2
*/
public void aliasAttribute(Class definedIn, String attributeName, String alias) {
aliasField(alias, definedIn, attributeName);
useAttributeFor(definedIn, attributeName);
}
代码示例来源:origin: org.jvnet.hudson/xstream
/**
* Create an alias for an attribute.
*
* @param definedIn the type where the attribute is defined
* @param attributeName the name of the attribute
* @param alias the alias itself
* @throws InitializationException if no {@link AttributeAliasingMapper} is available
* @since 1.2.2
*/
public void aliasAttribute(Class definedIn, String attributeName, String alias) {
aliasField(alias, definedIn, attributeName);
useAttributeFor(definedIn, attributeName);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream
/**
* Create an alias for an attribute.
*
* @param definedIn the type where the attribute is defined
* @param attributeName the name of the attribute
* @param alias the alias itself
* @throws InitializationException if no {@link AttributeAliasingMapper} is available
* @since 1.2.2
*/
public void aliasAttribute(Class definedIn, String attributeName, String alias) {
aliasField(alias, definedIn, attributeName);
useAttributeFor(definedIn, attributeName);
}
代码示例来源:origin: ch.epfl.gsn/gsn-core
public static XStream getXstream() {
XStream xstream = new XStream();
xstream.alias("stream-element", StreamElement4Rest.class);
xstream.alias("field", Field4Rest.class);
xstream.useAttributeFor(StreamElement4Rest.class,"timestamp");
xstream.addImplicitCollection(StreamElement4Rest.class, "fields");
xstream.registerConverter(new Field4RestConverter());
xstream.alias("strcture", DataField.class);
return xstream;
}
代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio
public XmlRulesDescriptorSerializer_v5_16() {
super(new RulesDeployVersionConverter());
xstream.ignoreUnknownElements();
xstream.omitField(RulesDeploy_v5_16.class, "log");
xstream.setMode(XStream.NO_REFERENCES);
xstream.aliasType("publisher", RulesDeploy_v5_16.PublisherType.class);
xstream.aliasType(RULES_DEPLOY_DESCRIPTOR_TAG, RulesDeploy_v5_16.class);
xstream.aliasType(MODULE_NAME, RulesDeploy_v5_16.WildcardPattern.class);
xstream.aliasField(LAZY_MODULES_FOR_COMPILATION, RulesDeploy_v5_16.class, "lazyModulesForCompilationPatterns");
xstream.aliasField("name", RulesDeploy_v5_16.WildcardPattern.class, "value");
xstream.useAttributeFor(RulesDeploy_v5_16.WildcardPattern.class, "value");
}
}
内容来源于网络,如有侵权,请联系作者删除!