Package org.jibx.schema.elements

Examples of org.jibx.schema.elements.SimpleRestrictionElement


        GroupItem group = (GroupItem)item;
        AnnotatedBase comp = group.getFirstChild().getSchemaComponent();
        if (comp.type() == SchemaBase.SIMPLETYPE_TYPE) {
            comp = (AnnotatedBase)((SimpleTypeElement)comp).getDerivation();
        }
        SimpleRestrictionElement restrict = (SimpleRestrictionElement)comp;
        FilteredSegmentList facets = restrict.getFacetsList();
        if (java5) {
            buildJava5Enumeration(name, fullname, facets, clasbuilder);
        } else {
            buildSimpleEnumeration(name, fullname, facets, clasbuilder);
        }
View Full Code Here


            public void exit(UnionElement 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);
                        break;
                    }
                }
            }
View Full Code Here

                    case SchemaBase.RESTRICTION_TYPE:
                    {
                        if (childcomp instanceof SimpleRestrictionElement) {
                           
                            // replace simple type restriction with base type unless it has facets
                            SimpleRestrictionElement restrict = (SimpleRestrictionElement)childcomp;
                            if (restrict.getFacetsList().size() == 0 && restrict.getBase() != null) {
                                QName base = restrict.getBase();
                                if (base == null) {
                                   
                                    // derivation using inline base type, just eliminate the restriction
                                   
                                } else {
                                    modified = substituteTypeDerivation(lead, topcomp, childcomp, restrict);
                                }
                            }
                           
                        } else {
                           
                            // always replace complex type restriction with base type
                            ComplexRestrictionElement restrict = (ComplexRestrictionElement)child;
                            modified = substituteTypeDerivation(lead, topcomp, childcomp, restrict);
                           
                        }
                        break;
                    }
                }
               
                // delete child component if flagged for removal
                if (childext.isRemoved()) {
                    removeChild(i);
                    compact = true;
                }
            }
        }
        if (compact) {
            topcomp.compactChildren();
            modified = true;
        }
       
        // handle union normalization after all children have been normalized
        if (topcomp.type() == SchemaBase.UNION_TYPE) {
           
            // start by checking duplicates in the member types
            compact = false;
            UnionElement union = (UnionElement)topcomp;
            Set typeset = new HashSet();
            ArrayList keeptypes = new ArrayList();
            QName[] membertypes = union.getMemberTypes();
            if (membertypes != null) {
                for (int i = 0; i < membertypes.length; i++) {
                    QName type = membertypes[i];
                    if (typeset.contains(type)) {
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug(lead + "removed redundant member type " + type + " from " + path);
                        }
                    } else {
                        typeset.add(type);
                        keeptypes.add(type);
                    }
                }
            }
           
            // then check inline types for duplicates, simplifying where possible
            count = union.getChildCount();
            for (int i = 0; i < count; i++) {
                SchemaBase child = topcomp.getChild(i);
                if (child instanceof OpenAttrBase) {
                   
                    // child schema component must be an inline simple type definition
                    SimpleTypeElement simple = (SimpleTypeElement)child;
                    boolean keeper = false;
                    SchemaBase derivation = simple.getDerivation();
                    QName repltype = null;
                    if (derivation != null) {
                       
                        // keep the inline definition by default, but check for replacement cases
                        keeper = true;
                        if (derivation.type() == SchemaBase.RESTRICTION_TYPE) {
                            SimpleRestrictionElement innerrestrict = (SimpleRestrictionElement)derivation;
                            if (innerrestrict.getChildCount() == 0) {
                               
                                // treat empty restriction the same as a member type from list
                                repltype = innerrestrict.getBase();
                                if (typeset.contains(repltype)) {
                                    keeper = false;
                                }
                               
                            }
View Full Code Here

                namemeth.setAccessible(true);
            } catch (RuntimeException e) { /* deliberately empty */
            }
            Object[] values = (Object[])valsmeth.invoke(null, (Object[])null);
            SimpleTypeElement simple = new SimpleTypeElement();
            SimpleRestrictionElement restr = new SimpleRestrictionElement();
            restr.setBase(Types.STRING_QNAME);
            for (int i = 0; i < values.length; i++) {
                Enumeration enumel = new Enumeration();
                enumel.setValue(namemeth.invoke(values[i], (Object[])null).toString());
                restr.getFacetsList().add(enumel);
            }
            simple.setDerivation(restr);
            addDocumentation(detail.getCustom().getClassInformation(), simple);
            return simple;
        } catch (SecurityException e) {
View Full Code Here

            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

     */
    public static boolean isEnumeration(AnnotatedBase comp) {
        if (comp.type() == SchemaBase.SIMPLETYPE_TYPE) {
            SimpleTypeElement type = (SimpleTypeElement)comp;
            if (type.getDerivation().type() == SchemaBase.RESTRICTION_TYPE) {
                SimpleRestrictionElement restrict = (SimpleRestrictionElement)type.getDerivation();
                FilteredSegmentList facets = restrict.getFacetsList();
                for (int i = 0; i < facets.size(); i++) {
                    FacetElement facet = (FacetElement)facets.get(i);
                    if (facet.type() == SchemaBase.ENUMERATION_TYPE) {
                        return true;
                    }
View Full Code Here

TOP

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

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.