Package com.sun.xml.xsom

Examples of com.sun.xml.xsom.XSType


                // Use XML schema object model to determine if field is mapped
                // from an element (attributes default values are handled
                // natively) and get its default value.
                XmlString xmlDefaultValue = null;
                XSType xsType = null;
                boolean isElement = false;
                boolean isRequiredAttr = true;
                if (f.getPropertyInfo().getSchemaComponent() instanceof XSParticle) {
                    XSParticle particle = (XSParticle)f.getPropertyInfo().getSchemaComponent();
                    XSTerm term = particle.getTerm();
                    XSElementDecl element = null;

                    if (term.isElementDecl()) {
                        element = particle.getTerm().asElementDecl();
                        xmlDefaultValue = element.getDefaultValue();                       
                        xsType = element.getType();
                        isElement = true;
                    }
                } else if (f.getPropertyInfo().getSchemaComponent() instanceof XSAttributeUse) {
                    XSAttributeUse attributeUse = (XSAttributeUse)f.getPropertyInfo().getSchemaComponent();
                    XSAttributeDecl decl = attributeUse.getDecl();
                    xmlDefaultValue = decl.getDefaultValue();                       
                    xsType = decl.getType();
                    isRequiredAttr = attributeUse.isRequired();
                }

               
                if (xsType != null && xsType.isComplexType() && containsDefaultValue(outline, f)) {
                    String varName = f.getPropertyInfo().getName(false);
                    JFieldVar var = co.implClass.fields().get(varName);
                    if (var != null) {
                        co.implClass.removeField(var);

                        JFieldVar newVar = co.implClass.field(var.mods().getValue(),
                                                              var.type(),
                                                              var.name(),
                                                              JExpr._new(f.getRawType()));
                        newVar.javadoc().append(var.javadoc());
                    }
                }

                JExpression dvExpr = null;
                if (null != xmlDefaultValue && null != xmlDefaultValue.value) {
                    dvExpr = getDefaultValueExpression(f, co, outline, xsType, isElement,
                                                       xmlDefaultValue, false);
                }
                
                if (null == dvExpr
                    && !isElement && !isRequiredAttr
                    && xsType != null && xsType.getOwnerSchema() != null
                    && !"http://www.w3.org/2001/XMLSchema"
                        .equals(xsType.getOwnerSchema().getTargetNamespace())) {
                    //non-primitive attribute, may still be able to convert it, but need to do
                    //a bunch more checks and changes to setters and isSet and such
                    dvExpr =
                        getDefaultValueExpression(f, co, outline, xsType, isElement, xmlDefaultValue, true);
                   
View Full Code Here


                // Use XML schema object model to determine if field is mapped
                // from an element (attributes default values are handled
                // natively) and get its default value.
                XmlString xmlDefaultValue = null;
                XSType xsType = null;
                boolean isElement = false;
                boolean isRequiredAttr = true;
                if (f.getPropertyInfo().getSchemaComponent() instanceof XSParticle) {
                    XSParticle particle = (XSParticle)f.getPropertyInfo().getSchemaComponent();
                    XSTerm term = particle.getTerm();
                    XSElementDecl element = null;

                    if (term.isElementDecl()) {
                        element = particle.getTerm().asElementDecl();
                        xmlDefaultValue = element.getDefaultValue();                       
                        xsType = element.getType();
                        isElement = true;
                    }
                } else if (f.getPropertyInfo().getSchemaComponent() instanceof XSAttributeUse) {
                    XSAttributeUse attributeUse = (XSAttributeUse)f.getPropertyInfo().getSchemaComponent();
                    XSAttributeDecl decl = attributeUse.getDecl();
                    xmlDefaultValue = decl.getDefaultValue();                       
                    xsType = decl.getType();
                    isRequiredAttr = attributeUse.isRequired();
                }

               
                if (xsType != null && xsType.isComplexType() && containsDefaultValue(outline, f)) {
                    String varName = f.getPropertyInfo().getName(false);
                    JFieldVar var = co.implClass.fields().get(varName);
                    if (var != null) {
                        co.implClass.removeField(var);

                        JFieldVar newVar = co.implClass.field(var.mods().getValue(),
                                                              var.type(),
                                                              var.name(),
                                                              JExpr._new(f.getRawType()));
                        newVar.javadoc().append(var.javadoc());
                    }
                }

                JExpression dvExpr = null;
                if (null != xmlDefaultValue && null != xmlDefaultValue.value) {
                    dvExpr = getDefaultValueExpression(f, co, outline, xsType, isElement,
                                                       xmlDefaultValue, false);
                }
                
                if (null == dvExpr
                    && !isElement && !isRequiredAttr
                    && xsType != null && xsType.getOwnerSchema() != null
                    && !"http://www.w3.org/2001/XMLSchema"
                        .equals(xsType.getOwnerSchema().getTargetNamespace())) {
                    //non-primitive attribute, may still be able to convert it, but need to do
                    //a bunch more checks and changes to setters and isSet and such
                    dvExpr =
                        getDefaultValueExpression(f, co, outline, xsType, isElement, xmlDefaultValue, true);
                   
View Full Code Here

          XSTerm pterm = p.getTerm();
          if(pterm.isElementDecl()){
            XSElementDecl element = pterm.asElementDecl();
            String name = element.getName();
            log.debug(name);
            XSType type = element.getType();

            while(type != null) {
              String typeName = type.getName();
              if(typeName != null &&(typeName.equals("long") ||
                  typeName.equals("string") ||
                  typeName.equals("integer") ||
                  typeName.equals("float") ||
                  typeName.endsWith("_type"))) {
                log.debug(typeName);
                flds.put(name, typeName);
                break;
              }
              type = type.getBaseType();
            }
          }
        }
      }
    }
