com.thoughtworks.xstream.XStream.alias()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中com.thoughtworks.xstream.XStream.alias()方法的一些代码示例,展示了XStream.alias()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.alias()方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:alias

XStream.alias介绍

[英]Alias a Class to a shorter name to be used in XML elements.
[中]将类别名为要在XML元素中使用的较短名称。

代码示例

代码示例来源:origin: stackoverflow.com

XStream xstream = new XStream();
 xstream.alias("person", Person.class);
 xstream.alias("persons", PersonList.class);
 xstream.addImplicitCollection(PersonList.class, "list");
 PersonList list = new PersonList();
 list.add(new Person("ABC",12,"address"));
 list.add(new Person("XYZ",20,"address2"));
 String xml = xstream.toXML(list);

代码示例来源:origin: apache/cloudstack

InputStream is = method.getResponseBodyAsStream();
XStream xstream = new XStream(new DomDriver());
xstream.alias("account", RegionAccount.class);
xstream.alias("user", RegionUser.class);
xstream.aliasField("id", RegionAccount.class, "uuid");
xstream.aliasField("name", RegionAccount.class, "accountName");

代码示例来源:origin: stackoverflow.com

map.put("island","faranga");
XStream magicApi = new XStream();
magicApi.registerConverter(new MapEntryConverter());
magicApi.alias("root", Map.class);

代码示例来源:origin: apache/cloudstack

if (client.executeMethod(method) == 200) {
  InputStream is = method.getResponseBodyAsStream();
  XStream xstream = new XStream(new DomDriver());
  xstream.alias("domain", RegionDomain.class);
  xstream.aliasField("id", RegionDomain.class, "uuid");
  xstream.aliasField("parentdomainid", RegionDomain.class, "parentUuid");

代码示例来源:origin: javamelody/javamelody

private static XStream createXStream(boolean json) {
    final XStream xstream;
    if (json) {
      // format json
      xstream = new XStream(new JsonHierarchicalStreamDriver());
      xstream.setMode(XStream.NO_REFERENCES);
    } else {
      // sinon format xml, utilise la dépendance XPP3 par défaut
      xstream = new XStream();
    }
    for (final Map.Entry<String, Class<?>> entry : XStreamAlias.getMap().entrySet()) {
      xstream.alias(entry.getKey(), entry.getValue());
    }
    final MapConverter mapConverter = new MapConverter(xstream.getMapper()) {
      /** {@inheritDoc} */
      @SuppressWarnings("rawtypes")
      @Override
      public boolean canConvert(Class type) {
        return true; // Counter.requests est bien une map
      }
    };
    xstream.registerLocalConverter(Counter.class, "requests", mapConverter);
    xstream.registerLocalConverter(Counter.class, "rootCurrentContextsByThreadId",
        mapConverter);
    return xstream;
  }
}

代码示例来源:origin: apache/cloudstack

