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


Java XStream.autodetectAnnotations方法代碼示例

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


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

示例1: loadXML

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static SPStoryWorldData loadXML(File xmlFile) throws FileNotFoundException {
	
	
	FileReader reader = new FileReader(xmlFile);
	XStream xstream = new XStream(new DomDriver());
	xstream.autodetectAnnotations(true);
	xstream.alias(SPStoryWorldData.class.getAnnotation(XStreamAlias.class).value(), SPStoryWorldData.class);
	Object obj = xstream.fromXML(reader);
	try {
		reader.close();
	} catch (IOException e) {
	}
	if (!(obj instanceof SPStoryWorldData)) throw new RuntimeException("file " + xmlFile.getAbsolutePath() + " doesn't contain a xml with SPStoryWorldData");
	SPStoryWorldData data = (SPStoryWorldData) obj;
	data.file = xmlFile.getAbsolutePath();
	return data;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:18,代碼來源:SPStoryWorldData.java

示例2: createCloner

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@Override
public <T> Function<T, T> createCloner(ClassLoader classLoader)
{
	final XStream xstream = new XStream() {
		@Override
		protected MapperWrapper wrapMapper(MapperWrapper next) {
			return new HibernateMapper(next);
		}
	};
	xstream.setClassLoader(classLoader);
	xstream.autodetectAnnotations(true);
	xstream.registerConverter(new HibernateProxyConverter());
	xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
	xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
	xstream.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
	xstream.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
	return t -> (T) xstream.fromXML(xstream.toXML(t));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:InitialiserServiceImpl.java

示例3: fromObjectToXML

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * From object to xml.
 * 
 * @param object
 *            the object
 * @return the string
 */
public void fromObjectToXML(Serializable object,ByteArrayOutputStream outputStream) {

	String str = "<!-- It is recommended to avoid changes to xml data -->\n\n";

	XStream xs = new XStream();
	xs.autodetectAnnotations(true);
	try {
		xs.toXML(object, outputStream);
		logger.debug( "Sucessfully converted XML from JAVA Object");
	} catch (Exception e) {
		logger.error("Failed to convert from Object to XML", e);
	}
	XMLUtil.unformatXMLString(outputStream);
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:22,代碼來源:CanvasUtils.java

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

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

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

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

示例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包/類
@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

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

示例11: replyToXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * 將回複消息對象轉換成xml字符串
 *
 * @param reply 回複消息對象
 * @return 返回符合微信接口的xml字符串
 */
public String replyToXml(WeChatReply reply) {
    XStream xstream = new XStream(new XppDriver() {
        public HierarchicalStreamWriter createWriter(Writer out) {
            return new PrettyPrintWriter(out) {
                // 對所有xml節點的轉換都增加CDATA標記
                boolean cdata = true;

                @SuppressWarnings("unchecked")
                public void startNode(String name, Class clazz) {
                    super.startNode(name, clazz);
                }

                protected void writeText(QuickWriter writer, String text) {
                    if (cdata) {
                        writer.write("<![CDATA[");
                        writer.write(text);
                        writer.write("]]>");
                    } else {
                        writer.write(text);
                    }
                }
            };
        }
    });
    String type = reply.getMsgType();
    if (WeChatReply.TEXT.equals(type)) {
        xstream.omitField(WeChatReply.class, "articles");
        xstream.omitField(WeChatReply.class, "articleCount");
        xstream.omitField(WeChatReply.class, "musicUrl");
        xstream.omitField(WeChatReply.class, "hQMusicUrl");
    } else if (WeChatReply.MUSIC.equals(type)) {
        xstream.omitField(WeChatReply.class, "articles");
        xstream.omitField(WeChatReply.class, "articleCount");
        xstream.omitField(WeChatReply.class, "content");
    } else if (WeChatReply.NEWS.equals(type)) {
        xstream.omitField(WeChatReply.class, "content");
        xstream.omitField(WeChatReply.class, "musicUrl");
        xstream.omitField(WeChatReply.class, "hQMusicUrl");
    }
    xstream.autodetectAnnotations(true);
    xstream.alias("xml", reply.getClass());
    xstream.alias("item", new Article().getClass());
    return xstream.toXML(reply);
}
 
開發者ID:NeilRen,項目名稱:NEILREN4J,代碼行數:51,代碼來源:WeChatService.java

示例12: xmlStringToBean

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * 把XML轉成對象
 *
 * @param xmlStr
 * @return Object
 */
@SuppressWarnings("unchecked")
public static <T> T xmlStringToBean(String xmlStr, Class<T> cls) {
	XStream xstream = new XStream(new DomDriver());
	xstream.processAnnotations(cls);
	xstream.autodetectAnnotations(true);
	return (T) xstream.fromXML(xmlStr);
}
 
開發者ID:yi-jun,項目名稱:aaden-pay,代碼行數:14,代碼來源:XmlBeanJsonConverUtil.java

示例13: init

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
protected XStream init(BDLParserXMLConfig config) {
	XStream xstream = new XStream(new DomDriver());
	xstream.autodetectAnnotations(true);
	config.configXStream(xstream);
	return xstream;

}
 
開發者ID:kefik,項目名稱:BDL-4J,代碼行數:8,代碼來源:BDLParserXML.java

示例14: generateUiXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
 * Creates the job file based for the container object.
 * 
 * @param container
 * @param jobFile
 * @param parameterFile
 */
private void generateUiXml(Container container, IFile jobFile, IFile parameterFile) {
	LOGGER.debug("Generating UI-XML");
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	String jobXmlData = null;
	IPath iPath = new Path(jobFile.getFullPath().toString());
	
	try {
		XStream xs = new XStream();
		xs.autodetectAnnotations(true);
		xs.toXML(container,out);
		XMLUtil.unformatXMLString(out);
		
		if (jobFile.exists()) {
			showMessageBox(jobFile, out, jobFile.getName() + " already exists.Do you want to replace it?");
		} else {
			jobFile.create(new ByteArrayInputStream(out.toByteArray()), true, null);
		}

	} catch (CoreException e) {
		LOGGER.error("Exception occurred while creating UI-XML", e);
	} finally {
		componentRepo.flushRepository();
		try {
			out.close();
		} catch (IOException ioe) {
			LOGGER.error("IOException occurred while closing output stream", ioe);
		}
	}
	
	ImportedJobsRepository.INSTANCE.addImportedJobName(jobFile);
	jobXmlData = getStringValueFromXMLFile(iPath);
	storeParameterData(parameterFile, jobXmlData);
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:41,代碼來源:UiConverterUtil.java

示例15: generateSubjobUiXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
private void generateSubjobUiXml(Container container, File file, IFile parameterFile) {
	LOGGER.debug("Generating UI-XML");
	XStream xs = new XStream();
	xs.autodetectAnnotations(true);
	try(FileOutputStream fileOutputStream = new FileOutputStream(file.getPath())) {
		xs.toXML(container, fileOutputStream);
		IPath iPath = new Path(file.getPath());
		storeParameterData(parameterFile, getStringValueFromXMLFile(iPath));
	} catch (IOException ioException) {
		LOGGER.error("Exception occurred while creating UI-XML", ioException);
	} finally {
		componentRepo.flushRepository();
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:15,代碼來源:UiConverterUtil.java


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