Examples of InsertionOrderedSet


Examples of org.jibx.util.InsertionOrderedSet

        TreeWalker.setLogging(Level.ERROR);
        CodeGenCommandLine parms = new CodeGenCommandLine();
        if (args.length > 0 && parms.processArgs(args)) {
           
            // build set of schemas specified on command line (including via wildcards)
            final InsertionOrderedSet fileset = new InsertionOrderedSet();
            URL base = parms.getSchemaRoot();
            File basedir = parms.getSchemaDir();
            List errors = ResourceMatcher.matchPaths(basedir, base, parms.getExtraArgs(),
                new ResourceMatcher.ReportMatch() {
                    public void foundMatch(String path, URL url) {
                        fileset.add(new UrlResolver(path, url));
                    }
                });
            if (errors.size() > 0) {
                for (Iterator iter = errors.iterator(); iter.hasNext();) {
                    s_logger.error(iter.next());
                }
                System.exit(2);
            }
           
            // handle code generation from schemas
            ProblemMultiHandler handler = new ProblemMultiHandler();
            handler.addHandler(new ProblemConsoleLister());
            handler.addHandler(new ProblemLogLister(s_logger));
            CodeGen inst = new CodeGen(parms.getCustomRoot(), parms.getSchemaRoot(),
                parms.getGeneratePath());
            inst.generate(parms.isVerbose(), parms.getUsingNamespace(), parms.getNonamespacePackage(),
                parms.getBindingName(), fileset.asList(), parms.getIncludePaths(), parms.getModelFile(), handler);
           
        } else {
            if (args.length > 0) {
                s_logger.error("Terminating due to command line or customization errors");
            } else {
View Full Code Here

Examples of org.jibx.util.InsertionOrderedSet

            return null;
        } else {
           
            // scan the item tree structure to find schema components needing special handling
            Map comptoclas = new HashMap();
            InsertionOrderedSet refcomps = new InsertionOrderedSet();
            AnnotatedBase grpcomp = group.getSchemaComponent();
            refcomps.add(grpcomp);
            Map uritoprefix = new HashMap();
            if (grpcomp instanceof INamed) {
                QName qname = ((INamed)grpcomp).getQName();
                if (qname == null && grpcomp instanceof IReference) {
                    qname = ((IReference)grpcomp).getRef();
                }
                if (qname != null && qname.getUri() != null) {
                    uritoprefix.put(qname.getUri(), qname.getPrefix());
                }
            }
            scanItemTree(group, comptoclas, refcomps, uritoprefix);
           
            // get full set of namespaces and corresponding prefixes needed for extracts
            UniqueNameSet prefset = new UniqueNameSet();
            prefset.add(m_schemaPrefix);
            for (Iterator iter = uritoprefix.keySet().iterator(); iter.hasNext();) {
                String uri = (String)iter.next();
                if (!SCHEMA_DEFINITIONS_NS.equals(uri)) {
                    String prefix = (String)uritoprefix.get(uri);
                    if (prefix == null) {
                        prefix = "ns";
                    }
                    prefix = prefset.add(prefix);
                    uritoprefix.put(uri, prefix);
                }
               
            }
           
            // set the writer to be used for output
            StringWriter strwriter = new StringWriter();
            m_context.setOutput(strwriter);
           
            // define namespaces as extension to those used in binding
            int count = uritoprefix.size();
            String[] uris = (String[])uritoprefix.keySet().toArray(new String[count]);
            IXMLWriter xmlwriter = m_context.getXmlWriter();
            int base = xmlwriter.getNamespaceCount();
            xmlwriter.pushExtensionNamespaces(uris);
           
            // build the arrays of namespace indexes and prefixes for use on marshalled root elements
            int length = count;
            if (!uritoprefix.containsKey(null)) {
                length++;
            }
            String[] prefixes = new String[length];
            int[] indexes = new int[length];
            int fill = 0;
            for (int i = 0; i < count; i++) {
                String uri = uris[i];
                if (uri != null) {
                    prefixes[fill] = (String)uritoprefix.get(uris[i]);
                    indexes[fill] = base+fill;
                    fill++;
                }
            }
            prefixes[fill] = m_schemaPrefix;
            indexes[fill] = m_schemaIndex;
           
            // build schema extracts from main component and all referenced components
            String clasname = group.getGenerateClass().getFullName();
            TreeWalker walker = new TreeWalker(null, new SchemaContextTracker());
            boolean ref = false;
            List list = refcomps.asList();
            for (Iterator iter = list.iterator(); iter.hasNext();) {
               
                // add a blank line separating components
                if (ref) {
                    strwriter.write(COMMENT_LEAD_TEXT);
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.