Examples of BindingElement


Examples of org.jibx.binding.model.BindingElement

        boolean valid = true;
        ClassFile cf = null;
        String tpack = null;
        String bname = null;
        if (test) {
            BindingElement root = validateBinding(fname, url,
                new ByteArrayInputStream(data));
            if (root == null) {
                valid = false;
            } else {
               
                // find package of first mapping to use for added classes
                cf = findMappedClass(root);
                tpack = root.getTargetPackage();
                if (tpack == null && cf != null) {
                    tpack = cf.getPackage();
                }
                bname = root.getName();
               
            }
        }
        if (valid) {
            try {
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

                    }
                   
                } else if (child instanceof IncludeElement) {
                   
                    // recurse on included binding
                    BindingElement bind = ((IncludeElement)child).getBinding();
                    if (bind != null) {
                        ClassFile cf = findMappedClass(bind);
                        if (cf != null) {
                            return cf;
                        }
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

                try {
                    URL url = new URL("file://" + file.getAbsolutePath());
                    FileInputStream is = new FileInputStream(file);
                    try {
                        ValidationContext vctx = new ValidationContext(parms.getLocator());
                        BindingElement binding = BindingElement.validateBinding(name, url, is, vctx);
                        if (vctx.getErrorCount() == 0 && vctx.getFatalCount() == 0) {
                            bindings.add(binding);
                        } else {
                            valid = false;
                        }
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

       
        // validate the root binding (which will pull in all referenced bindings)
        File file = new File(dir, root.getFileName());
        ValidationContext vctx = new ValidationContext(loc);
        FileInputStream is = new FileInputStream(file);
        BindingElement binding = BindingElement.validateBinding(root.getFileName(), file.toURI().toURL(), is, vctx);
        if (binding == null || vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) {
            return null;
        } else {
           
            // build and return list of validated binding definitions
            List uris = m_directory.getKeys();
            List bindings = new ArrayList();
            bindings.add(binding);
            URL base = dir.toURI().toURL();
            for (Iterator iter = uris.iterator(); iter.hasNext();) {
                String uri = (String)iter.next();
                BindingHolder hold = getBinding(uri);
                if (hold != root) {
                    URL url = new URL(base, hold.getFileName());
                    if (binding.addIncludePath(url.toExternalForm(), false)) {
                        throw new IllegalStateException("Binding not found when read from file");
                    } else {
                        bindings.add(binding.getExistingIncludeBinding(url));
                    }
                }
            }
            return bindings;
        }
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

                        } else {
                            file = new File(path);
                            url = file.toURI().toURL();
                        }
                        try {
                            BindingElement binding = processPregeneratedBinding(url, elemmap, typemap, handler);
                            if (!usenns) {
                                usenns = checkNoNamespace(binding);
                            }
                            try {
                                org.jibx.binding.model.IncludeElement include =
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

        for (int i = 0; i < childs.size(); i++) {
            ElementBase element = (ElementBase)childs.get(i);
            if (element.type() == ElementBase.INCLUDE_ELEMENT) {
               
                // use recursive call to add nested definitions in included binding
                BindingElement inclbinding = ((org.jibx.binding.model.IncludeElement)element).getBinding();
                if (inclbinding != null) {
                    accumulateBindingDefinitions(inclbinding, elemmap,
                        typemap);
                }
               
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

        }
       
        // construct object model for binding
        org.jibx.binding.model.ValidationContext vctx =
            new org.jibx.binding.model.ValidationContext(new DummyClassLocator());
        BindingElement binding = BindingElement.readBinding(url.openStream(), name, null, true,
            vctx);
        binding.setBaseUrl(url);
        vctx.setBindingRoot(binding);
       
        // validate the binding definition
        binding.runValidation(vctx);
       
        // list validation errors
        if (vctx.getProblems().size() > 0) {
            reportBindingProblems(vctx, handler);
            if (vctx.getErrorCount() > 0 || vctx.getFatalCount() > 0) {
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

                   
                    // read binding from file
                    String bpath = (String)bindings.get(i);
                    String name = Utility.fileName(bpath);
                    File file = new File(bpath);
                    BindingElement binding = Utility.validateBinding(name,
                        new URL("file://" + file.getAbsolutePath()),
                        new FileInputStream(file));
                   
                    // convert the binding to a schema
                    if (binding != null) {
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

           
            // set flag for unwrapping
            boolean unwrap = !codeGenConfig.isParametersWrapped();
           
            // initialize the binding information
            BindingElement binding = null;
            if (file == null) {
               
                // unwrapped can be used without a binding, but wrapped requires one
                if (!unwrap) {
                    throw new RuntimeException("JiBX wrapped support requires a binding definition to be provided using the -E" +
                        JiBXExtension.BINDING_PATH_OPTION + " {file-path} parameter");
                }
               
            } else {
               
                // Read the JiBX binding definition into memory. The binding definition
                // is only prevalidated so as not to require the user to have all
                // the referenced classes in the classpath, though this does make for
                // added work in finding the namespaces.
                ValidationContext vctx = BindingElement.newValidationContext();
                binding = BindingElement.readBinding(new FileInputStream(file), path, vctx);
                binding.setBaseUrl(file.toURL());
                vctx.setBindingRoot(binding);
                IncludePrevalidationVisitor ipv = new IncludePrevalidationVisitor(vctx);
                vctx.tourTree(binding, ipv);
                if (vctx.getErrorCount() != 0 || vctx.getFatalCount() != 0) {
                    throw new RuntimeException("invalid jibx binding definition file " + path);
                }
            }
           
            // create table with all built-in format definitions
            Map simpleTypeMap = new HashMap();
            buildFormat("byte", "byte",
                "org.jibx.runtime.Utility.serializeByte",
                "org.jibx.runtime.Utility.parseByte", "0", simpleTypeMap);
            buildFormat("unsignedShort", "char",
                "org.jibx.runtime.Utility.serializeChar",
                "org.jibx.runtime.Utility.parseChar", "0", simpleTypeMap);
            buildFormat("double", "double",
                "org.jibx.runtime.Utility.serializeDouble",
                "org.jibx.runtime.Utility.parseDouble", "0.0", simpleTypeMap);
            buildFormat("float", "float",
                "org.jibx.runtime.Utility.serializeFloat",
                "org.jibx.runtime.Utility.parseFloat", "0.0", simpleTypeMap);
            buildFormat("int", "int",
                "org.jibx.runtime.Utility.serializeInt",
                "org.jibx.runtime.Utility.parseInt", "0", simpleTypeMap);
            buildFormat("long", "long",
                "org.jibx.runtime.Utility.serializeLong",
                "org.jibx.runtime.Utility.parseLong", "0", simpleTypeMap);
            buildFormat("short", "short",
                "org.jibx.runtime.Utility.serializeShort",
                "org.jibx.runtime.Utility.parseShort", "0", simpleTypeMap);
            buildFormat("boolean", "boolean",
                "org.jibx.runtime.Utility.serializeBoolean",
                "org.jibx.runtime.Utility.parseBoolean", "false",
                simpleTypeMap);
            buildFormat("dateTime", "java.util.Date",
                "org.jibx.runtime.Utility.serializeDateTime",
                "org.jibx.runtime.Utility.deserializeDateTime", null,
                simpleTypeMap);
            buildFormat("date", "java.sql.Date",
                "org.jibx.runtime.Utility.serializeSqlDate",
                "org.jibx.runtime.Utility.deserializeSqlDate", null,
                simpleTypeMap);
            buildFormat("time", "java.sql.Time",
                "org.jibx.runtime.Utility.serializeSqlTime",
                "org.jibx.runtime.Utility.deserializeSqlTime", null,
                simpleTypeMap);
            buildFormat("base64Binary", "byte[]",
                "org.jibx.runtime.Utility.serializeBase64",
                "org.jibx.runtime.Utility.deserializeBase64", null,
                simpleTypeMap);
            buildFormat("string","java.lang.String", null, null, null,
                simpleTypeMap);
           
            // collect all the top-level mapping and format definitions
            Map elementMap = new HashMap();
            Map complexTypeMap = new HashMap();
            Map bindingMap = new HashMap();
            if (binding != null) {
                collectTopLevelComponents(binding, null, elementMap,
                    complexTypeMap, simpleTypeMap, bindingMap);
            }
           
            // make sure classes will be generated for abstract mappings
            if (unwrap && complexTypeMap.size() > 0 && !binding.isForceClasses()) {
                throw new RuntimeException("unwrapped binding must use force-classes='true' option in " + path);
            }
           
            // force off inappropriate option (set by error in options handling)
            codeGenConfig.setPackClasses(false);
View Full Code Here

Examples of org.jibx.binding.model.BindingElement

                               break;
                            }
                        }
                       
                        // also merge namespace definitions from binding
                        BindingElement binding = (BindingElement)bindingMap.get(mapping);
                        citer = binding.topChildIterator();
                        while (citer.hasNext()) {
                            ElementBase child = (ElementBase)citer.next();
                            if (child.type() == ElementBase.NAMESPACE_ELEMENT) {
                                dfltns = mapNamespace((NamespaceElement)child, dfltns, nsmap);
                            } else if (child.type() != ElementBase.INCLUDE_ELEMENT) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.