You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2010/10/17 04:26:08 UTC
svn commit: r1023402 [2/9] - in /cxf/trunk:
api/src/main/java/org/apache/cxf/databinding/
api/src/main/java/org/apache/cxf/service/model/
common/common/src/main/java/org/apache/cxf/common/xmlschema/
common/common/src/test/java/org/apache/cxf/common/xml...
Modified: cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java (original)
+++ cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java Sun Oct 17 02:26:06 2010
@@ -89,14 +89,14 @@ public final class CorbaUtils {
return ref;
}
}
- private static final ThreadLocal<LastExport> LAST_EXPORT_CACHE =
+ private static final ThreadLocal<LastExport> LAST_EXPORT_CACHE =
new ThreadLocal<LastExport>();
private CorbaUtils() {
//utility class
}
-
-
+
+
public static QName getEmptyQName() {
return EMPTY_QNAME;
}
@@ -106,8 +106,8 @@ public final class CorbaUtils {
return getTypeCode(orb, type, null, typeMap, seenTypes);
}
- public static TypeCode getTypeCode(ORB orb,
- QName type,
+ public static TypeCode getTypeCode(ORB orb,
+ QName type,
CorbaTypeMap typeMap,
Stack<QName> seenTypes) {
return getTypeCode(orb, type, null, typeMap, seenTypes);
@@ -121,17 +121,17 @@ public final class CorbaUtils {
return getTypeCode(orb, type, obj, typeMap, seenTypes);
}
- public static TypeCode getTypeCode(ORB orb,
- QName type,
- CorbaType obj,
+ public static TypeCode getTypeCode(ORB orb,
+ QName type,
+ CorbaType obj,
CorbaTypeMap typeMap,
Stack<QName> seenTypes) {
if (type == null) {
- throw new CorbaBindingException("corba:typemap type or elemtype information required"
- + (obj == null ? "" : " for " + obj)
- + (seenTypes.empty() ? "" : ", Enclosing type: " + seenTypes.elementAt(0)));
- }
-
+ throw new CorbaBindingException("corba:typemap type or elemtype information required"
+ + (obj == null ? "" : " for " + obj)
+ + (seenTypes.empty() ? "" : ", Enclosing type: " + seenTypes.elementAt(0)));
+ }
+
TypeCode tc = null;
// first see if it is a primitive
tc = getPrimitiveTypeCode(orb, type);
@@ -140,11 +140,11 @@ public final class CorbaUtils {
tc = orb.get_primitive_tc(TCKind.from_int(TCKind._tk_any));
} else if (tc == null) {
if (typeMap == null) {
- throw new CorbaBindingException("Unable to locate typemap for namespace \""
+ throw new CorbaBindingException("Unable to locate typemap for namespace \""
+ type.getNamespaceURI() + "\"");
}
-
- tc = typeMap.getTypeCode(type);
+
+ tc = typeMap.getTypeCode(type);
if (tc == null) {
if (obj == null) {
@@ -161,7 +161,7 @@ public final class CorbaUtils {
}
if (tc == null) {
throw new CorbaBindingException("Corba type node with qname " + type + " is not supported");
- }
+ }
return tc;
}
@@ -184,29 +184,29 @@ public final class CorbaUtils {
return null;
}
- public static TypeCode getComplexTypeCode(ORB orb,
- QName type,
- Object obj,
- CorbaTypeMap typeMap,
+ public static TypeCode getComplexTypeCode(ORB orb,
+ QName type,
+ Object obj,
+ CorbaTypeMap typeMap,
Stack<QName> seenTypes) {
TypeCode tc = getAnonTypeCode(orb, type, obj, typeMap, seenTypes);
-
+
if (tc == null) {
if (obj instanceof Alias) {
Alias aliasType = (Alias)obj;
- tc = orb.create_alias_tc(aliasType.getRepositoryID(),
- getTypeCodeName(aliasType.getName()),
- getTypeCode(orb, aliasType.getBasetype(), typeMap, seenTypes));
+ tc = orb.create_alias_tc(aliasType.getRepositoryID(),
+ getTypeCodeName(aliasType.getName()),
+ getTypeCode(orb, aliasType.getBasetype(), typeMap, seenTypes));
} else if (obj instanceof Array) {
Array arrayType = (Array)obj;
- tc = orb.create_array_tc((int) arrayType.getBound(),
+ tc = orb.create_array_tc((int) arrayType.getBound(),
getTypeCode(orb, arrayType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Enum) {
Enum enumType = (Enum)obj;
String name = enumType.getName();
List enums = enumType.getEnumerator();
String[] members = new String[enums.size()];
-
+
for (int i = 0; i < members.length; ++i) {
members[i] = ((Enumerator) enums.get(i)).getValue();
}
@@ -214,14 +214,14 @@ public final class CorbaUtils {
tc = orb.create_enum_tc(enumType.getRepositoryID(), name, members);
} else if (obj instanceof Exception) {
Exception exceptType = (Exception)obj;
-
+
// TODO: check to see if this is a recursive type.
List list = exceptType.getMember();
StructMember[] members = new StructMember[list.size()];
for (int i = 0; i < members.length; ++i) {
MemberType member = (MemberType) list.get(i);
- members[i] = new StructMember(member.getName(),
- getTypeCode(orb, member.getIdltype(), typeMap, seenTypes),
+ members[i] = new StructMember(member.getName(),
+ getTypeCode(orb, member.getIdltype(), typeMap, seenTypes),
null);
}
String name = getTypeCodeName(exceptType.getName());
@@ -240,11 +240,11 @@ public final class CorbaUtils {
}
} else if (obj instanceof Sequence) {
Sequence seqType = (Sequence)obj;
- tc = orb.create_sequence_tc((int) seqType.getBound(),
+ tc = orb.create_sequence_tc((int) seqType.getBound(),
getTypeCode(orb, seqType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Struct) {
Struct structType = (Struct)obj;
-
+
// TODO: check to see if this is a recursive type.
if (seenTypes.contains(new QName(structType.getName()))) {
tc = orb.create_recursive_tc(structType.getRepositoryID());
@@ -254,7 +254,7 @@ public final class CorbaUtils {
StructMember[] members = new StructMember[list.size()];
for (int i = 0; i < members.length; ++i) {
MemberType member = (MemberType) list.get(i);
- members[i] = new StructMember(member.getName(),
+ members[i] = new StructMember(member.getName(),
getTypeCode(orb, member.getIdltype(), typeMap, seenTypes),
null);
}
@@ -268,23 +268,23 @@ public final class CorbaUtils {
}
return tc;
}
-
- private static TypeCode getAnonTypeCode(ORB orb,
- QName type,
- Object obj,
+
+ private static TypeCode getAnonTypeCode(ORB orb,
+ QName type,
+ Object obj,
CorbaTypeMap typeMap,
Stack<QName> seenTypes) {
TypeCode tc = null;
if (obj instanceof Anonarray) {
Anonarray anonArrayType = (Anonarray)obj;
- tc = orb.create_array_tc((int) anonArrayType.getBound(),
+ tc = orb.create_array_tc((int) anonArrayType.getBound(),
getTypeCode(orb, anonArrayType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Anonfixed) {
Anonfixed anonFixedType = (Anonfixed) obj;
tc = orb.create_fixed_tc((short) anonFixedType.getDigits(), (short) anonFixedType.getScale());
} else if (obj instanceof Anonsequence) {
Anonsequence anonSeqType = (Anonsequence)obj;
- tc = orb.create_sequence_tc((int) anonSeqType.getBound(),
+ tc = orb.create_sequence_tc((int) anonSeqType.getBound(),
getTypeCode(orb, anonSeqType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Anonstring) {
Anonstring anonStringType = (Anonstring)obj;
@@ -296,8 +296,8 @@ public final class CorbaUtils {
return tc;
}
- public static TypeCode getUnionTypeCode(ORB orb,
- Object obj,
+ public static TypeCode getUnionTypeCode(ORB orb,
+ Object obj,
CorbaTypeMap typeMap,
Stack<QName> seenTypes) {
Union unionType = (Union)obj;
@@ -306,7 +306,7 @@ public final class CorbaUtils {
return orb.create_recursive_tc(unionType.getRepositoryID());
} else {
seenTypes.push(new QName(unionType.getName()));
-
+
TypeCode discTC = getTypeCode(orb, unionType.getDiscriminator(), typeMap, seenTypes);
Map<String, UnionMember> members = new LinkedHashMap<String, UnionMember>();
List<Unionbranch> branches = unionType.getUnionbranch();
@@ -320,8 +320,8 @@ public final class CorbaUtils {
member.name = branch.getName();
member.type = getTypeCode(orb, branch.getIdltype(), typeMap, seenTypes);
member.label = orb.create_any();
- // We need to insert the labels in a way that depends on the type of the
- // discriminator. According to the CORBA specification, the following types
+ // We need to insert the labels in a way that depends on the type of the
+ // discriminator. According to the CORBA specification, the following types
// are permissable as discriminator types:
// * signed & unsigned short
// * signed & unsigned long
@@ -355,7 +355,7 @@ public final class CorbaUtils {
member.label.insert_boolean(Boolean.parseBoolean(cs.getLabel()));
break;
case TCKind._tk_enum:
- org.omg.CORBA.portable.OutputStream out =
+ org.omg.CORBA.portable.OutputStream out =
member.label.create_output_stream();
Enum enumVal = (Enum)getCorbaType(unionType.getDiscriminator(), typeMap);
List<Enumerator> enumerators = enumVal.getEnumerator();
@@ -370,17 +370,17 @@ public final class CorbaUtils {
default:
throw new CorbaBindingException("Unsupported discriminator type");
}
- // Some orbs are strict on how the case labels are stored for
+ // Some orbs are strict on how the case labels are stored for
// each member. So we can't
- // simply insert the labels as strings
+ // simply insert the labels as strings
members.put(cs.getLabel(), member);
}
}
}
seenTypes.pop();
- return orb.create_union_tc(unionType.getRepositoryID(),
- getTypeCodeName(unionType.getName()),
- discTC,
+ return orb.create_union_tc(unionType.getRepositoryID(),
+ getTypeCodeName(unionType.getName()),
+ discTC,
(UnionMember[])members.values().toArray(
new UnionMember[members.size()]));
}
@@ -403,7 +403,7 @@ public final class CorbaUtils {
// There is a possiblitity that the idl type will not have its namespace URI set if it has
// been read directly from the WSDL file as a string. Try with the standard corba namespace URI.
if (idltype.getNamespaceURI() == null) {
- QName uriIdltype = new QName(CorbaConstants.NU_WSDL_CORBA, idltype.getLocalPart(),
+ QName uriIdltype = new QName(CorbaConstants.NU_WSDL_CORBA, idltype.getLocalPart(),
idltype.getPrefix());
kind = PRIMITIVE_TYPECODES.get(uriIdltype);
if (kind != null) {
@@ -445,16 +445,16 @@ public final class CorbaUtils {
name = name.substring(pos + 1);
corbaType.setName(name);
}
-
+
map.addType(name, corbaType);
LOG.fine("Adding type " + name);
}
}
return map;
}
-
-
-
+
+
+
public static boolean isValidURL(String url) {
if ((url.startsWith("ior:")) || (url.startsWith("IOR:"))) {
return true;
@@ -482,7 +482,7 @@ public final class CorbaUtils {
return result;
}
-
+
public static boolean isIOR(String location) {
if ((location.startsWith("ior:")) || (location.startsWith("IOR:"))) {
return true;
@@ -508,7 +508,7 @@ public final class CorbaUtils {
} else if ("IOR:".equalsIgnoreCase(url)) {
throw new RuntimeException("Proxy not initialized. URL contains a invalid ior");
}
-
+
String trimmedUrl = url.trim();
LastExport last = LAST_EXPORT_CACHE.get();
if (last != null
@@ -537,9 +537,9 @@ public final class CorbaUtils {
String ior = reader.readLine();
if (ior == null) {
throw new RuntimeException("Invalid object reference found in file " + url);
- }
+ }
result = orb.string_to_object(ior.trim());
- reader.close();
+ reader.close();
} catch (java.io.IOException ex) {
throw new RuntimeException(ex);
}
@@ -581,11 +581,9 @@ public final class CorbaUtils {
//Change this method to access the XmlSchemaCollection.
private static boolean isElementFormQualified(XmlSchema schema, String uri) {
if (uri.equals(schema.getTargetNamespace())) {
- return schema.getElementFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
+ return schema.getElementFormDefault() == XmlSchemaForm.QUALIFIED;
}
- Iterator it = schema.getIncludes().getIterator();
- while (it.hasNext()) {
- XmlSchemaExternal extSchema = (XmlSchemaExternal) it.next();
+ for (XmlSchemaExternal extSchema : schema.getExternals()) {
return isElementFormQualified(extSchema.getSchema(), uri);
}
return false;
@@ -610,11 +608,9 @@ public final class CorbaUtils {
//Change this method to access the XmlSchemaCollection.
private static boolean isAttributeFormQualified(XmlSchema schema, String uri) {
if (uri.equals(schema.getTargetNamespace())) {
- return schema.getAttributeFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
+ return schema.getAttributeFormDefault() == XmlSchemaForm.QUALIFIED;
}
- Iterator it = schema.getIncludes().getIterator();
- while (it.hasNext()) {
- XmlSchemaExternal extSchema = (XmlSchemaExternal) it.next();
+ for (XmlSchemaExternal extSchema : schema.getExternals()) {
return isAttributeFormQualified(extSchema.getSchema(), uri);
}
return false;
@@ -643,9 +639,9 @@ public final class CorbaUtils {
} else {
list = orb.create_list(0);
}
- return list;
+ return list;
}
-
+
static {
PRIMITIVE_TYPECODES.put(CorbaConstants.NT_CORBA_BOOLEAN, TCKind.from_int(TCKind._tk_boolean));
Modified: cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java (original)
+++ cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java Sun Oct 17 02:26:06 2010
@@ -188,11 +188,11 @@ public final class IriDecoderHelper {
}
return null;
}
-
+
private static boolean findSchemaUnQualified(Collection<SchemaInfo> schemas, QName name) {
for (SchemaInfo inf : schemas) {
if (inf.getNamespaceURI().equals(name.getNamespaceURI())) {
- return inf.getSchema().getElementFormDefault().getValue().equals(XmlSchemaForm.UNQUALIFIED);
+ return inf.getSchema().getElementFormDefault() == XmlSchemaForm.UNQUALIFIED;
}
}
//Unqualified by default
@@ -202,7 +202,7 @@ public final class IriDecoderHelper {
/**
* Create a dom document conformant with the given schema element with the
* input parameters.
- *
+ *
* @param element
* @param params
* @return
@@ -214,7 +214,7 @@ public final class IriDecoderHelper {
XmlSchemaElement element = null;
QName qname = null;
boolean unQualified = false;
-
+
XmlSchemaComplexType cplxType = null;
if (schemaAnnotation instanceof XmlSchemaElement) {
element = (XmlSchemaElement)schemaAnnotation;
@@ -222,7 +222,7 @@ public final class IriDecoderHelper {
if (element.getSchemaType() instanceof XmlSchemaSimpleType) {
throw new Fault(new Message("SIMPLE_TYPE", BUNDLE));
}
-
+
cplxType = (XmlSchemaComplexType)element.getSchemaType();
unQualified = findSchemaUnQualified(schemas, element.getSchemaTypeName());
if (cplxType == null) {
@@ -249,8 +249,8 @@ public final class IriDecoderHelper {
return doc;
}
- for (int i = 0; i < seq.getItems().getCount(); i++) {
- XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().getItem(i);
+ for (int i = 0; i < seq.getItems().size(); i++) {
+ XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().get(i);
Param param = null;
for (Param p : params) {
if (p.getName().equals(elChild.getQName().getLocalPart())) {
@@ -263,17 +263,17 @@ public final class IriDecoderHelper {
if (StringUtils.isEmpty(qn.getNamespaceURI()) && unQualified) {
ec = doc.createElement(elChild.getQName().getLocalPart());
} else {
-
+
if (!elChild.getQName().getNamespaceURI().equals(qname.getNamespaceURI())) {
- ec = doc.createElementNS(elChild.getQName().getNamespaceURI(),
+ ec = doc.createElementNS(elChild.getQName().getNamespaceURI(),
elChild.getQName().getLocalPart());
ec.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, elChild.getQName().getNamespaceURI());
} else {
- ec = doc.createElementNS(elChild.getQName().getNamespaceURI(),
- "ns1:" + elChild.getQName().getLocalPart());
+ ec = doc.createElementNS(elChild.getQName().getNamespaceURI(),
+ "ns1:" + elChild.getQName().getLocalPart());
}
}
-
+
if (param != null) {
params.remove(param);
ec.appendChild(doc.createTextNode(param.getValue()));
@@ -311,8 +311,8 @@ public final class IriDecoderHelper {
doc.appendChild(root);
}
- for (int i = 0; i < seq.getItems().getCount(); i++) {
- XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().getItem(i);
+ for (int i = 0; i < seq.getItems().size(); i++) {
+ XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().get(i);
Param param = null;
for (Param p : params) {
if (p.getName().equals(elChild.getQName().getLocalPart())) {
@@ -376,7 +376,7 @@ public final class IriDecoderHelper {
&& elem.getNamespaceURI().equals(name.getNamespaceURI())) {
return elem;
}
- elem = DOMUtils.getNextElement(elem);
+ elem = DOMUtils.getNextElement(elem);
}
return null;
}
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Sun Oct 17 02:26:06 2010
@@ -80,9 +80,8 @@ import org.apache.cxf.wsdl.WSDLManager;
import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
import static org.apache.cxf.helpers.CastUtils.cast;
@@ -121,7 +120,7 @@ public class WSDLServiceBuilder {
public void setAllowElementRefs(boolean b) {
allowRefs = b;
}
-
+
private void copyExtensors(AbstractPropertiesHolder info, List<?> extList) {
if (info != null) {
for (ExtensibilityElement ext : cast(extList, ExtensibilityElement.class)) {
@@ -148,7 +147,7 @@ public class WSDLServiceBuilder {
description.setName(d.getQName());
description.setBaseURI(d.getDocumentBaseURI());
copyExtensors(description, d.getExtensibilityElements());
- copyExtensionAttributes(description, d);
+ copyExtensionAttributes(description, d);
List<ServiceInfo> serviceList = new ArrayList<ServiceInfo>();
for (java.util.Iterator<QName> ite = CastUtils.cast(d.getServices().keySet().iterator()); ite
@@ -166,13 +165,13 @@ public class WSDLServiceBuilder {
return buildServices(d, name, endpointName);
}
- private List<ServiceInfo> buildServices(Definition d,
+ private List<ServiceInfo> buildServices(Definition d,
QName name,
QName endpointName,
DescriptionInfo description) {
Service service = d.getService(name);
if (service == null) {
- org.apache.cxf.common.i18n.Message msg =
+ org.apache.cxf.common.i18n.Message msg =
new org.apache.cxf.common.i18n.Message("MISSING_SERVICE",
LOG,
name);
@@ -200,7 +199,7 @@ public class WSDLServiceBuilder {
PortType portType = def.getPortType((QName)entry.getKey());
ServiceInfo serviceInfo = this.buildMockService(def, portType);
serviceList.add(serviceInfo);
-
+
for (Iterator it2 = d.getAllBindings().values().iterator(); it2.hasNext();) {
Binding b = (Binding)it2.next();
if (b.getPortType() == portType) {
@@ -260,8 +259,8 @@ public class WSDLServiceBuilder {
}
private List<ServiceInfo> buildServices(Definition def,
- Service serv,
- QName endpointName,
+ Service serv,
+ QName endpointName,
DescriptionInfo d) {
Map<QName, ServiceInfo> services = new LinkedHashMap<QName, ServiceInfo>();
@@ -275,7 +274,7 @@ public class WSDLServiceBuilder {
description.setBaseURI(def.getDocumentBaseURI());
copyExtensors(description, def.getExtensibilityElements());
copyExtensionAttributes(description, def);
-
+
Set<Definition> done = new HashSet<Definition>();
done.add(def);
Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
@@ -299,7 +298,7 @@ public class WSDLServiceBuilder {
Binding binding = port.getBinding();
PortType bindingPt = binding.getPortType();
if (bindingPt == null) {
- org.apache.cxf.common.i18n.Message msg = new
+ org.apache.cxf.common.i18n.Message msg = new
org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE",
LOG,
binding.getQName());
@@ -343,15 +342,15 @@ public class WSDLServiceBuilder {
return new ArrayList<ServiceInfo>(services.values());
}
-
-
+
+
private void getSchemas(Definition def, ServiceInfo serviceInfo) {
ServiceSchemaInfo serviceSchemaInfo = null;
WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
if (wsdlManager != null) {
serviceSchemaInfo = wsdlManager.getSchemasForDefinition(def);
}
-
+
if (serviceSchemaInfo == null) {
SchemaUtil schemaUtil = new SchemaUtil(bus, this.schemaList);
schemaUtil.getSchemas(def, serviceInfo);
@@ -431,7 +430,7 @@ public class WSDLServiceBuilder {
if (ignoreUnknownBindings) {
return null;
}
- org.apache.cxf.common.i18n.Message msg = new
+ org.apache.cxf.common.i18n.Message msg = new
org.apache.cxf.common.i18n.Message("MISSING_DESTINATION_FACTORY",
LOG,
port.getName());
@@ -617,7 +616,7 @@ public class WSDLServiceBuilder {
// The operation's input and output message (if present) each contain
// only a single part
// input message must exist
- if (inputMessage == null || inputMessage.size() == 0
+ if (inputMessage == null || inputMessage.size() == 0
|| (inputMessage.size() > 1 && !relaxed)) {
passedRule = false;
}
@@ -676,12 +675,12 @@ public class WSDLServiceBuilder {
// This should probably look at the restricted and substitute types too.
OperationInfo unwrapped = new UnwrappedOperationInfo(opInfo);
MessageInfo unwrappedInput = new MessageInfo(unwrapped, MessageInfo.Type.INPUT,
- inputMessage.getName());
+ inputMessage.getName());
MessageInfo unwrappedOutput = null;
XmlSchemaComplexType xsct = null;
if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
-
+
xsct = (XmlSchemaComplexType)inputEl.getSchemaType();
if (hasAttributes(xsct)
|| (inputEl.isNillable() && !relaxed)
@@ -730,7 +729,7 @@ public class WSDLServiceBuilder {
private static boolean hasAttributes(XmlSchemaComplexType complexType) {
// Now lets see if we have any attributes...
// This should probably look at the restricted and substitute types too.
- if (complexType.getAnyAttribute() != null || complexType.getAttributes().getCount() > 0) {
+ if (complexType.getAnyAttribute() != null || !complexType.getAttributes().isEmpty()) {
return true;
}
return false;
@@ -740,14 +739,13 @@ public class WSDLServiceBuilder {
MessageInfo wrapper, boolean allowRefs) {
if (type.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
- XmlSchemaObjectCollection items = seq.getItems();
+ List<XmlSchemaSequenceMember> items = seq.getItems();
boolean ret = true;
- for (int x = 0; x < items.getCount(); x++) {
- XmlSchemaObject o = items.getItem(x);
- if (!(o instanceof XmlSchemaElement)) {
+ for (XmlSchemaSequenceMember seqItem : items) {
+ if (!(seqItem instanceof XmlSchemaElement)) {
return false;
}
- XmlSchemaElement el = (XmlSchemaElement)o;
+ XmlSchemaElement el = (XmlSchemaElement)seqItem;
if (el.getSchemaTypeName() != null) {
MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
@@ -756,10 +754,10 @@ public class WSDLServiceBuilder {
mpi.setElement(true);
mpi.setElementQName(el.getQName());
mpi.setXmlSchema(el);
- } else if (el.getRefName() != null) {
- MessagePartInfo mpi = wrapper.addMessagePart(el.getRefName());
- mpi.setTypeQName(el.getRefName());
- mpi.setElementQName(el.getRefName());
+ } else if (el.getRef().getTargetQName() != null) {
+ MessagePartInfo mpi = wrapper.addMessagePart(el.getRef().getTargetQName());
+ mpi.setTypeQName(el.getRef().getTargetQName());
+ mpi.setElementQName(el.getRef().getTargetQName());
mpi.setElement(true);
mpi.setXmlSchema(el);
mpi.setProperty("isRefElement", true);
@@ -805,7 +803,7 @@ public class WSDLServiceBuilder {
pi.setElementQName(part.getElementName());
XmlSchemaElement schemaElement = schemas.getElementByQName(part.getElementName());
if (null == schemaElement) {
- org.apache.cxf.common.i18n.Message errorMessage =
+ org.apache.cxf.common.i18n.Message errorMessage =
new org.apache.cxf.common.i18n.Message("WSDL4J_BAD_ELEMENT_PART",
LOG,
part.getName(),
@@ -815,14 +813,14 @@ public class WSDLServiceBuilder {
pi.setElement(true);
pi.setXmlSchema(schemaElement);
} else {
- org.apache.cxf.common.i18n.Message errorMessage =
+ org.apache.cxf.common.i18n.Message errorMessage =
new org.apache.cxf.common.i18n.Message("PART_NO_NAME_NO_TYPE",
LOG,
part.getName());
throw new WSDLRuntimeException(errorMessage);
-
+
}
}
}
-
+
}
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java Sun Oct 17 02:26:06 2010
@@ -76,7 +76,7 @@ import org.apache.ws.commons.schema.util
* not require special arrangements; the service factories do not call {{@link #initialize(Service)} until
* after the application passes the data binding into the factory. This class adds root classes to the context
* based on the SEI and implementation.
- *
+ *
* @see org.apache.cxf.aegis.AegisContext
*/
public class AegisDatabinding extends AbstractDataBinding {
@@ -267,7 +267,7 @@ public class AegisDatabinding extends Ab
}
}
- private void initializeOperation(Service s, TypeMapping serviceTM, OperationInfo opInfo,
+ private void initializeOperation(Service s, TypeMapping serviceTM, OperationInfo opInfo,
Set<AegisType> deps) {
try {
initializeMessage(s, serviceTM, opInfo.getInput(), IN_PARAM, deps);
@@ -322,7 +322,7 @@ public class AegisDatabinding extends Ab
part.setElementQName(type.getSchemaType());
}
}
-
+
Annotation[] anns = part.getProperty("parameter.annotations", Annotation[].class);
long miValue = -1;
@@ -337,7 +337,7 @@ public class AegisDatabinding extends Ab
part.setProperty("minOccurs", Long.toString(miValue));
}
-
+
// The concept of type.isNillable is questionable: how are types nillable?
// However, this if at least allow .aegis.xml files to get control.
if (part.getProperty("nillable") == null) {
@@ -360,7 +360,7 @@ public class AegisDatabinding extends Ab
part.setProperty("maxOccurs", moValue);
}
}
-
+
part2Type.put(part, type);
@@ -472,8 +472,8 @@ public class AegisDatabinding extends Ab
schema.setNamespaceContext(xmlsNamespaceMap);
schema.setTargetNamespace(entry.getKey());
- schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
- schema.setAttributeFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
+ schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
+ schema.setAttributeFormDefault(XmlSchemaForm.QUALIFIED);
for (AegisType t : entry.getValue()) {
try {
@@ -600,7 +600,7 @@ public class AegisDatabinding extends Ab
if (info.getMaxOccurs() != -1) {
param.setProperty("maxOccurs", Long.toString(info.getMaxOccurs()));
}
-
+
if ((type instanceof ArrayType) && !type.isWriteOuter()) {
param.setProperty("org.apache.cxf.aegis.outerType", type);
ArrayType aType = (ArrayType) type;
@@ -616,7 +616,7 @@ public class AegisDatabinding extends Ab
if (!usingComponentType) {
// We have to register the type if we want minOccurs and such to
- // work. (for custom types). Is this really still true with all the
+ // work. (for custom types). Is this really still true with all the
// param setting above?
if (info.nonDefaultAttributes()) {
tm.register(type);
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java Sun Oct 17 02:26:06 2010
@@ -44,7 +44,7 @@ import org.apache.ws.commons.schema.XmlS
/**
* An ArrayType.
- *
+ *
* @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
*/
public class ArrayType extends AegisType {
@@ -56,9 +56,9 @@ public class ArrayType extends AegisType
public ArrayType() {
}
-
+
public Object readObject(MessageReader reader, QName flatElementName,
- Context context, boolean asArray)
+ Context context, boolean asArray)
throws DatabindingException {
try {
Collection values = readCollection(reader, flatElementName, context);
@@ -72,7 +72,7 @@ public class ArrayType extends AegisType
}
/*
- * This version is not called for the flat case.
+ * This version is not called for the flat case.
*/
@Override
public Object readObject(MessageReader reader, Context context) throws DatabindingException {
@@ -202,16 +202,16 @@ public class ArrayType extends AegisType
return array == null ? values.toArray((Object[])Array.newInstance(getComponentType().getTypeClass(),
values.size())) : array;
}
-
-
+
+
@Override
- public void writeObject(Object values, MessageWriter writer,
+ public void writeObject(Object values, MessageWriter writer,
Context context) throws DatabindingException {
writeObject(values, writer, context, null);
}
-
-
+
+
/**
* Write an array type, using the desired element name in the flattened case.
* @param values values to write.
@@ -220,7 +220,7 @@ public class ArrayType extends AegisType
* @param flatElementName name to use for the element if flat.
* @throws DatabindingException
*/
- public void writeObject(Object values, MessageWriter writer,
+ public void writeObject(Object values, MessageWriter writer,
Context context, QName flatElementName) throws DatabindingException {
boolean forceXsiWrite = false;
if (values == null) {
@@ -246,13 +246,13 @@ public class ArrayType extends AegisType
ns = type.getSchemaType().getNamespaceURI();
}
- /*
+ /*
* This is not the right name in the 'flat' case. In the flat case,
* we need the element name that would have been attached
* one level out.
*/
String name;
-
+
if (isFlat()) {
name = flatElementName.getLocalPart();
ns = flatElementName.getNamespaceURI(); // override the namespace.
@@ -321,7 +321,7 @@ public class ArrayType extends AegisType
}
}
- protected void writeValue(Object value, MessageWriter writer, Context context,
+ protected void writeValue(Object value, MessageWriter writer, Context context,
AegisType type, String name,
String ns) throws DatabindingException {
type = TypeUtil.getWriteType(context.getGlobalContext(), value, type);
@@ -353,16 +353,14 @@ public class ArrayType extends AegisType
return;
}
- XmlSchemaComplexType complex = new XmlSchemaComplexType(root);
+ XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
complex.setName(getSchemaType().getLocalPart());
- root.addType(complex);
- root.getItems().add(complex);
XmlSchemaSequence seq = new XmlSchemaSequence();
complex.setParticle(seq);
AegisType componentType = getComponentType();
- XmlSchemaElement element = new XmlSchemaElement();
+ XmlSchemaElement element = new XmlSchemaElement(root, false);
element.setName(componentType.getSchemaType().getLocalPart());
element.setSchemaTypeName(componentType.getSchemaType());
@@ -380,7 +378,7 @@ public class ArrayType extends AegisType
/**
* Since both an Array and a List can have the same type definition, double check that there isn't already
* a defined type already.
- *
+ *
* @param root
* @return
*/
@@ -390,7 +388,7 @@ public class ArrayType extends AegisType
/**
* We need to write a complex type schema for Beans, so return true.
- *
+ *
* @see org.apache.cxf.aegis.type.AegisType#isComplex()
*/
@Override
@@ -420,7 +418,7 @@ public class ArrayType extends AegisType
/**
* Get the <code>AegisType</code> of the elements in the array.
- *
+ *
* @return
*/
public AegisType getComponentType() {
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java Sun Oct 17 02:26:06 2010
@@ -58,13 +58,13 @@ import org.apache.ws.commons.schema.XmlS
/**
* Serializes JavaBeans.
- *
+ *
* There's a really dangerous coding convention in this class, maintainers beware.
* There are two constructor. The no-args constructor defers, until later,
* the construction of a BeanTypeInfo. The one-arg constructor gets the BeanTypeInfo passed as a parameter.
* Aegis doesn't have any uniform discipline of 'construct, set properties, initialize'. Instead,
* each piece of code that uses the type info needs to call getTypeInfo() instead of referencing the
- * 'info' field.
+ * 'info' field.
*/
public class BeanType extends AegisType {
private BeanTypeInfo info;
@@ -74,7 +74,7 @@ public class BeanType extends AegisType
private boolean isException;
/**
- * Construct a type info. Caller must pass in the type class via
+ * Construct a type info. Caller must pass in the type class via
* setTypeClass later.
*/
public BeanType() {
@@ -176,7 +176,7 @@ public class BeanType extends AegisType
writeProperty(name, target, writeObj, clazz, propertyTypeInfo);
} else {
if (!alwaysAllowNillables() && !propertyTypeInfo.isNillable(name)) {
- throw new DatabindingException(name.getLocalPart()
+ throw new DatabindingException(name.getLocalPart()
+ " is nil, but not nillable.");
}
@@ -200,12 +200,12 @@ public class BeanType extends AegisType
throw new DatabindingException("Could not create class: " + e.getMessage(), e);
}
}
-
+
protected boolean alwaysAllowNillables() {
return false;
}
- protected AegisType getElementType(QName name, BeanTypeInfo beanTypeInfo,
+ protected AegisType getElementType(QName name, BeanTypeInfo beanTypeInfo,
MessageReader reader, Context context) {
AegisType type = beanTypeInfo.getType(name);
@@ -323,13 +323,13 @@ public class BeanType extends AegisType
/**
* To avoid double-writing xsi:type attributes, ObjectType uses this special entrypoint.
- *
+ *
* @param object
* @param writer
* @param context
* @param wroteXsiType
*/
- void writeObjectFromObjectType(Object object, MessageWriter writer,
+ void writeObjectFromObjectType(Object object, MessageWriter writer,
Context context, boolean wroteXsiType) {
writeObjectInternal(object, writer, context, wroteXsiType);
}
@@ -338,7 +338,7 @@ public class BeanType extends AegisType
* {@inheritDoc}
*/
@Override
- public void writeObject(Object object, MessageWriter writer,
+ public void writeObject(Object object, MessageWriter writer,
Context context) throws DatabindingException {
writeObjectInternal(object, writer, context, false);
}
@@ -373,7 +373,7 @@ public class BeanType extends AegisType
cwriter.close();
}
}
-
+
if (inf.isExtension()) {
AegisType t = getSuperType();
if (t != null) {
@@ -412,7 +412,7 @@ public class BeanType extends AegisType
}
}
- protected void writeElement(QName name, Object value,
+ protected void writeElement(QName name, Object value,
AegisType type, MessageWriter writer, Context context) {
if (!type.isFlatArray()) {
@@ -460,7 +460,7 @@ public class BeanType extends AegisType
return type;
}
- private void writeTypeReference(QName name, XmlSchemaElement element, AegisType type,
+ private void writeTypeReference(QName name, XmlSchemaElement element, AegisType type,
XmlSchema schemaRoot) {
if (type.isAbstract()) {
element.setName(name.getLocalPart());
@@ -470,9 +470,9 @@ public class BeanType extends AegisType
/*
* Here we have a semi-giant mess. If a parameter has a minOccurs > 1, it ends
* up in the type info. However, it really got used in the array type.
- * All we really want to do here is manage 'optional' elements. If we
+ * All we really want to do here is manage 'optional' elements. If we
* ever implement flat arrays, this will change. For now, we ignore
- * maxOccurs and we only look for 0's in the minOccurs.
+ * maxOccurs and we only look for 0's in the minOccurs.
*/
long minOccurs = getTypeInfo().getMinOccurs(name);
/* If it is 1, that's the default, and if it's greater than one, it means
@@ -483,10 +483,10 @@ public class BeanType extends AegisType
element.setMinOccurs(minOccurs);
}
-
+
element.setNillable(getTypeInfo().isNillable(name));
} else {
- element.setRefName(type.getSchemaType());
+ element.getRef().setTargetQName(type.getSchemaType());
}
}
@@ -502,7 +502,7 @@ public class BeanType extends AegisType
/**
* We need to write a complex type schema for Beans, so return true.
- *
+ *
* @see org.apache.cxf.aegis.type.AegisType#isComplex()
*/
@Override
@@ -666,14 +666,12 @@ public class BeanType extends AegisType
info.setTypeMapping(typeMapping);
}
}
-
+
@Override
public void writeSchema(XmlSchema root) {
BeanTypeInfo inf = getTypeInfo();
- XmlSchemaComplexType complex = new XmlSchemaComplexType(root);
+ XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
complex.setName(getSchemaType().getLocalPart());
- root.addType(complex);
- root.getItems().add(complex);
AegisType sooperType = getSuperType();
@@ -721,7 +719,7 @@ public class BeanType extends AegisType
}
}
- XmlSchemaElement element = new XmlSchemaElement();
+ XmlSchemaElement element = new XmlSchemaElement(root, false);
element.setName(name.getLocalPart());
sequence.getItems().add(element);
@@ -766,7 +764,7 @@ public class BeanType extends AegisType
// Write out schema for attributes
for (QName name : inf.getAttributes()) {
- XmlSchemaAttribute attribute = new XmlSchemaAttribute();
+ XmlSchemaAttribute attribute = new XmlSchemaAttribute(root, false);
complex.getAttributes().add(attribute);
attribute.setName(name.getLocalPart());
AegisType type = getType(inf, name);
@@ -781,7 +779,7 @@ public class BeanType extends AegisType
* If extensible attributes then add <xsd:anyAttribute/>
*/
if (inf.isExtensibleAttributes()) {
- sequence.getItems().add(new XmlSchemaAnyAttribute());
+ complex.setAnyAttribute(new XmlSchemaAnyAttribute());
}
}
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java Sun Oct 17 02:26:06 2010
@@ -48,7 +48,7 @@ import org.apache.ws.commons.schema.XmlS
* in the constructor, in the case that the type is a custom type that may not
* have its schema in the WSDL. Can specify whether or not unknown objects
* should be serialized as a byte stream.
- *
+ *
*/
public class ObjectType extends AegisType {
private static final QName XSI_TYPE = new QName(SOAPConstants.XSI_NS, "type");
@@ -102,7 +102,7 @@ public class ObjectType extends AegisTyp
AegisType type = null;
QName typeQName = null;
-
+
if (typeName != null) {
typeName = typeName.trim();
typeQName = extractQName(reader, typeName);
@@ -124,7 +124,7 @@ public class ObjectType extends AegisTyp
if (type == this) {
throw new DatabindingException("Could not determine how to read type: " + typeQName);
}
-
+
if (type == null && readToDocument) {
type = getTypeMapping().getType(Document.class);
}
@@ -168,7 +168,7 @@ public class ObjectType extends AegisTyp
}
@Override
- public void writeObject(Object object, MessageWriter writer, Context context)
+ public void writeObject(Object object, MessageWriter writer, Context context)
throws DatabindingException {
if (null == object) {
MessageWriter nilWriter = writer.getAttributeWriter(XSI_NIL);
@@ -188,7 +188,7 @@ public class ObjectType extends AegisTyp
type = tm.getTypeCreator().createType(object.getClass());
tm.register(type);
}
-
+
writer.writeXsiType(type.getSchemaType());
boolean nextIsBeanType = type instanceof BeanType;
if (nextIsBeanType) {
@@ -264,11 +264,9 @@ public class ObjectType extends AegisTyp
@Override
public void writeSchema(XmlSchema root) {
if (serializedWhenUnknown) {
- XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
+ XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true);
simple.setName("serializedJavaObject");
- root.addType(simple);
- root.getItems().add(simple);
- XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+ XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
simple.setContent(restriction);
restriction.setBaseTypeName(XmlSchemaConstants.BASE64BINARY_QNAME);
}
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java Sun Oct 17 02:26:06 2010
@@ -75,7 +75,7 @@ public class MapType extends AegisType {
if (evReader.getName().equals(getKeyName())) {
AegisType kType = TypeUtil.getReadType(evReader.getXMLStreamReader(),
- context.getGlobalContext(),
+ context.getGlobalContext(),
getKeyType());
key = kType.readObject(evReader, context);
} else if (evReader.getName().equals(getValueName())) {
@@ -182,45 +182,43 @@ public class MapType extends AegisType {
@Override
public void writeSchema(XmlSchema root) {
- XmlSchemaComplexType complex = new XmlSchemaComplexType(root);
+ XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
complex.setName(getSchemaType().getLocalPart());
- root.addType(complex);
- root.getItems().add(complex);
XmlSchemaSequence sequence = new XmlSchemaSequence();
complex.setParticle(sequence);
AegisType kType = getKeyType();
AegisType vType = getValueType();
-
- XmlSchemaElement element = new XmlSchemaElement();
+
+ XmlSchemaElement element = new XmlSchemaElement(root, false);
sequence.getItems().add(element);
element.setName(getEntryName().getLocalPart());
element.setMinOccurs(0);
element.setMaxOccurs(Long.MAX_VALUE);
-
- XmlSchemaComplexType evType = new XmlSchemaComplexType(root);
+
+ XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false);
element.setType(evType);
-
+
XmlSchemaSequence evSequence = new XmlSchemaSequence();
evType.setParticle(evSequence);
- createElement(evSequence, getKeyName(), kType, false);
- createElement(evSequence, getValueName(), vType, true);
+ createElement(root, evSequence, getKeyName(), kType, false);
+ createElement(root, evSequence, getValueName(), vType, true);
}
/**
* Creates a element in a sequence for the key type and the value type.
*/
- private void createElement(XmlSchemaSequence seq, QName name,
+ private void createElement(XmlSchema schema, XmlSchemaSequence seq, QName name,
AegisType type, boolean optional) {
- XmlSchemaElement element = new XmlSchemaElement();
+ XmlSchemaElement element = new XmlSchemaElement(schema, false);
seq.getItems().add(element);
element.setName(name.getLocalPart());
element.setSchemaTypeName(type.getSchemaType());
if (optional) {
element.setMinOccurs(0);
} else {
- element.setMinOccurs(1);
+ element.setMinOccurs(1);
}
element.setMaxOccurs(1);
}
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java Sun Oct 17 02:26:06 2010
@@ -19,6 +19,7 @@
package org.apache.cxf.aegis.type.java5;
import java.lang.reflect.Type;
+import java.util.List;
import org.apache.cxf.aegis.Context;
import org.apache.cxf.aegis.DatabindingException;
@@ -28,7 +29,7 @@ import org.apache.cxf.aegis.xml.MessageW
import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaFacet;
import org.apache.ws.commons.schema.XmlSchemaSimpleType;
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
@@ -43,7 +44,7 @@ public class EnumType extends AegisType
@Override
public void writeObject(Object object, MessageWriter writer, Context context) {
- // match the reader.
+ // match the reader.
writer.writeValue(((Enum)object).name());
}
@@ -52,7 +53,7 @@ public class EnumType extends AegisType
if (!(typeClass instanceof Class)) {
throw new DatabindingException("Aegis cannot map generic Enums.");
}
-
+
Class<?> plainClass = (Class<?>)typeClass;
if (!plainClass.isEnum()) {
throw new DatabindingException("EnumType must map an enum.");
@@ -63,18 +64,16 @@ public class EnumType extends AegisType
@Override
public void writeSchema(XmlSchema root) {
-
- XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
+
+ XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true);
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();
+ List<XmlSchemaFacet> facets = restriction.getFacets();
for (Object constant : constants) {
XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
f.setValue(((Enum)constant).name());
Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/SchemaAddinsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/SchemaAddinsTest.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/SchemaAddinsTest.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/SchemaAddinsTest.java Sun Oct 17 02:26:06 2010
@@ -32,13 +32,13 @@ import org.junit.Test;
public class SchemaAddinsTest extends Assert {
private TestUtilities testUtilities;
-
+
@Before
public void before() {
testUtilities = new TestUtilities(getClass());
testUtilities.addDefaultNamespaces();
}
-
+
@Test
public void testAegisTypeSchema() throws Exception {
AegisContext context = new AegisContext();
@@ -54,13 +54,13 @@ public class SchemaAddinsTest extends As
}
}
assertNotNull(typeSchema);
-
- assertNotSame(0, typeSchema.getItems().getCount());
+
+ assertNotSame(0, typeSchema.getItems().size());
XmlSchemaSerializer serializer = new XmlSchemaSerializer();
Document[] docs = serializer.serializeSchema(typeSchema, false);
testUtilities.assertValid("/xsd:schema/xsd:simpleType[@name='char']", docs[0]);
-
-
-
+
+
+
}
}
Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java Sun Oct 17 02:26:06 2010
@@ -49,6 +49,8 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
+
import org.junit.Test;
public class BeanTest extends AbstractAegisTest {
@@ -57,7 +59,7 @@ public class BeanTest extends AbstractAe
public void setUp() throws Exception {
super.setUp();
-
+
addNamespace("b", "urn:Bean");
addNamespace("bz", "urn:beanz");
addNamespace("a", "urn:anotherns");
@@ -138,7 +140,7 @@ public class BeanTest extends AbstractAe
@Test
public void testUnmappedProperty() throws Exception {
-
+
defaultContext();
String ns = "urn:Bean";
BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, ns, false);
@@ -167,7 +169,7 @@ public class BeanTest extends AbstractAe
assertInvalid("/b:root/b:bleh", element);
assertValid("/b:root/b:howdycustom[text()='howdy']", element);
}
-
+
@Test
public void testAttributeMap() throws Exception {
defaultContext();
@@ -193,15 +195,15 @@ public class BeanTest extends AbstractAe
Element element = writeObjectToElement(type, bean, getContext());
assertValid("/b:root[@b:bleh='bleh']", element);
assertValid("/b:root[@b:howdy='howdy']", element);
-
+
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType stype = (XmlSchemaComplexType)schema.getTypeByName("bean");
boolean howdy = false;
boolean bleh = false;
- for (int x = 0; x < stype.getAttributes().getCount(); x++) {
- XmlSchemaObject o = stype.getAttributes().getItem(x);
+ for (int x = 0; x < stype.getAttributes().size(); x++) {
+ XmlSchemaObject o = stype.getAttributes().get(x);
if (o instanceof XmlSchemaAttribute) {
XmlSchemaAttribute a = (XmlSchemaAttribute)o;
if ("howdy".equals(a.getName())) {
@@ -246,7 +248,7 @@ public class BeanTest extends AbstractAe
writer.flush();
bos.close();
-
+
Document doc = DOMUtils.readXml(new ByteArrayInputStream(bos.toByteArray()));
Element element = doc.getDocumentElement();
@@ -271,7 +273,7 @@ public class BeanTest extends AbstractAe
SimpleBean bean = new SimpleBean();
// Test writing
-
+
Element element = writeObjectToElement(type, bean, getContext());
assertInvalid("/b:root[@b:howdy]", element);
@@ -279,14 +281,14 @@ public class BeanTest extends AbstractAe
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType stype = (XmlSchemaComplexType)schema.getTypeByName("bean");
XmlSchemaSequence seq = (XmlSchemaSequence) stype.getParticle();
boolean howdy = false;
boolean bleh = false;
- for (int x = 0; x < seq.getItems().getCount(); x++) {
- XmlSchemaObject o = seq.getItems().getItem(x);
+ for (int x = 0; x < seq.getItems().size(); x++) {
+ XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement a = (XmlSchemaElement)o;
if ("bleh".equals(a.getName())) {
@@ -295,8 +297,8 @@ public class BeanTest extends AbstractAe
}
}
- for (int x = 0; x < stype.getAttributes().getCount(); x++) {
- XmlSchemaObject o = stype.getAttributes().getItem(x);
+ for (int x = 0; x < stype.getAttributes().size(); x++) {
+ XmlSchemaObject o = stype.getAttributes().get(x);
if (o instanceof XmlSchemaAttribute) {
XmlSchemaAttribute a = (XmlSchemaAttribute)o;
if ("howdy".equals(a.getName())) {
@@ -308,7 +310,7 @@ public class BeanTest extends AbstractAe
assertTrue(howdy);
assertTrue(bleh);
}
-
+
@Test
public void testNillableInt() throws Exception {
defaultContext();
@@ -322,13 +324,13 @@ public class BeanTest extends AbstractAe
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("bean");
XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
boolean int1ok = false;
boolean int2ok = false;
- for (int x = 0; x < seq.getItems().getCount(); x++) {
- XmlSchemaObject o = seq.getItems().getItem(x);
+ for (int x = 0; x < seq.getItems().size(); x++) {
+ XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("int1".equals(oe.getName())) {
@@ -345,7 +347,7 @@ public class BeanTest extends AbstractAe
assertTrue(int1ok);
assertTrue(int2ok);
}
-
+
@Test
public void testNillableAnnotation() throws Exception {
context = new AegisContext();
@@ -362,13 +364,13 @@ public class BeanTest extends AbstractAe
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("BeanWithNillableItem");
XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
boolean itemFound = false;
boolean itemNotNillableFound = false;
- for (int x = 0; x < seq.getItems().getCount(); x++) {
- XmlSchemaObject o = seq.getItems().getItem(x);
+ for (int x = 0; x < seq.getItems().size(); x++) {
+ XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("item".equals(oe.getName())) {
@@ -384,8 +386,8 @@ public class BeanTest extends AbstractAe
assertTrue(itemFound);
assertTrue(itemNotNillableFound);
}
-
-
+
+
@Test
public void testNillableIntMinOccurs1() throws Exception {
context = new AegisContext();
@@ -402,24 +404,24 @@ public class BeanTest extends AbstractAe
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("IntBean");
XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
boolean int1ok = false;
- for (int x = 0; x < seq.getItems().getCount(); x++) {
- XmlSchemaObject o = seq.getItems().getItem(x);
+ for (int x = 0; x < seq.getItems().size(); x++) {
+ XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("int1".equals(oe.getName())) {
int1ok = true;
assertFalse(oe.isNillable());
assertEquals(1, oe.getMinOccurs());
- }
+ }
}
}
assertTrue(int1ok);
}
-
+
@Test
public void testCharMappings() throws Exception {
defaultContext();
@@ -427,30 +429,30 @@ public class BeanTest extends AbstractAe
BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
type.setTypeClass(SimpleBean.class);
type.setTypeMapping(mapping);
-
+
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("SimpleBean");
XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
boolean charok = false;
- for (int x = 0; x < seq.getItems().getCount(); x++) {
- XmlSchemaObject o = seq.getItems().getItem(x);
+ for (int x = 0; x < seq.getItems().size(); x++) {
+ XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("character".equals(oe.getName())) {
charok = true;
assertNotNull(oe.getSchemaTypeName());
assertTrue(oe.isNillable());
- assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,
+ assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,
oe.getSchemaTypeName());
}
}
}
assertTrue(charok);
}
-
+
@Test
public void testByteMappings() throws Exception {
defaultContext();
@@ -461,14 +463,14 @@ public class BeanTest extends AbstractAe
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
-
+
XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("SimpleBean");
XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
boolean littleByteOk = false;
boolean bigByteOk = false;
- for (int x = 0; x < seq.getItems().getCount(); x++) {
- XmlSchemaObject o = seq.getItems().getItem(x);
+ for (int x = 0; x < seq.getItems().size(); x++) {
+ XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("littleByte".equals(oe.getName())) {
@@ -484,7 +486,7 @@ public class BeanTest extends AbstractAe
}
assertTrue(littleByteOk);
assertTrue(bigByteOk);
-
+
SimpleBean bean = new SimpleBean();
bean.setBigByte(new Byte((byte)0xfe));
bean.setLittleByte((byte)0xfd);
@@ -492,7 +494,7 @@ public class BeanTest extends AbstractAe
Byte bb = new Byte((byte)0xfe);
String bbs = bb.toString();
assertValid("/b:root/bz:bigByte[text()='" + bbs + "']", element);
-
+
// Test reading
ElementReader reader = new ElementReader(getResourceAsStream("byteBeans.xml"));
bean = (SimpleBean)type.readObject(reader, getContext());
@@ -502,7 +504,7 @@ public class BeanTest extends AbstractAe
reader.getXMLStreamReader().close();
}
-
+
@Test
public void testNullNonNillableWithDate() throws Exception {
defaultContext();
@@ -525,7 +527,7 @@ public class BeanTest extends AbstractAe
assertInvalid("/b:root/b:date", element);
assertValid("/b:root", element);
}
-
+
@Test
public void testExtendedBean() throws Exception {
defaultContext();
@@ -546,7 +548,7 @@ public class BeanTest extends AbstractAe
Element element = writeObjectToElement(type, bean, getContext());
assertValid("/b:root/b:howdy[text()='howdy']", element);
}
-
+
@Test
public void testByteBean() throws Exception {
defaultContext();
@@ -638,7 +640,7 @@ public class BeanTest extends AbstractAe
this.int2 = int2;
}
}
-
+
public static class BeanWithNillableItem {
private IntBean item;
private Integer itemNotNillable;
@@ -660,7 +662,7 @@ public class BeanTest extends AbstractAe
this.itemNotNillable = itemNotNillable;
}
-
+
}
public static class ByteBean {
Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CustomStringType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CustomStringType.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CustomStringType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CustomStringType.java Sun Oct 17 02:26:06 2010
@@ -35,10 +35,8 @@ public class CustomStringType extends St
if (root.getTargetNamespace().equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
return;
}
- XmlSchemaSimpleType type = new XmlSchemaSimpleType(root);
+ XmlSchemaSimpleType type = new XmlSchemaSimpleType(root, true);
type.setName(getSchemaType().getLocalPart());
- root.getItems().add(type);
- root.addType(type);
XmlSchemaSimpleContentExtension ext = new XmlSchemaSimpleContentExtension();
ext.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
XmlSchemaSimpleTypeRestriction content = new XmlSchemaSimpleTypeRestriction();