Package org.jibx.util

Examples of org.jibx.util.UniqueNameSet


     * @param uri (<code>null</code> if no-namespace schema)
     */
    public SchemaHolder(String uri) {
        super(uri);
        m_schema = new SchemaElement();
        m_typeNameSet = new UniqueNameSet();
        m_elementNameSet = new UniqueNameSet();
        if (uri != null) {
            m_schema.setElementFormDefault(FormChoiceAttribute.QUALIFIED_FORM);
            m_schema.setTargetNamespace(uri);
            m_schema.addNamespaceDeclaration("tns", uri);
        }
View Full Code Here


            Item item = parent.getItem();
            item.setName(m_nameSet.add(m_nameConverter.toBaseName(item.getEffectiveName()) + "Select"));
           
            // create value name set if first time used
            if (m_selectSet == null) {
                m_selectSet = new UniqueNameSet();
            }
           
            // generate constant for each child value
            if (parent.getSchemaComponent().type() == SchemaBase.UNION_TYPE) {
                suffix = "_Form";
View Full Code Here

                }
            }
        }
       
        // define the namespace prefixes to be used (unless otherwise specified at individual binding level)
        UniqueNameSet prefset = new UniqueNameSet();
        Map uridfltpref = new HashMap();
        Map urifrcdpref = buildDefaultPrefixes(prefset, uridfltpref);
      
        // check if only single binding defined
        BindingHolder roothold = null;
        BindingElement rootbind;
        List includes = new ArrayList(pregens);
        if (objs.size() == 1) {
           
            // single binding, just write it using supplied name and added namespaces
            roothold = (BindingHolder)m_objectBindings.get(objs.get(0));
            rootbind = roothold.getBinding();
           
        } else {
           
            // first look for existing binding with supplied name
            for (Iterator iter = objs.iterator(); iter.hasNext();) {
                BindingHolder hold = (BindingHolder)m_objectBindings.get(iter.next());
                if (rootname.equals(hold.getFileName())) {
                    roothold = hold;
                    break;
                }
            }
            if (roothold == null) {
               
                // get or create no namespace binding
                roothold = getBinding(null);
                if (roothold == null) {
                    roothold = addBinding(null, null, "", true);
                }
            }
            rootbind = roothold.getBinding();
           
            // add root binding namespace to set declared at root
            if (roothold.isBindingNamespaceUsed()) {
                String uri = roothold.getNamespace();
                if (uri != null && !MarshallingContext.XML_NAMESPACE.equals(uri)) {
                    m_nsRootUris.add(uri);
                }
            }
           
            // set file names and add to list for root binding
            UniqueNameSet nameset = new UniqueNameSet();
            nameset.add(rootname);
            for (Iterator iter = objs.iterator(); iter.hasNext();) {
                BindingHolder holder = (BindingHolder)m_objectBindings.get(iter.next());
                if (holder != roothold) {
                    if (holder.getFileName() == null) {
                       
                        // get last part of namespace URI as file name candidate
                        String bindname;
                        String raw = holder.getNamespace();
                        if (raw == null) {
                            bindname = "nonamespaceBinding";
                        } else {
                           
                            // strip off protocol and any trailing slash
                            raw = raw.replace('\\', '/');
                            int split = raw.indexOf("://");
                            if (split >= 0) {
                                raw = raw.substring(split + 3);
                            }
                            while (raw.endsWith("/")) {
                                raw = raw.substring(0, raw.length()-1);
                            }
                           
                            // strip off host portion if present and followed by path
                            split = raw.indexOf('/');
                            if (split > 0 && raw.substring(0, split).indexOf('.') > 0) {
                                raw = raw.substring(split+1);
                            }
                           
                            // eliminate any invalid characters in name
                            StringBuffer buff = new StringBuffer();
                            int index = 0;
                            char chr = raw.charAt(0);
                            if (isAsciiAlpha(chr)) {
                                buff.append(chr);
                                index = 1;
                            } else {
                                buff.append('_');
                            }
                            boolean toupper = false;
                            while (index < raw.length()) {
                                chr = raw.charAt(index++);
                                if (isAsciiAlphaNum(chr)) {
                                    if (toupper) {
                                        chr = Character.toUpperCase(chr);
                                        toupper = false;
                                    }
                                    buff.append(chr);
                                } else if (chr == '.') {
                                    toupper = true;
                                } else if (chr == ':' || chr == '/') {
                                    buff.append('_');
                                }
                            }
                            buff.append("Binding");
                            bindname = buff.toString();
                        }
                       
                        // ensure uniqueness of the name
                        holder.setFileName(nameset.add(bindname) + ".xml");
                    }
                   
                    // finish construction of this binding
                    holder.finish(Collections.EMPTY_LIST, Collections.EMPTY_LIST, m_nsRootUris, uridfltpref,
                        urifrcdpref);
View Full Code Here

        m_decorators = decorators;
        m_useInnerClasses = inner;
        m_importsTracker = new ImportsTracker(pack.getName());
        m_outerClass = null;
        m_inners = new LazyList();
        m_nameSet = new UniqueNameSet();
        m_nameSet.add(name);
        m_importsTracker.addLocalType(name, getFullName());
    }
View Full Code Here

        m_decorators = context.m_decorators;
        m_useInnerClasses = true;
        m_importsTracker = context.m_importsTracker;
        m_outerClass = context;
        m_inners = new LazyList();
        m_nameSet = new UniqueNameSet();
        ClassHolder scan = this;
        while (scan != null) {
            m_nameSet.add(scan.getName());
            scan = scan.m_outerClass;
        }
View Full Code Here

        m_generateDirectory = dir;
        m_parentPackage = parent;
        if (m_parentPackage != null) {
            m_parentPackage.m_subpackageCount++;
        }
        m_nameSet = new UniqueNameSet();
        m_classes = new ArrayList();
        m_allClasses = new ArrayList();
    }
View Full Code Here

     * @param map namespace URI to {@link UniqueNameSet} map for category
     * @return <code>true</code> if used, <code>false</code> if not
     */
    private boolean isQNameUsed(QName qname, Map map) {
        if (qname != null) {
            UniqueNameSet nameset = (UniqueNameSet)map.get(qname.getUri());
            if (nameset != null) {
                return nameset.contains(qname.getName());
            }
        }
        return false;
    }
View Full Code Here

     * @return unique version of qualified name
     */
    private QName fixQName(QName qname, Map map) {
        if (qname != null) {
            String uri = qname.getUri();
            UniqueNameSet nameset = (UniqueNameSet)map.get(uri);
            if (nameset == null) {
                nameset = new UniqueNameSet();
                map.put(uri, nameset);
            }
            String base = qname.getName();
            String name = nameset.add(base);
            if (name.equals(base)) {
                return qname;
            } else {
                return new QName(uri, name);
            }
View Full Code Here

                }
            }
            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);
                }
               
            }
           
View Full Code Here

TOP

Related Classes of org.jibx.util.UniqueNameSet

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.