if (client.executeMethod(method) == 200) {
  InputStream is = method.getResponseBodyAsStream();
  XStream xstream = new XStream(new DomDriver());
  xstream.alias("useraccount", UserAccountVO.class);
  xstream.aliasField("id", UserAccountVO.class, "uuid");
  try(ObjectInputStream in = xstream.createObjectInputStream(is);) {

代码示例来源:origin: Impetus/Kundera

/**
 * get XStream Object.
 * 
 * @return XStream object.
 */
private XStream getXStreamObject()
{
  XStream stream = new XStream();
  stream.alias("indexerProperties", IndexerProperties.class);
  stream.alias("node", IndexerProperties.Node.class);
  return stream;
}

代码示例来源:origin: Impetus/Kundera

/**
 * get XStream Object.
 * 
 * @return XStream object.
 */
private XStream getXStreamObject()
{
  if (xStream == null)
  {
    XStream stream = new XStream();
    stream.alias("clientProperties", ClientProperties.class);
    stream.alias("dataStore", ClientProperties.DataStore.class);
    stream.alias("schema", ClientProperties.DataStore.Schema.class);
    stream.alias("table", ClientProperties.DataStore.Schema.Table.class);
    stream.alias("dataCenter", ClientProperties.DataStore.Schema.DataCenter.class);
    stream.alias("connection", ClientProperties.DataStore.Connection.class);
    stream.alias("server", ClientProperties.DataStore.Connection.Server.class);
    return stream;
  }
  else
  {
    return xStream;
  }
}

代码示例来源:origin: stackoverflow.com

XStream xStream = new XStream();
xStream.alias("Strings", String[].class);
xStream.alias("String", String.class);
String[] result = (String[])xStream.fromXML(file);

代码示例来源:origin: stackoverflow.com

List <String> list = new ArrayList <String>();
list.add("a");
list.add("b");

XStream xStream = new XStream();
xStream.alias("Strings", List.class);
xStream.alias("String", String.class);
String result = xStream.toXML(list);

代码示例来源:origin: stackoverflow.com

XStream xstream = new XStream();
xstream.alias("comments", Comments.class);
xstream.alias("comment", Comment.class);
xstream.addImplicitCollection(Comments.class, "comments");
Comments comments = (Comments)xstream.fromXML(xml);

代码示例来源:origin: stackoverflow.com

XStream xStream = new XStream();
xStream.alias("Strings", ArrayList.class);
xStream.alias("String", String.class);
xStream.addImplicitArray(ArrayList.class, "elementData");
List <String> result = (List <String>)xStream.fromXML(file);

代码示例来源:origin: apache/cloudstack

private static void writeAlertTypes(String dirName) {
  XStream xs = new XStream();
  xs.alias("alert", Alert.class);
  try(ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName + "/alert_types.xml"), "alerts");) {
    for (Field f : AlertManager.class.getFields()) {
      if (f.getClass().isAssignableFrom(Number.class)) {
        String name = f.getName().substring(11);
        Alert alert = new Alert(name, f.getInt(null));
        out.writeObject(alert);
      }
    }
  } catch (IOException e) {
    s_logger.error("Failed to create output stream to write an alert types ", e);
  } catch (IllegalAccessException e) {
    s_logger.error("Failed to read alert fields ", e);
  }
}

代码示例来源:origin: apache/cloudstack

XStream xs = new XStream();
xs.alias("command", Command.class);
xs.alias("arg", Argument.class);
String xmlDocDir = s_dirName + "/xmldoc";
String rootAdminDirName = xmlDocDir + "/apis";

代码示例来源:origin: apache/cloudstack

Gson gson = new Gson();
XStream xs = new XStream(new DomDriver());
xs.alias("command", Command.class);
xs.alias("arg", Argument.class);

代码示例来源:origin: org.drools/guvnor-repository

private XStream getXStream() {
  XStream xs = new XStream();
  xs.alias("inbox-entries", List.class);
  xs.alias("entry", InboxEntry.class);
  return xs;
}

代码示例来源:origin: org.jfrog.jade.plugins.common/jade-plugin-common

private static XStream getXStream() {
  XStream xStream = new XStream();
  xStream.alias("deployment", Deployment.class);
  xStream.alias("projectDeployments", ProjectDeployments.class);
  return xStream;
}

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-project-backend

private XStream createXStream() {
    XStream xStream = new XStream();
    xStream.alias("configuration", ProjectImports.class);
    xStream.alias("import", Import.class);
    return xStream;
  }
}

代码示例来源:origin: org.kuali.ole/ole-sru

public OleSRUDublinRecord fromXML(String fileContent) {
  XStream xStream = new XStream();
  xStream.alias("dublincore", OleSRUDublinRecord.class);
  xStream.alias("dublin", OleSRUDublin.class);
  Object object = xStream.fromXML(fileContent);
  return (OleSRUDublinRecord) object;
}

代码示例来源:origin: igniterealtime/Spark

private XStream getXStream() {
  if (xstream == null) {
    xstream = new XStream();
    xstream.alias("sounds", SoundPreferences.class);
  }
  return xstream;
}

相关文章