当前位置: 首页>>代码示例>>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;未经允许,请勿转载。