Example #1
0
    private void processSimpleType(SimpleType simpleType, SGStateInfo sInfo) {

        if (simpleType == null) return;

        String packageName = sInfo.packageName;

        //-- Right now the only time we actually
        //-- generate source for a simpletype is
        //-- when it's an enumeration
        //if (! (simpleType instanceof BuiltInType) ) {
        if (simpleType.hasFacet(Facet.ENUMERATION)) {

            ClassInfo classInfo = sInfo.resolve(simpleType);

            if (classInfo == null) {

                JClass jClass
                    = sourceFactory.createSourceCode(simpleType, sInfo);

                processJClass(jClass, sInfo);
            }
            else {
                JClass jClass = classInfo.getJClass();
                if (!sInfo.processed(jClass)) {
                    processJClass(jClass, sInfo);
                }
            }
        }
    } //-- processSimpleType
Example #2
0
    private void createClasses(Group group, SGStateInfo sInfo) {

		if (sInfo.verbose()) {
		    System.out.print("Creating classes for group: ");
		    System.out.println(group.getName());
            if (group.getName() == null) {
                System.out.println("cannot create classes for unnamed nested groups");
                return;
            }
		}

		JClass[] classes = sourceFactory.createSourceCode(group, sInfo);
        processContentModel(group, sInfo);
        for (int i = 0; i < classes.length; i++)
            processJClass(classes[i], sInfo);

    } //-- createClasses
Example #3
0
    /**
     * Processes the given ComplexType and creates all necessary class
     * to support it
     * @param complexType the ComplexType to process
    **/
    private void processComplexType(ComplexType complexType, SGStateInfo sInfo) {

        if (complexType == null) return;

        ClassInfo classInfo = sInfo.resolve(complexType);

        if (classInfo == null) {

            //-- handle top-leve complextypes
            if (complexType.isTopLevel()) {

                JClass[] classes
                    = sourceFactory.createSourceCode(complexType, sInfo);

                for (int i = 0; i < classes.length; i++)
                    processJClass(classes[i], sInfo);
            }

            //-- process base complextype if necessary
            XMLType baseType= complexType.getBaseType();
            if (baseType != null &&
				baseType.getSchema() == complexType.getSchema()) {

				if (baseType.isComplexType())
                    processComplexType((ComplexType)baseType, sInfo);
            }

            //-- process AttributeDecl
            processAttributes(complexType, sInfo);

            //-- process ContentModel
            processContentModel(complexType, sInfo);

        }
        else {
            JClass jClass = classInfo.getJClass();
            if (!sInfo.processed(jClass)) {
                //-- process AttributeDecl
                processAttributes(complexType, sInfo);
                //-- process ContentModel
                processContentModel(complexType, sInfo);
                processJClass(jClass, sInfo);
            }
        }
    } //-- processComplexType
Example #4
0
    private void createClasses(ElementDecl elementDecl, SGStateInfo sInfo) {

		//-- when mapping schema types, only interested in producing classes
		//-- for elements with anonymous complex types
		if (SourceGenerator.mappingSchemaType2Java())
			if (elementDecl.isReference() ||
				(elementDecl.getType()!=null &&
				 elementDecl.getType().getName()!=null))
				return;

		if (sInfo.verbose()) {
		    System.out.print("Creating classes for element: ");
		    System.out.println(elementDecl.getName());
		}
        //-- create classes for sub-elements if necessary
        XMLType xmlType = elementDecl.getType();

        //-- No type definition
        if (xmlType == null) {
            System.out.print("Type not found for element: ");
            System.out.println(elementDecl.getName());
            return;
        }
        //-- ComplexType
        else if (xmlType.isComplexType()) {

			JClass[] classes = sourceFactory.createSourceCode(elementDecl,
                                                        sInfo);

            processComplexType((ComplexType)xmlType, sInfo);

            for (int i = 0; i < classes.length; i++)
                 processJClass(classes[i], sInfo);

        }
        //-- SimpleType
        else {
            processSimpleType((SimpleType)xmlType, sInfo);
        }

    }  //-- createClasses
Example #5
0
   /**
     * Sets whether or not to create the XML marshalling framework specific
     * methods (marshall, unmarshall, validate) in the generated classes.
	 * By default, these methods are generated.
	 *
     * @param createMarshall a boolean, when true indicates
     * to generated the marshalling framework methods
     *
     */
    public void setTestable(boolean testable) {
        if (sourceFactory != null)
		   sourceFactory.setTestable(testable);
    } //-- setTestable
Example #6
0
    /**
     * Sets whether or not to create the XML marshalling framework specific
     * methods (marshall, unmarshall, validate) in the generated classes.
	 * By default, these methods are generated.
	 *
     * @param createMarshalMethods a boolean, when true indicates
     * to generated the marshalling framework methods
     *
     */
    public void setCreateMarshalMethods(boolean createMarshalMethods) {
        if (sourceFactory != null)
		   sourceFactory.setCreateMarshalMethods(createMarshalMethods);
    } //-- setCreateMarshalMethods