Package org.jibx.schema.elements

Examples of org.jibx.schema.elements.OpenAttrBase


     * @return description
     */
    public static String componentPath(OpenAttrBase comp) {
        StringBuffer buff = new StringBuffer();
        StringBuffer segment = new StringBuffer();
        OpenAttrBase node = comp;
        while (node != null && node.type() != SchemaBase.SCHEMA_TYPE) {
            segment.append(node.name());
            String name;
            OpenAttrBase parent = node.getParent();
            if (node instanceof INamed && (name = ((INamed)node).getName()) != null) {
                segment.append("[@name=");
                segment.append(name);
                segment.append(']');
            } else {
                int index = 1;
                if (parent != null) {
                    for (Iterator iter = parent.getChildIterator(); iter.hasNext();) {
                        OpenAttrBase child = (OpenAttrBase)iter.next();
                        if (child == node) {
                            break;
                        } else if (child.type() == node.type()) {
                            index++;
                        }
                    }
                }
                if (index > 1) {
View Full Code Here


       
        // TODO: remove this once list and union handling fully implemented
        SchemaVisitor visitor = new SchemaVisitor() {
           
            private void replaceSimpleType(OpenAttrBase node) {
                OpenAttrBase parent = node.getParent();
                int count = parent.getChildCount();
                for (int i = 0; i < count; i++) {
                    if (parent.getChild(i) == node) {
                        SimpleRestrictionElement empty = new SimpleRestrictionElement();
                        empty.setBase(SchemaTypes.STRING.getQName());
                        parent.replaceChild(i, empty);
                        return;
                    }
                }
            }
           
View Full Code Here

                if (childgrp.isInline()) {
                    convertToDefinitions(childgrp, defs);
                } else {
                    DefinitionItem def = childgrp.convertToDefinition();
                    def.setChecked(true);
                    OpenAttrBase ancestor = group.getSchemaComponent();
                    while (!ancestor.isGlobal()) {
                        ancestor = ancestor.getParent();
                    }
                    GlobalExtension global = (GlobalExtension)ancestor.getExtension();
                    PackageHolder pack = global.getPackage();
                    String clasname = def.getClassName();
                    NameConverter nconv = global.getNameConverter();
                    boolean useinner = global.isUseInnerClasses();
                    ClassDecorator[] decorators = global.getClassDecorators();
View Full Code Here

            DefinitionItem definition = (DefinitionItem)defs.get(i);
            compactGroups(definition);
           
            // build the binding component for this definition
            ClassHolder clas = (ClassHolder)definition.getGenerateClass();
            OpenAttrBase comp = definition.getSchemaComponent();
            SchemaElement schema = comp.getSchema();
            BindingHolder holder = m_bindingDirectory.getRequiredBinding(schema);
            if (definition.isEnumeration()) {
               
                // construct format and add to binding
                FormatElement format = new FormatElement();
                format.setTypeName(clas.getBindingName());
                format.setQName(definition.getQName());
                ((EnumerationClassHolder)clas).setBinding(format);
                m_bindingDirectory.addFormat(format);
               
            } else {
               
                // construct mapping element
                MappingElementBase mapping = new MappingElement();
                mapping.setClassName(clas.getBindingName());
                if (comp.type() == SchemaBase.ELEMENT_TYPE) {
                   
                    // abstract or concrete mapping for element
                    ElementElement element = (ElementElement)comp;
                    setName(element.getEffectiveQName(), mapping, holder);
                    mapping.setAbstract(element.isAbstract());
View Full Code Here

     * @param comptoclas map from schema component to corresponding {@link ClassHolder}
     * @param refcomps set of schema global definitions incorporated into this tree
     * @param uritoprefix map from namespaces used by referenced definitions to the corresponding prefixes
     */
    private void scanItemTree(GroupItem group, Map comptoclas, Set refcomps, Map uritoprefix) {
        OpenAttrBase topcomp = group.getSchemaComponent();
        for (Item item = group.getFirstChild(); item != null; item = item.getNext()) {
            if (!item.isIgnored()) {
               
                // start by checking if we've crossed into a different schema definition
                OpenAttrBase comp = item.getSchemaComponent();
                while (comp != topcomp) {
                    if (comp.isGlobal()) {
                        if (!(item instanceof ReferenceItem)) {
                            refcomps.add(comp);
                        }
                        QName qname = ((INamed)comp).getQName();
                        if (qname == null) {
                            throw new IllegalStateException("Internal error - no name on global definition");
                        } else {
                            uritoprefix.put(qname.getUri(), qname.getPrefix());
                        }
                        break;
                    } else {
                        comp = comp.getParent();
                    }
                }
               
                // now check the actual item type
                if (item instanceof GroupItem) {
                   
                    // check non-inlined group which uses separate class
                    GroupItem childgroup = (GroupItem)item;
                    if (!childgroup.isIgnored()) {
                        if (childgroup.isInline()) {
                            scanItemTree(childgroup, comptoclas, refcomps, uritoprefix);
                        } else {
                           
                            // add component to class mapping to stop schema fragment generation when reached
                            TypeData genclas = childgroup.getGenerateClass();
                            if (genclas == null) {
                                throw new IllegalStateException("Internal error - no generate class");
                            } else {
                                comptoclas.put(childgroup.getSchemaComponent(), genclas);
                            }
                           
                            // check for type definition or reference used (with associated namespace reference)
                            QName tname = null;
                            comp = item.getSchemaComponent();
                            switch (comp.type()) {
                                case SchemaBase.ATTRIBUTE_TYPE:
                                    tname = ((AttributeElement)comp).getType();
                                    break;
                                case SchemaBase.ELEMENT_TYPE:
                                    tname = ((ElementElement)comp).getType();
View Full Code Here

TOP

Related Classes of org.jibx.schema.elements.OpenAttrBase

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.