当前位置: 首页>>代码示例>>Java>>正文


Java Mapping.loadMapping方法代码示例

本文整理汇总了Java中org.exolab.castor.mapping.Mapping.loadMapping方法的典型用法代码示例。如果您正苦于以下问题:Java Mapping.loadMapping方法的具体用法?Java Mapping.loadMapping怎么用?Java Mapping.loadMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.exolab.castor.mapping.Mapping的用法示例。


在下文中一共展示了Mapping.loadMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createXMLContext

import org.exolab.castor.mapping.Mapping; //导入方法依赖的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.mapping.Mapping; //导入方法依赖的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.mapping.Mapping; //导入方法依赖的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: convertStringToXml

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
/**
 * Convert String To XML.
 * @param xmlString String.
 * @return BulkOperationMetaData.
 * @throws BulkOperationException BulkOperationException.
 */
public BulkOperationMetaData convertStringToXml(String xmlString)
	throws BulkOperationException
{
	BulkOperationMetaData bulkOperationMetaData = null;
	try
	{
		InputSource inputSource = new InputSource(new StringReader(xmlString));
		String mappingFilePath = CommonServiceLocator.getInstance().getPropDirPath()
				+ File.separator + "mapping.xml";
		Mapping mapping = new Mapping();
		mapping.loadMapping(mappingFilePath);
		Unmarshaller unMarshaller = new Unmarshaller(BulkOperationMetaData.class);
		unMarshaller.setMapping(mapping);
		bulkOperationMetaData = (BulkOperationMetaData) unMarshaller.unmarshal(inputSource);
	}
	catch (Exception exp)
	{
		logger.error(exp.getMessage(), exp);
		ErrorKey errorkey = ErrorKey.getErrorKey("bulk.operation.issues");
		throw new BulkOperationException(errorkey, exp, exp.getMessage());
	}
	return bulkOperationMetaData;
}
 
开发者ID:NCIP,项目名称:catissue-migration-tool,代码行数:30,代码来源:BulkOperationBizLogic.java

