Package org.exolab.castor.mapping

Examples of org.exolab.castor.mapping.Mapping


            XMLContext context = new XMLContext();
            InputStream strmMapping = this.getClass().getClassLoader().getResourceAsStream("withmapping-mapping.xml");
            Assert.assertNotNull("InputStream of mapping must not be null", strmMapping);
            InputSource srcMapping = new InputSource(strmMapping);
            Assert.assertNotNull("InputSource of mapping must not be null", srcMapping);
            Mapping mapping = new Mapping();
            mapping.loadMapping(srcMapping);
            context.addMapping(mapping);
            Unmarshaller unmarshaller = context.createUnmarshaller();
            InputStream stream = this.getClass().getClassLoader().getResourceAsStream("withmapping-input.xml");
            Assert.assertNotNull("InputStream must not be null", stream);
            InputSource is = new InputSource(stream);
View Full Code Here


    /**
     * Creates an instance of a Castor XML specific {@link Mapping} instance.
     * @return a Castor XML specific {@link Mapping} instance.
     */
    public Mapping createMapping() {
        Mapping mapping = new Mapping();
//        mapping.setBindingType(BindingType.XML);
        return mapping;
    }
View Full Code Here

        try {
            InputStream strmMapping = this.getClass().getClassLoader().getResourceAsStream("withmapping-mapping.xml");
            Assert.assertNotNull("InputStream of mapping must not be null", strmMapping);
            InputSource srcMapping = new InputSource(strmMapping);
            Assert.assertNotNull("InputSource of mapping must not be null", srcMapping);
            Mapping mapping = new Mapping();
            mapping.loadMapping(srcMapping);
            ClassDescriptorResolver classDescriptorResolver = ClassDescriptorResolverFactory
                    .createClassDescriptorResolver(BindingType.XML);
            MappingUnmarshaller mappingUnmarshaller = new MappingUnmarshaller();
            MappingLoader mappingLoader = mappingUnmarshaller.getMappingLoader(
                    mapping, BindingType.XML);
View Full Code Here

    }

    public Test () throws IOException, MappingException {
       
        // Load the mapping file
        _mapping = new Mapping(getClass().getClassLoader());
        _mapping.loadMapping(getClass().getResource(MAPPING_FILE));

        String jdoConf = getClass().getResource(JDO_CONFIG_FILE).toString();
        JDOManager.loadConfiguration(jdoConf);
        _jdo = JDOManager.createInstance(DATABASE_NAME);
View Full Code Here

     * @throws Exception If any exception occured during unmarshalling of expected result
     *         patterns.
     */
    public static Expected getExpectedResult(final URL expected) throws Exception {
        // 1. Load the mapping information from the file
        Mapping mapping = new Mapping();
        mapping.loadMapping(Expected.class.getResource(MAPPING));
       
        // 2. Unmarshal the data
        Unmarshaller unmar = new Unmarshaller(mapping);
        InputSource source = new InputSource(expected.toExternalForm());
        return (Expected) unmar.unmarshal(source);
View Full Code Here

     */
    protected final void loadData(final String filename) throws Exception {
        Class cls = AbstractGeneratorTest.class;
       
        URL mappingURL = cls.getResource(MAPPING_PATH + filename);
        Mapping mapping = new Mapping();
        mapping.loadMapping(mappingURL);
        new MappingUnmarshaller().loadMappingOnly(mapping);
        // TODO: Joachim 2007-09-07 the InternalContext should be set into the unmarshaller!
        _generator.setMapping(mapping);
        _generator.createSchema();

View Full Code Here

            // Create the unmarshaller
            unmarshaller = new Unmarshaller((Class) null);
            // Only set a mapping if one is specified
            if (mappingpath != null) {
                Mapping mapping;

                try {
                    mapping = loadMapping(mappingpath);
                    unmarshaller.setMapping(mapping);
                } catch (MappingException e) {
View Full Code Here

    private void marshal(Map objectModel, String name, String scope, String mappingpath) {
        try {
            Marshaller marshaller = new Marshaller(new IncludeXMLConsumer(super.contentHandler));
            try {
                Mapping mapping = null;
                if (mappingpath != null) {
                    mapping = loadMapping(mappingpath);
                } else {
                    mapping = defaultMapping;
                }
View Full Code Here

            // Create cache (once) if does not exist
            if (mappings == null) {
                mappings = new HashMap();
            }

            Mapping mapping;
            Source source = resolver.resolveURI(file);
            try {
                mapping = (Mapping) mappings.get(source.getURI());
                if (mapping == null) {
                    // mapping not found in cache or the cache is new
                    mapping = new Mapping();
                    InputSource in = new InputSource(source.getInputStream());
                    mapping.loadMapping(in);
                    mappings.put (source.getURI(), mapping);
                }
            } finally {
                resolver.release(source);
            }
View Full Code Here

        Source source = null;
        try {
      Entry entry;
      String name;
      String mappingSource;
      Mapping mapping;
      Iterator iterator = this.mappingSources.entrySet().iterator();
          while (iterator.hasNext()) {
            entry = (Map.Entry)iterator.next();
            name = (String)entry.getKey();
            mappingSource = (String)entry.getValue();
           
        source = resolver.resolveURI(mappingSource);
        mapping = new Mapping();
        mapping.loadMapping(SourceUtil.getInputSource(source));
        this.mappings.put(name, mapping);
          }
        } finally {
            if (source != null) {
                resolver.release(source);
View Full Code Here

TOP

Related Classes of org.exolab.castor.mapping.Mapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.