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


Java XStream.setMode方法代碼示例

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


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

示例1: readFile

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * Reads in an XML file describing a fully serialized game.
 */
@Override
public IGame readFile (File xmlFile) throws LoadErrorException {
    XStream xstream = new XStream(new DomDriver());
    FXConverters.configure(xstream);
    xstream.setMode(XStream.SINGLE_NODE_XPATH_RELATIVE_REFERENCES);
    try {
        String xml = fileToXMLString(xmlFile);
        return (IGame) xstream.fromXML(xml);
    }
    catch (IOException | UnknownFieldException e) {
        // TODO throw a checked error here to make front-end deal with an error if the file is
        // corrupted
        throw new LoadErrorException("Could not deserialize file: " + xmlFile.getPath());
    }
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:19,代碼來源:GameReader.java

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

示例3: converterParaXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public String converterParaXml() {
  String XML_HEADER = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  
  XStream xstream = new XStream();
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.autodetectAnnotations(true);
  
  return XML_HEADER + xstream.toXML(this);
}
 
開發者ID:pablopdomingos,項目名稱:nfse,代碼行數:10,代碼來源:AbstractService.java

示例4: toPojo

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

示例5: toPojo

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

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

示例7: 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 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.registerConverter(new FunctionXMLConverter());

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

    xstream.registerConverter(new TaskXMLConverter());
    xstream.alias("Task", Task.class);
    xstream.alias("Task", this.getClass());

    // Note: http://cristian.sulea.net/blog.php?p=2014-11-12-xstream-object-references
    xstream.setMode(XStream.NO_REFERENCES);

}
 
開發者ID:CIRDLES,項目名稱:Squid,代碼行數:32,代碼來源:Task.java

示例8: customizeXstream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@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);

    xstream.registerConverter(new ExpressionXMLConverter());
    xstream.alias("Expression", Expression.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,代碼行數:34,代碼來源:Expression.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: initXStream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * Needed to recover drag information
 */
private void initXStream () {
    myXStream = new XStream(new DomDriver());
    FXConverters.configure(myXStream);
    myXStream.setMode(XStream.SINGLE_NODE_XPATH_RELATIVE_REFERENCES);

}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:10,代碼來源:WaveDragCell.java

示例11: launchGame

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
private void launchGame () {
    XStream xstream = new XStream(new DomDriver());
    FXConverters.configure(xstream);
    xstream.setMode(XStream.SINGLE_NODE_XPATH_RELATIVE_REFERENCES);
    myGame.createAndSortGlobals();
    String xml = xstream.toXML(myGame);

    IGame game = (IGame) xstream.fromXML(xml);
    new GamePlayer(game);
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:11,代碼來源:AuthoringView.java

示例12: getInstance

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static XStream getInstance() {
  XStream xstream = new XStream(new XppDriver() {

    @Override
    public HierarchicalStreamWriter createWriter(Writer out) {
      return new PrettyPrintWriter(out, getNameCoder()) {
        protected String PREFIX_CDATA = "<![CDATA[";
        protected String SUFFIX_CDATA = "]]>";
        protected String PREFIX_MEDIA_ID = "<MediaId>";
        protected String SUFFIX_MEDIA_ID = "</MediaId>";

        @Override
        protected void writeText(QuickWriter writer, String text) {
          if (text.startsWith(this.PREFIX_CDATA) && text.endsWith(this.SUFFIX_CDATA)) {
            writer.write(text);
          } else if (text.startsWith(this.PREFIX_MEDIA_ID) && text.endsWith(this.SUFFIX_MEDIA_ID)) {
            writer.write(text);
          } else {
            super.writeText(writer, text);
          }

        }

        @Override
        public String encodeNode(String name) {
          return name;//防止將_轉換成__
        }
      };
    }
  });
  xstream.ignoreUnknownElements();
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.addPermission(NullPermission.NULL);
  xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
  return xstream;
}
 
開發者ID:11590692,項目名稱:Wechat-Group,代碼行數:37,代碼來源:XStreamInitializer.java

示例13: serialise

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static String serialise(ProjectMsTeamsNotificationsBean project){
	XStream xstream = new XStream(new JsonHierarchicalStreamDriver());
       xstream.setMode(XStream.NO_REFERENCES);
       xstream.alias("projectMsTeamsnotificationConfig", ProjectMsTeamsNotificationsBean.class);
       /* For some reason, the items are coming back as "@name" and "@value"
        * so strip those out with a regex.
        */
	return xstream.toXML(project);
}
 
開發者ID:spyder007,項目名稱:teamcity-msteams-notifier,代碼行數:10,代碼來源:ProjectMsTeamsNotificationsBeanJsonSerialiser.java

示例14: toXML

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static String toXML(Object obj, boolean excludeEncryptedFields) throws Exception {
	XStream xstream = new XStream();
	if (excludeEncryptedFields) {
		OmittedFields.omitFields(xstream);
	}
	xstream.setMode(XStream.ID_REFERENCES);
	return xstream.toXML(obj);
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:9,代碼來源:CoreUtil.java

示例15: getXML

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
private String getXML (IGame game) {
    XStream xstream = new XStream(new DomDriver());
    FXConverters.configure(xstream);
    xstream.setMode(XStream.SINGLE_NODE_XPATH_RELATIVE_REFERENCES);
    return xstream.toXML(game);
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:7,代碼來源:GameWriter.java


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