use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project cxf by apache.
the class EnumVisitor method visit.
public void visit(AST enumNode) {
// <enum_type> ::= "enum" <identifier> "{" <enumerator> {"," <enumerator>}* "}"
// <enumerator> ::= <identifier>
AST enumNameNode = enumNode.getFirstChild();
Scope enumNameScope = new Scope(getScope(), enumNameNode);
// xmlschema:enum
XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema, true);
enumSchemaSimpleType.setName(mapper.mapToQName(enumNameScope));
XmlSchemaSimpleTypeRestriction enumSchemaSimpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
enumSchemaSimpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
// XmlSchemaSimpleTypeContent xmlSchemaSimpleTypeContent = enumSchemaSimpleTypeRestriction;
enumSchemaSimpleType.setContent(enumSchemaSimpleTypeRestriction);
// corba:enum
Enum corbaEnum = new Enum();
corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameScope.toString()));
corbaEnum.setRepositoryID(enumNameScope.toIDLRepositoryID());
corbaEnum.setType(enumSchemaSimpleType.getQName());
AST node = enumNameNode.getNextSibling();
while (node != null) {
// xmlschema:enumeration
XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
enumeration.setValue(node.toString());
enumSchemaSimpleTypeRestriction.getFacets().add(enumeration);
// corba:enumerator
Enumerator enumerator = new Enumerator();
enumerator.setValue(node.toString());
corbaEnum.getEnumerator().add(enumerator);
node = node.getNextSibling();
}
// add corbaType
typeMap.getStructOrExceptionOrUnion().add(corbaEnum);
// REVISIT: are there assignments needed?
setSchemaType(enumSchemaSimpleType);
setCorbaType(corbaEnum);
}
use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project cxf by apache.
the class DeclaratorVisitor method duplicateXmlSchemaSimpleType.
private XmlSchemaSimpleType duplicateXmlSchemaSimpleType(Scope newScope) {
XmlSchemaSimpleType oldSimpleType = (XmlSchemaSimpleType) getSchemaType();
XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, oldSimpleType.isTopLevel());
simpleType.setContent(oldSimpleType.getContent());
simpleType.setName(newScope.toString());
return simpleType;
}
use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project cxf by apache.
the class ParameterMapper method map.
public static JavaParameter map(JavaMethod jm, MessagePartInfo part, JavaType.Style style, ToolContext context) {
String name = ProcessorUtil.mangleNameToVariableName(part.getName().getLocalPart());
String namespace = ProcessorUtil.resolvePartNamespace(part);
String type = ProcessorUtil.resolvePartType(part, context);
JavaParameter parameter = new JavaParameter(name, type, namespace);
parameter.setPartName(part.getName().getLocalPart());
if (part.getXmlSchema() instanceof XmlSchemaSimpleType) {
processXmlSchemaSimpleType((XmlSchemaSimpleType) part.getXmlSchema(), jm, parameter, part);
} else if (part.getXmlSchema() instanceof XmlSchemaElement) {
XmlSchemaElement element = (XmlSchemaElement) part.getXmlSchema();
if (element.getSchemaType() instanceof XmlSchemaSimpleType) {
processXmlSchemaSimpleType((XmlSchemaSimpleType) element.getSchemaType(), jm, parameter, part);
}
}
parameter.setQName(ProcessorUtil.getElementName(part));
parameter.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriter(part, context));
String fullJavaName = ProcessorUtil.getFullClzName(part, context, false);
parameter.setClassName(fullJavaName);
if (style == JavaType.Style.INOUT || style == JavaType.Style.OUT) {
parameter.setHolder(true);
parameter.setHolderName(javax.xml.ws.Holder.class.getName());
String holderClass = fullJavaName;
if (JAXBUtils.holderClass(fullJavaName) != null) {
holderClass = JAXBUtils.holderClass(fullJavaName).getName();
}
parameter.setClassName(holderClass);
}
parameter.setStyle(style);
return parameter;
}
use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project cxf by apache.
the class WSDLToCorbaHelper method convertSchemaToCorbaType.
public CorbaType convertSchemaToCorbaType(XmlSchemaType stype, QName defaultName, XmlSchemaType parent, XmlSchemaAnnotation annotation, boolean anonymous) throws Exception {
CorbaType corbaTypeImpl = null;
if (!isAddressingNamespace(stype.getQName())) {
// need to determine if its a primitive type.
if (stype instanceof XmlSchemaComplexType) {
corbaTypeImpl = processComplexType((XmlSchemaComplexType) stype, defaultName, annotation, anonymous);
} else if (stype instanceof XmlSchemaSimpleType) {
corbaTypeImpl = processSimpleType((XmlSchemaSimpleType) stype, defaultName, anonymous);
} else if (xmlSchemaList.getElementByQName(stype.getQName()) != null) {
XmlSchemaElement el = xmlSchemaList.getElementByQName(stype.getQName());
// REVISIT, passing ns uri because of a bug in XmlSchema (Bug: WSCOMMONS-69)
corbaTypeImpl = processElementType(el, defaultName, stype.getQName().getNamespaceURI());
} else {
throw new Exception("Couldn't convert schema " + stype.getQName() + " to corba type");
}
}
if (corbaTypeImpl != null && !isDuplicate(corbaTypeImpl)) {
typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
}
return corbaTypeImpl;
}
Aggregations