View Full Code Here

      XSElementDecl element = schema.getElementDecl(file.getName().replace(".xsd", ""));

      if(element != null) {
        log.debug("element is " + element.getName());
        bufferName = element.getName();
        XSType xtype = element.getType();
        if(xtype.isComplexType()) {
          findElementType(xtype.asComplexType());
          rc = true;
        }
      }
    } catch (Exception e) {
      log.error("parse " + fname + " failed with " + e.getMessage(), e);
View Full Code Here

    public BaseContentRef(final NGCCRuntimeEx $runtime, Ref.Type _baseType) {
        this.baseType = _baseType;
        $runtime.addPatcher(this);
        $runtime.addErrorChecker(new Patch() {
            public void run() throws SAXException {
                XSType t = baseType.getType();
                if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) {
                    $runtime.reportError(
                        Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED,
                            t.getTargetNamespace(), t.getName()), loc);
                }
            }
        });
        this.loc = $runtime.copyLocator();
    }
View Full Code Here

        });
        this.loc = $runtime.copyLocator();
    }

    public XSContentType getContentType() {
        XSType t = baseType.getType();
        if(t.asComplexType()!=null)
            return t.asComplexType().getContentType();
        else
            return t.asSimpleType();
    }
View Full Code Here

                // Use XML schema object model to determine if field is mapped
                // from an element (attributes default values are handled
                // natively) and get its default value.

                XmlString xmlDefaultValue = null;
                XSType xsType = null;
                boolean isElement = false;

                if (f.getPropertyInfo().getSchemaComponent() instanceof XSParticle) {
                    XSParticle particle = (XSParticle)f.getPropertyInfo().getSchemaComponent();
                    XSTerm term = particle.getTerm();
View Full Code Here

    }
   
   
    public void updateSubstitutabilityMap() {
        ElementDecl parent = this;
        XSType type = this.getType();

        boolean rused = false;
        boolean eused = false;
       
        while( (parent=(ElementDecl)parent.getSubstAffiliation())!=null ) {
           
            if(parent.isSubstitutionDisallowed(XSType.SUBSTITUTION))
                continue;
           
            boolean rd = parent.isSubstitutionDisallowed(XSType.RESTRICTION);
            boolean ed = parent.isSubstitutionDisallowed(XSType.EXTENSION);

            if( (rd && rused) || ( ed && eused ) )   continue;
           
            XSType parentType = parent.getType();
            while(type!=parentType) {
                if(type.getDerivationMethod()==XSType.RESTRICTIONrused = true;
                else                                                eused = true;
               
                type = type.getBaseType();
View Full Code Here

   public void complexType(XSComplexType type) {
      dumpComplexTypeAttribute(type);
      if (type.getDerivationMethod() == XSType.RESTRICTION) {
         type.getContentType().visit(this);
      } else {
         XSType baseType = type.getBaseType();
         String name = baseType.getName();
         XSComplexType parentType = schema.getComplexType(name);
         complexType(parentType);
         type.getExplicitContent().visit(this);
      }
   }
View Full Code Here

   public void complexType(XSComplexType type) {
      dumpComplexTypeAttribute(type);
      if (type.getDerivationMethod() == XSType.RESTRICTION) {
         type.getContentType().visit(this);
      } else {
         XSType baseType = type.getBaseType();
         String name = baseType.getName();
         XSComplexType parentType = schema.getComplexType(name);
         complexType(parentType);
         type.getExplicitContent().visit(this);
      }
   }
View Full Code Here

TOP

Related Classes of com.sun.xml.xsom.XSType

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.