Package org.exolab.castor.xml.schema

Examples of org.exolab.castor.xml.schema.SimpleType


     * @param typeName Name of the type we search.
     *
     * @return Definition of the simple type is found, null otherwise.
     */
    private SimpleType getSimpleTypeFromSchema(Schema schema, String typeName) {
      SimpleType base = schema.getSimpleType(typeName);
      if(base == null) {
        Enumeration imports = schema.getImportedSchema();
        while (imports.hasMoreElements() && base == null) {
        Schema sch = (Schema) imports.nextElement();
        base = getSimpleTypeFromSchema(sch, typeName);
View Full Code Here


                if (complexType.getParent() == schema) {
                    break;
                }
                return null;
            case Structure.SIMPLE_TYPE:
                SimpleType simpleType = (SimpleType) _annotated;
                schema = simpleType.getSchema();
                if (simpleType.getParent() == schema) {
                    break;
                }
                return null;
            default:
                break;
View Full Code Here

     * @param simpleType the SimpleType we are processing an enumeration for
     * @param state our current state
     */
    void processEnumerationAsBaseType(final ExtendedBinding binding,
            final SimpleType simpleType, final FactoryState state) {
        SimpleType base = (SimpleType) simpleType.getBaseType();
        XSType baseType = null;

        if (base == null) {
            baseType = new XSString();
        } else {
View Full Code Here

     */
    public void testSimpleType() throws Exception  {

        // create targeted schema
        _schema.addNamespace("pre", "my.namespace.org");
        SimpleType sType = _schema.createSimpleType("myType", "string", "");

        _schema.addSimpleType(sType);

        // compare
        TestResult result = doTest("simpletype_simple.xsd");
View Full Code Here

    public void testMinMax() throws Exception  {

        // create targeted schema
        _schema.addNamespace("pre", "my.namespace.org");

        SimpleType sType = _schema.createSimpleType("myType", "int", "");

        Facet min = new Facet(Facet.MIN_EXCLUSIVE, "0");
        Facet max = new Facet(Facet.MAX_EXCLUSIVE, "100");
        sType.addFacet(min);
        sType.addFacet(max);

        _schema.addSimpleType(sType);

        // compare
        TestResult result = doTest("simpletype_res_minmax.xsd");
View Full Code Here

            if (type != null) {
                if (type.isComplexType()) {
                    processComplexType(component, sgState, state);
                } else if (type.isSimpleType()) {
                    SimpleType simpleType = (SimpleType) type;
                    //-- handle our special case for enumerated types
                    if (simpleType.hasFacet(Facet.ENUMERATION)) {
                        processSimpleTypeEnumeration(component, sgState, classInfo, simpleType);
                    } else {
                        //////////////////////////////////////////////////////////
                        //NOTE: generate sources if the flag for generating sources
                        //from imported schemas is on
                        //////////////////////////////////////////////////////////
                        return new JClass[0];
                    }
                } else if (type.isAnyType()) {
                    //-- Do not create classes for AnyType
                    xmlNature.setSchemaType(new XSClass(SGTypes.OBJECT));
                    return new JClass[0];
                }
            } else {
                //--no type we must be facing an XML schema group
                //--MODEL GROUP OR GROUP
                createForSingleGroup = processSchemaGroup(component, state, classInfo);
            }

            //6--createGroupItem
            if (createGroupItem) {
                //-- create Bound Properties code
                if (component.hasBoundProperties()) {
                    createPropertyChangeMethods(jClass);
                }

                sgState.bindReference(jClass, classInfo);

                classes[1] = jClass;

                //-- create main group class
                String fname = component.getJavaClassName() + ITEM_NAME;
                fname = getJavaNaming().toJavaMemberName(fname, false);

                FieldInfo fInfo = null;
                if (createForSingleGroup) {
                    //By default a nested group Item can occur only once
                    fInfo = getInfoFactory().createFieldInfo(new XSClass(jClass), fname);
                } else {
                    fInfo = getInfoFactory().createCollection(
                            new XSClass(jClass), "_items", fname, getJavaNaming(), getConfig().useJava50());
                }
                fInfo.setContainer(true);
                String newClassName = className.substring(0, className.length() - 4);
                state = new FactoryState(newClassName, sgState, packageName, component);
                classInfo = state.getClassInfo();
                jClass    = state.getJClass();
                initialize(jClass);
                if (type != null && type.isComplexType()) {
                    ComplexType complexType = (ComplexType) type;
                    if (complexType.isTopLevel() ^ creatingForAnElement) {
                        //process attributes and content type since it has not be performed before
                        Annotated saved = component.getAnnotated();
                        processAttributes(component.getBinding(), complexType, state);
                        component.setView(saved);
                        if (complexType.getContentType() == ContentType.mixed) {
                            FieldInfo fieldInfo = _memberFactory.createFieldInfoForContent(
                                    component, new XSString(), getConfig().useJava50());
                            handleField(fieldInfo, state, component);
                        } else if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                            SimpleContent simpleContent = (SimpleContent) complexType.getContentType();
                            SimpleType temp = simpleContent.getSimpleType();
                            XSType xsType = _typeConversion.convertType(
                                    temp, packageName, getConfig().useJava50());
                            FieldInfo fieldInfo = _memberFactory.createFieldInfoForContent(
                                    component, xsType, getConfig().useJava50());
                            handleField(fieldInfo, state, component);
View Full Code Here

            AttributeDecl attr = enumeration.nextElement();

            component.setView(attr);

            //-- if we have a new SimpleType...generate ClassInfo
            SimpleType sType = attr.getSimpleType();

            // look for simpleType def in base type(s)
            XMLType baseXMLType = complexType.getBaseType();
            while (sType == null) {
                // If no simple type found: Get the same attribute of the base type.
                // If base type is not complex, forget it; break out of loop now.
                if (baseXMLType == null || !(baseXMLType instanceof ComplexType)) {
                    break;
                }

                // There's a base complexType; get the attribute with the same name
                // as this attribute (=attr) from it
                final ComplexType baseComplexType = (ComplexType) baseXMLType;
                AttributeDecl baseAttribute = baseComplexType.getAttributeDecl(attr.getName());

                if (baseAttribute != null) {
                    // See if this one has a simple-type...
                    sType = baseAttribute.getSimpleType();
                    if (sType != null) {
                        attr.setSimpleType(sType);
                        break;
                    }
                }

                // ... if not, go another step higher in the class hierarchy
                baseXMLType = baseXMLType.getBaseType();
            }

            // Look for referenced type (if any) for setting type, and use
            // it, if found.
            if (sType == null && attr.getReference() != null) {
                SimpleType referencedSimpleType = attr.getReference().getSimpleType();
                attr.setSimpleType(referencedSimpleType);
                sType = referencedSimpleType;
            }

            if (sType != null && !(SimpleTypesFactory.isBuiltInType(sType.getTypeCode()))) {
View Full Code Here

            } //--complexType

            //--if the content type is a simpleType create a field info for it.
            if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                SimpleContent simpleContent = (SimpleContent) complexType.getContentType();
                SimpleType temp = simpleContent.getSimpleType();
                SimpleType baseType = (SimpleType) temp.getBaseType();
                XSType xsType = _typeConversion.convertType(
                        temp, state.getPackageName(), getConfig().useJava50());

                FieldInfo fieldInfo = null;
                if ((baseType != null) && extendsSimpleType(state.getJClass(), baseType, state)) {
View Full Code Here

            } else {
                System.out.println("warning: top-level complexType with no name.");
            }
        } else if (name.equals(SchemaNames.SIMPLE_TYPE)) {
            //-- <simpleType>
            SimpleType simpleType = null;
            simpleType = ((SimpleTypeUnmarshaller) _unmarshaller).getSimpleType();
            _schema.addSimpleType(simpleType);
            getResolver().addResolvable(simpleType.getReferenceId(), simpleType);
        } else if (name.equals(SchemaNames.ELEMENT)) {
            //--<element>
            ElementDecl element = null;
            element = ((ElementUnmarshaller) _unmarshaller).getElement();
            _schema.addElementDecl(element);
View Full Code Here

        if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = ((AnnotationUnmarshaller)unmarshaller).getAnnotation();
            _list.setLocalAnnotation(ann);
        }
        else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
            SimpleType type = (SimpleType) unmarshaller.getObject();
            _list.setItemType(type);
        }


        unmarshaller = null;
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.schema.SimpleType

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.