Package org.apache.ws.commons.schema

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction


    public static boolean isEumeration(XmlSchemaSimpleType type) {
        XmlSchemaSimpleTypeContent content = type.getContent();
        if (!(content instanceof XmlSchemaSimpleTypeRestriction)) {
            return false;
        }
        XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
        XmlSchemaObjectCollection facets = restriction.getFacets();
        for (int x = 0; x < facets.getCount(); x++) {
            XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(x);
            if (!(facet instanceof XmlSchemaEnumerationFacet)) {
                return false;
            }
View Full Code Here


     * @param type
     * @return
     */
    public static List<String> enumeratorValues(XmlSchemaSimpleType type) {
        XmlSchemaSimpleTypeContent content = type.getContent();
        XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
        XmlSchemaObjectCollection facets = restriction.getFacets();
        List<String> values = new ArrayList<String>();
        for (int x = 0; x < facets.getCount(); x++) {
            XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(x);
            XmlSchemaEnumerationFacet enumFacet = (XmlSchemaEnumerationFacet) facet;
            values.add(enumFacet.getValue().toString());
View Full Code Here

    private void createImportedAttributeType(XmlSchema attributeTypeSchema) {
        XmlSchemaSimpleType attributeImportedType = new XmlSchemaSimpleType(attributeTypeSchema);
        attributeImportedType.setName("importedAttributeType");
        attributeTypeSchema.addType(attributeImportedType);
        attributeTypeSchema.getItems().add(attributeImportedType);
        XmlSchemaSimpleTypeRestriction simpleContent = new XmlSchemaSimpleTypeRestriction();
        attributeImportedType.setContent(simpleContent);
        simpleContent.setBaseTypeName(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string"));
    }
View Full Code Here

       
        XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
        simple.setName(getSchemaType().getLocalPart());
        root.addType(simple);
        root.getItems().add(simple);
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
        restriction.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
        simple.setContent(restriction);

        Object[] constants = getTypeClass().getEnumConstants();

        XmlSchemaObjectCollection facets = restriction.getFacets();
        for (Object constant : constants) {
            XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
            f.setValue(((Enum)constant).name());
            facets.add(f);
        }
View Full Code Here

                  enumClass, targetNamespacePrefix);
                 // check weather this enum class have already added to schema
            if(typeTable.getSimpleTypeEnum(classType.getName())==null){
                XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema, false);
                simpleType.setName(enumClass);
                XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
                restriction.setBaseTypeName(Constants.XSD_STRING);
                List enumList = Arrays.asList(classType.getEnumConstants());
                for(Object enumObj : enumList){        // add all enum constants to restriction facet
                    restriction.getFacets().add(new XmlSchemaEnumerationFacet(enumObj.toString(), false));
                }
                simpleType.setContent(restriction);
                xmlSchema.getItems().add(simpleType);       // add enum to wsdl
                typeTable.addSimpleTypeEnum( classType.getName() ,enumQname ); //add to typetable
            }
View Full Code Here

            String targetNamespacePrefix = (String) targetNamespacePrefixMap.get(targetNameSpace);
            schemaTypeName = new QName(targetNameSpace, simpleName, targetNamespacePrefix);

            if (dataType instanceof EnumType) {
                XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema, false);
                XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
                restriction.setBaseTypeName(typeTable.getSimpleSchemaTypeName("java.lang.String"));
                simpleType.setContent(restriction);
                simpleType.setName(simpleName);

                List<XmlSchemaFacet> facets = restriction.getFacets();
                EnumType enumType = (EnumType) dataType;
                List enumMembers = enumType.getEnumMembers();
                for (int i = 0; i < enumMembers.size(); i++) {
                    facets.add(new XmlSchemaEnumerationFacet(enumMembers.get(i), false));
                }

                XmlSchemaElement eltOuter = new XmlSchemaElement(xmlSchema, false);
                eltOuter.setName(simpleName);
                eltOuter.setSchemaTypeName(schemaTypeName);

                xmlSchema.getItems().add(eltOuter);
                xmlSchema.getElements().put(schemaTypeName, eltOuter);
                eltOuter.setSchemaTypeName(simpleType.getQName());

                xmlSchema.getItems().add(simpleType);
                xmlSchema.getSchemaTypes().put(schemaTypeName, simpleType);

                // adding this type to the table
                typeTable.addComplexSchema(name, eltOuter.getQName());
            } else if (dataType instanceof UnionType) {
                XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false);
                XmlSchemaChoice choice = new XmlSchemaChoice();
                List<XmlSchemaObject> items = choice.getItems();

                UnionType unionType = (UnionType) dataType;
                Member[] members = unionType.getMembers();
                for (int i = 0; i < members.length; i++) {
                    items.add(generateSchemaforFieldsandProperties(xmlSchema, members[i].getDataType(),
                            members[i].getName(), true));
                }

                complexType.setParticle(choice);
                complexType.setName(simpleName);

                XmlSchemaElement eltOuter = new XmlSchemaElement(xmlSchema, false);
                eltOuter.setName(simpleName);
                eltOuter.setSchemaTypeName(schemaTypeName);

                xmlSchema.getItems().add(eltOuter);
                xmlSchema.getElements().put(schemaTypeName, eltOuter);
                eltOuter.setSchemaTypeName(complexType.getQName());
                xmlSchema.getItems().add(complexType);
                xmlSchema.getSchemaTypes().put(schemaTypeName, complexType);

                typeTable.addComplexSchema(name, eltOuter.getQName());
            } else {
                if (dataType instanceof Typedef) {
                    Typedef typedef = (Typedef) dataType;
                    DataType aliasType = typedef.getDataType();
                    if (aliasType instanceof FixedType) {
                        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema, false);
                        XmlSchemaElement eltOuter = new XmlSchemaElement(xmlSchema, false);
                        eltOuter.setName(simpleName);
                        eltOuter.setSchemaTypeName(schemaTypeName);
                        simpleType.setName(simpleName);

                        xmlSchema.getItems().add(eltOuter);
                        xmlSchema.getElements().put(schemaTypeName, eltOuter);
                        eltOuter.setSchemaTypeName(simpleType.getQName());

                        xmlSchema.getItems().add(simpleType);
                        xmlSchema.getSchemaTypes().put(schemaTypeName, simpleType);

                        typeTable.addComplexSchema(name, eltOuter.getQName());
                        XmlSchemaElement elt1 = new XmlSchemaElement(xmlSchema, false);
                        elt1.setName(name);

                        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
                        restriction.setBaseTypeName(typeTable.getSimpleSchemaTypeName(BigDecimal.class.getName()));

                        FixedType fixedType = (FixedType) aliasType;
                        XmlSchemaTotalDigitsFacet totalDigits = new XmlSchemaTotalDigitsFacet(fixedType.getDigits(), false);
                        restriction.getFacets().add(totalDigits);
                        XmlSchemaFractionDigitsFacet fractionDigits = new XmlSchemaFractionDigitsFacet(fixedType.getScale(), true);
                        restriction.getFacets().add(fractionDigits);

                        simpleType.setContent(restriction);
                    } else {
                        XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false);
                        XmlSchemaSequence sequence = new XmlSchemaSequence();
View Full Code Here

        assertEquals(new QName("http://soapinterop.org/types", "workDays"), elem.getQName());

        XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
        assertNotNull(simpleType);

        XmlSchemaSimpleTypeRestriction r = (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
        assertNotNull(r);

        QName baseTypeName = r.getBaseTypeName();
        assertEquals(new QName("http://soapinterop.org/types", "daysInWeek"), baseTypeName);
        XmlSchemaType type = schemaCol.getTypeByQName(baseTypeName);

        XmlSchemaSimpleTypeContent content = ((XmlSchemaSimpleType)type).getContent();
        assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
View Full Code Here

        if (serializedWhenUnknown) {
            XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
            simple.setName("serializedJavaObject");
            root.addType(simple);
            root.getItems().add(simple);
            XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();   
            simple.setContent(restriction);
            restriction.setBaseTypeName(XmlSchemaConstants.BASE64BINARY_QNAME);
        }
    }
View Full Code Here

    public static boolean isEumeration(XmlSchemaSimpleType type) {
        XmlSchemaSimpleTypeContent content = type.getContent();
        if (!(content instanceof XmlSchemaSimpleTypeRestriction)) {
            return false;
        }
        XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
        XmlSchemaObjectCollection facets = restriction.getFacets();
        for (int x = 0; x < facets.getCount(); x++) {
            XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(x);
            if (!(facet instanceof XmlSchemaEnumerationFacet)) {
                return false;
            }
View Full Code Here

     * @param type
     * @return
     */
    public static List<String> enumeratorValues(XmlSchemaSimpleType type) {
        XmlSchemaSimpleTypeContent content = type.getContent();
        XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
        XmlSchemaObjectCollection facets = restriction.getFacets();
        List<String> values = new ArrayList<String>();
        for (int x = 0; x < facets.getCount(); x++) {
            XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(x);
            XmlSchemaEnumerationFacet enumFacet = (XmlSchemaEnumerationFacet) facet;
            values.add(enumFacet.getValue().toString());
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

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.