Package org.exolab.castor.builder.binding.xml

Examples of org.exolab.castor.builder.binding.xml.Binding


     * @throws BindingException
     *             thrown when an error occurred during the unmarshalling.
     */
    @SuppressWarnings("unchecked")
    public void loadBinding(final InputSource source) throws BindingException {
        Binding loaded = null;
        if (_binding == null) {
            _binding = new ExtendedBinding();
        }

        //do not use the static method to ensure validation is turned on
        Unmarshaller unmarshaller = new Unmarshaller(Binding.class);
        unmarshaller.setValidation(true);

        try {
            loaded = (Binding) unmarshaller.unmarshal(source);

            //--Copy one by one the components loaded in the root binding
            _binding.setDefaultBindingType(loaded.getDefaultBindingType());

            //--packages
            Enumeration<PackageType> packages = loaded.enumeratePackage();
            while (packages.hasMoreElements()) {
                PackageType tempPackage = packages.nextElement();
                _binding.addPackage(tempPackage);
            }

            //--NamingXML
            NamingXMLType naming = loaded.getNamingXML();
            if (naming != null) {
                _binding.setNamingXML(naming);
            }

            //--NamingXML
            AutomaticNamingType automaticNaming = loaded.getAutomaticNaming();
            if (automaticNaming != null) {
                _binding.setAutomaticNaming(automaticNaming);
                _binding.handleAutomaticNaming(automaticNaming);
            }
           
            //--elementBindings
            Enumeration<ComponentBindingType> elements = loaded.enumerateElementBinding();
            while (elements.hasMoreElements()) {
                ComponentBindingType tempComp = elements.nextElement();
                _binding.addElementBinding(tempComp);
            }

            //--attributeBindings
            Enumeration<ComponentBindingType> attributes = loaded.enumerateAttributeBinding();
            while (attributes.hasMoreElements()) {
                ComponentBindingType  tempComp = attributes.nextElement();
                _binding.addAttributeBinding(tempComp);
            }

            //--ComplexTypeBindings
            Enumeration<ComponentBindingType> complexTypes = loaded.enumerateComplexTypeBinding();
            while (complexTypes.hasMoreElements()) {
                ComponentBindingType tempComp = complexTypes.nextElement();
                _binding.addComplexTypeBinding(tempComp);
            }

            //--SimpleTypeBindings
            Enumeration<ComponentBindingType> sts = loaded.enumerateSimpleTypeBinding();
            while (sts.hasMoreElements()) {
                ComponentBindingType tempComp = sts.nextElement();
                _binding.addSimpleTypeBinding(tempComp);
            }

            //--groupBindings
            Enumeration<ComponentBindingType> groups = loaded.enumerateGroupBinding();
            while (groups.hasMoreElements()) {
                ComponentBindingType tempComp = groups.nextElement();
                _binding.addGroupBinding(tempComp);
            }

            //--enumBinding
            Enumeration<ComponentBindingType> enums = loaded.enumerateEnumBinding();
            while (enums.hasMoreElements()) {
                ComponentBindingType tempEnum = enums.nextElement();
                _binding.addEnumBinding(tempEnum);
            }

            //--included schemas
            Enumeration<IncludeType> includes = loaded.enumerateInclude();
            while (includes.hasMoreElements()) {
                IncludeType tempInclude = includes.nextElement();
                try {
                    loadBinding(tempInclude.getURI());
                } catch (Exception except) {
View Full Code Here

TOP

Related Classes of org.exolab.castor.builder.binding.xml.Binding

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.