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


Java MappingException类代码示例

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


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

示例1: createXMLContext

import org.exolab.castor.mapping.MappingException; //导入依赖的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: setMapping

import org.exolab.castor.mapping.MappingException; //导入依赖的package包/类
/**
 * Initializes the Castor mapping instance.
 * @param mapping a Castor mapping. Shall not be <code>null</code>.
 * @throws NullPointerException if <code>mapping</code> is <code>null</code>.
 * @throws MappingException an exception indicating an invalid mapping error.
 */
private void setMapping(final Mapping mapping) throws MappingException
{
    _unmarshaller = new Unmarshaller(mapping); // May throw MappingException.
    _unmarshaller.setValidation(false);
    _unmarshaller.setIgnoreExtraElements(true);

    _marshaller = new Marshaller();
    _marshaller.setMapping(mapping); // May throw MappingException.
    _marshaller.setValidation(false);
    //_marshaller.setDebug(true);
    // Specifies whether to support XML namespaces by default. Default is false.
    //_marshaller.setProperty("org.exolab.castor.parser.namespaces", "true");
    // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
    //_marshaller.setProperty("org.exolab.castor.indent", "true");
}
 
开发者ID:LizzyProject,项目名称:Lizzy,代码行数:22,代码来源:XmlSerializer.java

示例3: createXMLContext

import org.exolab.castor.mapping.MappingException; //导入依赖的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: loadMapping

import org.exolab.castor.mapping.MappingException; //导入依赖的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

示例5: getSAXStore

import org.exolab.castor.mapping.MappingException; //导入依赖的package包/类
public static SAXStore getSAXStore(Object value, Mapping mapping, String contentType, String key) throws SAXException, TransformerException, IOException, MappingException {
    if (ScopeProcessorBase.TEXT_PLAIN.equals(contentType)) {
        final SAXStore result = new SAXStore();
        if (value instanceof String) {
            // Creating a stream from the String! Better to extend the ProcessorUtils class to support String or StringReader or something...
            ProcessorUtils.readText((String) value, result, contentType, System.currentTimeMillis());
        } else {
            logger.error("Content-type: " + ScopeProcessorBase.TEXT_PLAIN + " not applicable for key: " + key);
            XMLUtils.streamNullDocument(result);
        }
        return result;
    } else {
        return getSAXStore(value, mapping);
    }
}
 
开发者ID:evlist,项目名称:orbeon-forms,代码行数:16,代码来源:ScopeGenerator.java

示例6: getMapping

import org.exolab.castor.mapping.MappingException; //导入依赖的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

示例7: getMapping

import org.exolab.castor.mapping.MappingException; //导入依赖的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

示例8: getMapping

import org.exolab.castor.mapping.MappingException; //导入依赖的package包/类
/**
 * Retrieves the XML serializer instance associated to the specified package name.
 * The full Castor mapping file name will be <code><i>packageName</i>/mapping.xml</code>.
 * Thus the separator character used in <code>packageName</code> <u>shall be the slash</u> ("<code>/</code>").
 * @param packageName the package name. May be <code>null</code>.
 * @return a <code>XmlSerializer</code> instance. Shall not be <code>null</code>.
 * @throws FileNotFoundException if the mapping file cannot be found.
 * @throws IOException an error occured when reading the mapping file.
 * @throws MappingException the mapping file is invalid.
 * @throws SecurityException if a security manager exists and its <code>checkPermission</code> method denies access to the class loader for the class.
 */
public static XmlSerializer getMapping(final String packageName) throws IOException, MappingException
{
    final StringBuilder sb = new StringBuilder();

    if ((packageName != null) && (packageName.length() > 0))
    {
        sb.append(packageName);
        sb.append('/');
    }

    sb.append("mapping.xml");

    final String mappingFileName = sb.toString();

    synchronized(_mappings)
    {
        XmlSerializer mappingDescriptor = _mappings.get(mappingFileName); // Should not throw NullPointerException.

        if (mappingDescriptor == null)
        {
            mappingDescriptor = new XmlSerializer();
            final URL mappingURL = XmlSerializer.class.getClassLoader().getResource(mappingFileName); // May throw SecurityException.

            if (mappingURL == null)
            {
                // Development error.
                // Shall not occur, since this file is included in the jar.
                // May occur if the jar has been "hacked".
                throw new FileNotFoundException(mappingFileName);
            }

            final Mapping mapping = new Mapping(XmlSerializer.class.getClassLoader());

            // Load the mapping information from the file.
            mapping.loadMapping(mappingURL); // May throw IOException, MappingException.
            mappingDescriptor.setMapping(mapping); // Should not throw NullPointerException. May throw MappingException.

            _mappings.put(mappingFileName, mappingDescriptor); // Should not throw NullPointerException.
        }

        return mappingDescriptor;
    }
}
 
开发者ID:LizzyProject,项目名称:Lizzy,代码行数:55,代码来源:XmlSerializer.java


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