示例5: convertAttributeValue

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
protected SequenceIterator convertAttributeValue(XPathContext xpathContext, Object attributeObject, String contentType, String key) throws XPathException {
    if (attributeObject instanceof AtomicValue) {
        // Found atomic value
        // NOTE: This can be a XXFormsSetScopeAttribute.StringValueWithEquals
        return SingletonIterator.makeIterator((AtomicValue) attributeObject);
    } else if (attributeObject != null) {
        // Found something else, hopefully convertible to SAXStore
        final SAXStore saxStore;
        try {
            // We don't have any particular mappings to pass to serialize objects
            final Mapping mapping = new Mapping();
            mapping.loadMapping(new InputSource(new StringReader("<mapping/>")));

            saxStore = ScopeGenerator.getSAXStore(attributeObject, mapping, contentType, key);
        } catch (Exception e) {
            throw new OXFException(e);
        }
        // Convert to DocumentInfo
        final DocumentInfo documentInfo = TransformerUtils.saxStoreToTinyTree(xpathContext.getConfiguration(), saxStore);
        return SingletonIterator.makeIterator(documentInfo);
    } else {
        // Empty result
        return EmptyIterator.getInstance();
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:26,代码来源:XXFormsGetScopeAttribute.java

示例6: loadMapping

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
/**
 *
 */
private void loadMapping(Mapping mapping, String mappingFile)
{
	try
	{
		byte[] mappingFileData = JRLoader.loadBytesFromResource(mappingFile);
		InputSource mappingSource = new InputSource(new ByteArrayInputStream(mappingFileData));

		mapping.loadMapping(mappingSource);
	}
	catch (JRException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:CastorUtil.java

示例7: loadMapping

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
private Mapping loadMapping() throws IOException, MappingException {
	InputStream inputstream = null;
	
	try {
		inputstream = CastorXMLSerializer.class.getClassLoader().getResourceAsStream(MAPPING_FILE_LOCATION);
		Mapping mapping = new Mapping();
		mapping.loadMapping(new InputSource(inputstream));
		return mapping;
		
	} finally {
		IOUtils.closeQuietly(inputstream);
		
	}
}
 
开发者ID:neopeak,项目名称:brownsocks-payments-enets,代码行数:15,代码来源:CastorXMLSerializer.java

示例8: loadMappingFromString

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
protected static Mapping loadMappingFromString(String mappingLocation,
        String mappingContents, EntityResolver resolver) {
    InputSource mappIS = new org.xml.sax.InputSource(new StringReader(mappingContents));
    Mapping mapping = new Mapping();
    mapping.setEntityResolver(resolver);
    try {
        mapping.loadMapping(mappIS);
    } catch (Exception ex) {
        LOG.error("Error loading castor mapping (" 
            + mappingLocation + "): " + ex.getMessage(), ex);
    }
    return mapping;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:14,代码来源:SDK44EncodingUtils.java

示例9: getMapping

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
private static Mapping getMapping() throws Exception {
    // load the mapping
    Mapping map = new Mapping();
    map.setEntityResolver(Cql2SerialzationHelper.getDtdResolver());
    try {
        map.loadMapping(new InputSource(Cql2SerialzationHelper.getMappingStream()));
    } catch (IOException ex) {
        String error = "Error loading CQL 2 castor mapping: " + ex.getMessage();
        LOG.error(error, ex);
        throw new SAXException(error, ex);
    }
    return map;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:14,代码来源:Cql2SerialzationHelper.java

示例10: loadMappingFromString

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
protected static Mapping loadMappingFromString(String mappingLocation, String mappingContents,
    EntityResolver resolver) {
    InputSource mappIS = new org.xml.sax.InputSource(new StringReader(mappingContents));
    Mapping mapping = new Mapping();
    mapping.setEntityResolver(resolver);
    try {
        mapping.loadMapping(mappIS);
    } catch (Exception ex) {
        LOG.error("Error loading castor mapping (" + mappingLocation + "): " + ex.getMessage(), ex);
    }
    return mapping;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:13,代码来源:SDK40EncodingUtils.java

示例11: loadMappingFromStream

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
private static Mapping loadMappingFromStream(String mappingLocation, InputStream mappingStream,
    EntityResolver resolver) {
    InputSource mappIS = new org.xml.sax.InputSource(mappingStream);
    Mapping mapping = new Mapping();
    mapping.setEntityResolver(resolver);
    try {
        mapping.loadMapping(mappIS);
    } catch (Exception ex) {
        LOG.error("Error loading castor mapping (" + mappingLocation + "): " + ex.getMessage(), ex);
    }
    return mapping;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:13,代码来源:EncodingUtils.java

示例12: loadListFromFile

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
private void loadListFromFile() {
	log.debug("Loading TempleList...");

	try {
	  Mapping mapping = new Mapping();

	  // 1. Load the mapping information from the file
	  mapping.loadMapping(NSBundle.mainBundle().resourcePath() + "/temple-mapping.xml");

	  // 2. Unmarshal the data
	  Unmarshaller unmar = new Unmarshaller(mapping);
	  TempleXML tempList = (TempleXML) unmar.unmarshal(new InputSource(new FileReader(NSBundle.mainBundle().
		  resourcePath() + "/TempleList.xml")));
//           instance = (TempleList)unmar.unmarshal(new InputSource(new FileReader(NSBundle.mainBundle().resourcePath()+"/TempleList.xml")));
	  setTempleList(tempList.getTempleList());

	  // 3. Do some processing on the data
	  // 4. marshal the data with the total price back and print the XML in the console
//            Marshaller marshaller = new Marshaller(new OutputStreamWriter(System.out));
//            marshaller.setMapping(mapping);
//            marshaller.marshal(order);

	}
	catch (Throwable e) {
	  e.printStackTrace();
	  log.error("Could not load TempleList", e);
	  return;
	}
  }
 
开发者ID:MaddTheSane,项目名称:MacPaf,代码行数:30,代码来源:TempleList.java

示例13: sendReport

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
public void sendReport(Object reportObject, String castorPropertyName, String url, boolean sendAsychronously,
		ITransmissionResponseHandler responseHandler) {
	
	String xmlString = null;
	String castorMappingName = getCastorMappingName(castorPropertyName);

	InputSource source = getSource(castorMappingName);

	Mapping castorMapping = new Mapping();
	try {
		castorMapping.loadMapping(source);

		Marshaller marshaller = new Marshaller();
		marshaller.setMapping(castorMapping);
		Writer writer = new StringWriter();
		marshaller.setWriter(writer);
		marshaller.marshal(reportObject);
		xmlString = writer.toString();
		 
		sendRawReport(xmlString, url, sendAsychronously, responseHandler, HTTP_TYPE.POST);
		
	}catch (UnknownHostException he) {
		List<String> errors = new ArrayList<String>();
		errors.add(he.toString());
		responseHandler.handleResponse(HttpServletResponse.SC_BAD_REQUEST, errors, xmlString);
	} catch (Exception e) {
		LogEvent.logError("ReportTransmission ", "sendResults()", e.toString());
	}

}
 
开发者ID:openelisglobal,项目名称:openelisglobal-sandbox,代码行数:31,代码来源:ReportTransmission.java

示例14: getMapping

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
private static Mapping getMapping() throws IOException, MappingException {
	URL url = Configuration.class.getResource("castor-config-mapping.xml");
	Mapping mapping = new Mapping();
	mapping.loadMapping(url);
	return mapping;
}
 
开发者ID:realrolfje,项目名称:anonimatron,代码行数:7,代码来源:Configuration.java

示例15: getMapping

import org.exolab.castor.mapping.Mapping; //导入方法依赖的package包/类
private static Mapping getMapping() throws IOException, MappingException {
	URL url = SynonymMapper.class.getResource("castor-synonym-mapping.xml");
	Mapping mapping = new Mapping();
	mapping.loadMapping(url);
	return mapping;
}
 
开发者ID:realrolfje,项目名称:anonimatron,代码行数:7,代码来源:SynonymMapper.java


注:本文中的org.exolab.castor.mapping.Mapping.loadMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。