本文整理汇总了Java中org.exolab.castor.xml.XMLContext类的典型用法代码示例。如果您正苦于以下问题:Java XMLContext类的具体用法?Java XMLContext怎么用?Java XMLContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLContext类属于org.exolab.castor.xml包,在下文中一共展示了XMLContext类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createXMLContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
/**
* Create the Castor {@code XMLContext}. Subclasses can override this to create a custom context.
* <p>The default implementation loads mapping files if defined, or the target class or packages if defined.
* @return the created resolver
* @throws MappingException when the mapping file cannot be loaded
* @throws IOException in case of I/O errors
* @see XMLContext#addMapping(org.exolab.castor.mapping.Mapping)
* @see XMLContext#addClass(Class)
*/
protected XMLContext createXMLContext(Resource[] mappingLocations, Class<?>[] targetClasses,
String[] targetPackages) throws MappingException, ResolverException, IOException {
XMLContext context = new XMLContext();
if (!ObjectUtils.isEmpty(mappingLocations)) {
Mapping mapping = new Mapping();
for (Resource mappingLocation : mappingLocations) {
mapping.loadMapping(SaxResourceUtils.createInputSource(mappingLocation));
}
context.addMapping(mapping);
}
if (!ObjectUtils.isEmpty(targetClasses)) {
context.addClasses(targetClasses);
}
if (!ObjectUtils.isEmpty(targetPackages)) {
context.addPackages(targetPackages);
}
if (this.castorProperties != null) {
for (Map.Entry<String, String> property : this.castorProperties.entrySet()) {
context.setProperty(property.getKey(), property.getValue());
}
}
return context;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:CastorMarshaller.java
示例2: getStatisticDescriptors
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
@Override
public List<StatisticDescriptor> getStatisticDescriptors(String filePath)
throws ParserException {
try {
Mapping mapping = new Mapping();
mapping.loadMapping(FileUtils.findFileAsResource("StatisticDescriptorMapping.xml"));
XMLContext context = new XMLContext();
context.addMapping(mapping);
InputSource source = new InputSource(FileUtils.findFileAsStream(filePath));
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setClass(StatisticList.class);
StatisticList list = (StatisticList)unmarshaller.unmarshal(source);
validate(list.getDescriptors());
return list.getDescriptors();
} catch (Exception e) {
ParserException parserException = new ParserException("Exception parsing statistic descriptor files", e);
Logger.getLogger(this.getClass()).error(parserException.getMessage(), parserException);
throw parserException;
}
}
开发者ID:lafourchette,项目名称:solrmeter,代码行数:21,代码来源:StatisticsParserCastorImpl.java
示例3: createXMLContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
/**
* Create the Castor {@code XMLContext}. Subclasses can override this to create a custom context.
* <p>The default implementation loads mapping files if defined, or the target class or packages if defined.
* @return the created resolver
* @throws MappingException when the mapping file cannot be loaded
* @throws IOException in case of I/O errors
* @see XMLContext#addMapping(org.exolab.castor.mapping.Mapping)
* @see XMLContext#addClass(Class)
*/
protected XMLContext createXMLContext(Resource[] mappingLocations, Class[] targetClasses, String[] targetPackages)
throws MappingException, ResolverException, IOException {
XMLContext context = new XMLContext();
if (!ObjectUtils.isEmpty(mappingLocations)) {
Mapping mapping = new Mapping();
for (Resource mappingLocation : mappingLocations) {
mapping.loadMapping(SaxResourceUtils.createInputSource(mappingLocation));
}
context.addMapping(mapping);
}
if (!ObjectUtils.isEmpty(targetClasses)) {
context.addClasses(targetClasses);
}
if (!ObjectUtils.isEmpty(targetPackages)) {
context.addPackages(targetPackages);
}
if (this.castorProperties != null) {
for (Map.Entry<String, String> property : this.castorProperties.entrySet()) {
context.setProperty(property.getKey(), property.getValue());
}
}
return context;
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:34,代码来源:CastorMarshaller.java
示例4: marshal
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see marshalsec.MarshallerBase#marshal(java.lang.Object)
*/
@Override
public String marshal ( Object o ) throws Exception {
XMLContext context = new XMLContext();
Marshaller m = context.createMarshaller();
StringWriter sw = new StringWriter();
m.setWriter(sw);
return sw.toString();
}
开发者ID:mbechler,项目名称:marshalsec,代码行数:14,代码来源:Castor.java
示例5: unmarshal
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see marshalsec.MarshallerBase#unmarshal(java.lang.Object)
*/
@Override
public Object unmarshal ( String data ) throws Exception {
XMLContext context = new XMLContext();
Unmarshaller unmarshaller = context.createUnmarshaller();
return unmarshaller.unmarshal(new StringReader(data));
}
开发者ID:mbechler,项目名称:marshalsec,代码行数:12,代码来源:Castor.java
示例6: getWriteXmlContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
private XMLContext getWriteXmlContext()
{
String targetVersion = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(
JRXmlBaseWriter.PROPERTY_REPORT_VERSION);
if (log.isDebugEnabled())
{
log.debug("using write mappings for version " + targetVersion);
}
return getXmlContext(CASTOR_WRITE_XML_CONTEXT_KEY, targetVersion);
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:12,代码来源:CastorUtil.java
示例7: getReadXmlContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
private XMLContext getReadXmlContext()
{
return getXmlContext(CASTOR_READ_XML_CONTEXT_KEY, null);//always reading with the last version mappings
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:5,代码来源:CastorUtil.java
示例8: AbstractCastorDataFormat
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
public AbstractCastorDataFormat(XMLContext xmlContext) {
this.xmlContext = xmlContext;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:AbstractCastorDataFormat.java
示例9: setXmlContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
public void setXmlContext(XMLContext xmlContext) {
this.xmlContext = xmlContext;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:AbstractCastorDataFormat.java
示例10: CastorDataFormat
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
public CastorDataFormat(XMLContext xmlContext) {
super(xmlContext);
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:CastorDataFormat.java
示例11: init
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
private void init(String[] springCtxList) {
appCtx = new ClassPathXmlApplicationContext( springCtxList );
xmlContext = (XMLContext) appCtx.getBean(Util.CASTOR_CONTEXT_BEAN);
}
开发者ID:NCIP,项目名称:cagrid-core,代码行数:5,代码来源:Resolver.java
示例12: getContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
/**
* @return the context
*/
public static XMLContext getContext() {
return context;
}
开发者ID:galleon1,项目名称:chocolate-milk,代码行数:7,代码来源:AbstractClient.java
示例13: setContext
import org.exolab.castor.xml.XMLContext; //导入依赖的package包/类
/**
* @param aContext the context to set
*/
public static void setContext(XMLContext aContext) {
context = aContext;
}
开发者ID:galleon1,项目名称:chocolate-milk,代码行数:8,代码来源:AbstractClient.java
注:本文中的org.exolab.castor.xml.XMLContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论