Java Code Examples for org.apache.ws.commons.schema.XmlSchemaSimpleType#getContent()
The following examples show how to use
org.apache.ws.commons.schema.XmlSchemaSimpleType#getContent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Xsd2UmlConvert.java From secure-data-service with Apache License 2.0 | 7 votes |
private static final QName getSimpleTypeName(final XmlSchemaSimpleType simpleType) { final QName typeName = simpleType.getQName(); if (null == typeName) { // The type is anonymous. final XmlSchemaSimpleTypeContent content = simpleType.getContent(); if (content instanceof XmlSchemaSimpleTypeRestriction) { final XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; return restriction.getBaseTypeName(); } else if (content instanceof XmlSchemaSimpleTypeList) { final XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList) content; return list.getItemTypeName(); } else { throw new AssertionError(content); } } else { return typeName; } }
Example 2
Source File: XmlSchemaUtils.java From cxf with Apache License 2.0 | 6 votes |
/** * Return true if a simple type is a straightforward XML Schema representation of an enumeration. * If we discover schemas that are 'enum-like' with more complex structures, we might * make this deal with them. * @param type Simple type, possible an enumeration. * @return true for an enumeration. */ public static boolean isEumeration(XmlSchemaSimpleType type) { XmlSchemaSimpleTypeContent content = type.getContent(); if (!(content instanceof XmlSchemaSimpleTypeRestriction)) { return false; } XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; List<XmlSchemaFacet> facets = restriction.getFacets(); for (XmlSchemaFacet facet : facets) { if (!(facet instanceof XmlSchemaEnumerationFacet)) { return false; } } return true; }
Example 3
Source File: XmlSchemaUtils.java From cxf with Apache License 2.0 | 6 votes |
/** * Retrieve the string values for an enumeration. * @param type */ public static List<String> enumeratorValues(XmlSchemaSimpleType type) { XmlSchemaSimpleTypeContent content = type.getContent(); XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; List<XmlSchemaFacet> facets = restriction.getFacets(); List<String> values = new ArrayList<>(); for (XmlSchemaFacet facet : facets) { XmlSchemaEnumerationFacet enumFacet = (XmlSchemaEnumerationFacet) facet; values.add(enumFacet.getValue().toString()); } return values; }
Example 4
Source File: XmlSchemaExtractor.java From syndesis with Apache License 2.0 | 5 votes |
private void handleSimpleType(XmlSchemaSimpleType target, XmlSchemaSimpleType source) throws ParserException { // handle content final XmlSchemaSimpleTypeContent sourceContent = source.getContent(); if (sourceContent != null) { target.setContent(createXmlSchemaObjectBase(sourceContent)); } }
Example 5
Source File: ParameterProcessor.java From cxf with Apache License 2.0 | 5 votes |
private static void processXmlSchemaSimpleType(XmlSchemaSimpleType xmlSchema, JavaMethod method, MessagePartInfo part) { if (xmlSchema.getContent() instanceof XmlSchemaSimpleTypeList && (!part.isElement() || !method.isWrapperStyle())) { method.annotate(new XmlListAnotator(method.getInterface())); } if (Constants.XSD_HEXBIN.equals(xmlSchema.getQName()) && (!part.isElement() || !method.isWrapperStyle())) { method.annotate(new XmlJavaTypeAdapterAnnotator(method.getInterface(), HexBinaryAdapter.class)); } }
Example 6
Source File: ParameterMapper.java From cxf with Apache License 2.0 | 5 votes |
private static void processXmlSchemaSimpleType(XmlSchemaSimpleType xmlSchema, JavaMethod jm, JavaParameter parameter, MessagePartInfo part) { if (xmlSchema.getContent() instanceof XmlSchemaSimpleTypeList && (!part.isElement() || !jm.isWrapperStyle())) { parameter.annotate(new XmlListAnotator(jm.getInterface())); } if (Constants.XSD_HEXBIN.equals(xmlSchema.getQName()) && (!part.isElement() || !jm.isWrapperStyle())) { parameter.annotate(new XmlJavaTypeAdapterAnnotator(jm.getInterface(), HexBinaryAdapter.class)); } }
Example 7
Source File: XsdToNeutralSchemaRepo.java From secure-data-service with Apache License 2.0 | 5 votes |
private QName getSimpleContentTypeName(XmlSchemaSimpleType schemaSimpleType) { QName simpleContentTypeName = null; if (schemaSimpleType.getContent() != null && schemaSimpleType.getContent() instanceof XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction simpleContent = (XmlSchemaSimpleTypeRestriction) schemaSimpleType .getContent(); simpleContentTypeName = simpleContent.getBaseTypeName(); } else { throw new RuntimeException("Unsupported simple content model: " + schemaSimpleType.getContent().getClass().getCanonicalName()); } return simpleContentTypeName; }
Example 8
Source File: Xsd2CobolTypesModelBuilder.java From legstar-core2 with GNU Affero General Public License v3.0 | 4 votes |
/** * Retrieve the properties of a primitive type. * * @param xsdSimpleType the XML schema primitive type * @param cobolAnnotations the associated COBOL annotations * @return a set of properties */ private Map < String, Object > getProps(XmlSchemaSimpleType xsdSimpleType, final CobolAnnotations cobolAnnotations) { XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) xsdSimpleType .getContent(); if (restriction != null && restriction.getBaseTypeName() != null) { QName xsdTypeName = restriction.getBaseTypeName(); List < XmlSchemaFacet > facets = restriction.getFacets(); if (xsdTypeName.equals(Constants.XSD_STRING)) { return getCobolAlphanumType(facets); } else if (xsdTypeName.equals(Constants.XSD_HEXBIN)) { return getCobolOctetStreamType(facets); } else if (xsdTypeName.equals(Constants.XSD_INT)) { return getCobolDecimalType(cobolAnnotations, Integer.class); } else if (xsdTypeName.equals(Constants.XSD_LONG)) { return getCobolDecimalType(cobolAnnotations, Long.class); } else if (xsdTypeName.equals(Constants.XSD_SHORT)) { return getCobolDecimalType(cobolAnnotations, Short.class); } else if (xsdTypeName.equals(Constants.XSD_DECIMAL)) { return getCobolDecimalType(cobolAnnotations, BigDecimal.class); } else if (xsdTypeName.equals(Constants.XSD_FLOAT)) { return getCobolDecimalType(cobolAnnotations, Float.class); } else if (xsdTypeName.equals(Constants.XSD_DOUBLE)) { return getCobolDecimalType(cobolAnnotations, Double.class); } else if (xsdTypeName.equals(Constants.XSD_UNSIGNEDINT)) { return getCobolDecimalType(cobolAnnotations, Long.class); } else if (xsdTypeName.equals(Constants.XSD_UNSIGNEDSHORT)) { return getCobolDecimalType(cobolAnnotations, Integer.class); } else if (xsdTypeName.equals(Constants.XSD_UNSIGNEDLONG)) { return getCobolDecimalType(cobolAnnotations, BigInteger.class); } else if (xsdTypeName.equals(Constants.XSD_INTEGER)) { return getCobolDecimalType(cobolAnnotations, BigInteger.class); } else { throw new Xsd2ConverterException("Unsupported xsd type " + xsdTypeName); } } else { throw new Xsd2ConverterException("Simple type without restriction " + xsdSimpleType.getQName()); } }
Example 9
Source File: WSDLToCorbaHelper.java From cxf with Apache License 2.0 | 4 votes |
private CorbaType processSimpleRestrictionType(XmlSchemaSimpleType stype, QName name, QName schematypeName, boolean anonymous) throws Exception { CorbaType corbaTypeImpl = null; // checks if enumeration XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction)stype .getContent(); QName baseName = checkPrefix(restrictionType.getBaseTypeName()); String maxLength = null; String length = null; for (XmlSchemaFacet val : restrictionType.getFacets()) { if (val instanceof XmlSchemaMaxLengthFacet) { maxLength = val.getValue().toString(); } if (val instanceof XmlSchemaLengthFacet) { length = val.getValue().toString(); } } if (isEnumeration(restrictionType)) { corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName); } else { if (restrictionType.getBaseType() != null) { corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName, stype, null, false); } else { corbaTypeImpl = processPrimitiveType(baseName); if (corbaTypeImpl == null) { XmlSchemaType schematype = findSchemaType(baseName); corbaTypeImpl = convertSchemaToCorbaType(schematype, schematypeName, schematype, null, false); } } if (corbaTypeImpl != null) { if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_STRING) || (baseName.equals(W3CConstants.NT_SCHEMA_STRING))) { corbaTypeImpl = WSDLTypes.processStringType(corbaTypeImpl, name, maxLength, length); } else if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_DECIMAL) || (baseName.equals(W3CConstants.NT_SCHEMA_DECIMAL))) { corbaTypeImpl = WSDLTypes.processDecimalType(restrictionType, name, corbaTypeImpl, anonymous); } else if ((corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_BASE64)) || (baseName.equals(W3CConstants.NT_SCHEMA_BASE64)) || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))) { corbaTypeImpl = WSDLTypes.processBase64Type(corbaTypeImpl, name, maxLength, length); } } } return corbaTypeImpl; }
Example 10
Source File: CommonsSchemaInfoBuilder.java From tomee with Apache License 2.0 | 4 votes |
public static XmlTypeInfo createXmlTypeInfo(QName qname, XmlSchemaType type) { if (qname == null) throw new NullPointerException("qname is null"); if (type == null) throw new NullPointerException("type is null"); XmlTypeInfo typeInfo = new XmlTypeInfo(); typeInfo.qname = qname; typeInfo.anonymous = qname.getLocalPart().indexOf('>') >= 0; if (type instanceof XmlSchemaSimpleType) { XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type; XmlSchemaSimpleTypeContent content = simpleType.getContent(); if (content instanceof XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList) content; typeInfo.simpleBaseType = list.getItemType().getQName(); // this is a list typeInfo.listType = true; } else if (content instanceof XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; typeInfo.simpleBaseType = restriction.getBaseTypeName(); // is this an enumeration? for (Iterator iterator = restriction.getFacets().getIterator(); iterator.hasNext(); ) { if (iterator.next() instanceof XmlSchemaEnumerationFacet) { typeInfo.enumType = true; break; } } } } else if (type instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = (XmlSchemaComplexType) type; // SOAP array component type typeInfo.arrayComponentType = extractSoapArrayComponentType(complexType); // process attributes (skip soap arrays which have non-mappable attributes) if (!isSoapArray(complexType)) { XmlSchemaObjectCollection attributes = complexType.getAttributes(); for (Iterator iterator = attributes.getIterator(); iterator.hasNext(); ) { Object item = iterator.next(); if (item instanceof XmlSchemaAttribute) { XmlSchemaAttribute attribute = (XmlSchemaAttribute) item; Object old = typeInfo.attributes.put(attribute.getQName().getLocalPart(), attribute.getSchemaTypeName()); if (old != null) { throw new IllegalArgumentException("Complain to your expert group member, spec does not support attributes with the same local name and differing namespaces: original: " + old + ", duplicate local name: " + attribute); } } } } } else { LOG.warn("Unknown schema type class " + typeInfo.getClass().getName()); } return typeInfo; }