本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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());
}
}
示例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;
}
示例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;
}