You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by ry...@apache.org on 2006/07/05 01:01:37 UTC
svn commit: r419116 [2/2] - in /incubator/woden/java: ant-test/
src/org/apache/woden/ant/
Modified: incubator/woden/java/src/org/apache/woden/ant/WsdlCm.java
URL: http://svn.apache.org/viewvc/incubator/woden/java/src/org/apache/woden/ant/WsdlCm.java?rev=419116&r1=419115&r2=419116&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/ant/WsdlCm.java (original)
+++ incubator/woden/java/src/org/apache/woden/ant/WsdlCm.java Tue Jul 4 16:01:36 2006
@@ -33,110 +33,22 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Vector;
-
-import javax.xml.namespace.QName;
import org.apache.woden.WSDLException;
import org.apache.woden.WSDLFactory;
import org.apache.woden.WSDLReader;
-import org.apache.woden.wsdl20.Binding;
-import org.apache.woden.wsdl20.BindingFault;
-import org.apache.woden.wsdl20.BindingFaultReference;
-import org.apache.woden.wsdl20.BindingMessageReference;
-import org.apache.woden.wsdl20.BindingOperation;
import org.apache.woden.wsdl20.Description;
-import org.apache.woden.wsdl20.ElementDeclaration;
-import org.apache.woden.wsdl20.Endpoint;
-import org.apache.woden.wsdl20.Feature;
-import org.apache.woden.wsdl20.Interface;
-import org.apache.woden.wsdl20.InterfaceFault;
-import org.apache.woden.wsdl20.InterfaceFaultReference;
-import org.apache.woden.wsdl20.InterfaceMessageReference;
-import org.apache.woden.wsdl20.InterfaceOperation;
-import org.apache.woden.wsdl20.Property;
-import org.apache.woden.wsdl20.Service;
-import org.apache.woden.wsdl20.TypeDefinition;
-import org.apache.woden.wsdl20.extensions.ComponentExtensions;
-import org.apache.woden.wsdl20.extensions.InterfaceOperationExtensions;
-import org.apache.woden.wsdl20.extensions.http.HTTPAuthenticationScheme;
-import org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensions;
-import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensions;
-import org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensions;
-import org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions;
-import org.apache.woden.wsdl20.extensions.http.HTTPEndpointExtensions;
-import org.apache.woden.wsdl20.extensions.http.HTTPErrorStatusCode;
-import org.apache.woden.wsdl20.extensions.http.HTTPHeader;
-import org.apache.woden.wsdl20.extensions.rpc.Argument;
-import org.apache.woden.wsdl20.extensions.rpc.RPCInterfaceOperationExtensions;
-import org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions;
-import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions;
-import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions;
-import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions;
-import org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensions;
-import org.apache.woden.wsdl20.extensions.soap.SOAPFaultCode;
-import org.apache.woden.wsdl20.extensions.soap.SOAPFaultSubcodes;
-import org.apache.woden.wsdl20.extensions.soap.SOAPHeaderBlock;
-import org.apache.woden.wsdl20.extensions.soap.SOAPModule;
import org.apache.woden.wsdl20.xml.DescriptionElement;
/**
- * <code>WsdlCm</code> writes the component model in the W3C interchange format.
+ * The <code>WsdlCm</code> class writes the component model in the W3C interchange format.
*
* @author Arthur Ryman (ryman@ca.ibm.com, arthur-ryman@gmail.com)
*
*/
public class WsdlCm extends XMLWriter {
- /** WSDL CM namespaces */
- private static String WSDLCM_NS = "http://www.w3.org/2002/ws/desc/wsdl/component";
-
- private static String WSDLCMBASE_PREFIX = "cmbase";
-
- private static String WSDLCMBASE_NS = "http://www.w3.org/2002/ws/desc/wsdl/component-base";
-
- private static String WSDLCMEXTENSIONS_PREFIX = "cmextensions";
-
- private static String WSDLCMEXTENSIONS_NS = "http://www.w3.org/2002/ws/desc/wsdl/component-extensions";
-
- private static String WSDLCMHTTP_PREFIX = "cmhttp";
-
- private static String WSDLCMHTTP_NS = "http://www.w3.org/2002/ws/desc/wsdl/component-http";
-
- private static String WSDLCMRPC_PREFIX = "cmrpc";
-
- private static String WSDLCMRPC_NS = "http://www.w3.org/2002/ws/desc/wsdl/component-rpc";
-
- private static String WSDLCMSOAP_PREFIX = "cmsoap";
-
- private static String WSDLCMSOAP_NS = "http://www.w3.org/2002/ws/desc/wsdl/component-soap";
-
- /** XML Schema namespace */
- private static String XSD_NS = "http://www.w3.org/2001/XMLSchema";
-
- /** build-in simple types */
- private static String[] XSD_TYPES = { "string", "boolean", "decimal",
- "float", "double", "duration", "dateTime", "time", "date",
- "gYearMonth", "gYear", "gMonthDay", "gDay", "gMonth", "hexBinary",
- "base64Binary", "anyURI", "QName", "NOTATION", "normalizedString",
- "token", "language", "NMTOKEN", "NMTOKENS", "Name", "NCName", "ID",
- "IDREF", "IDREFS", "ENTITY", "ENTITIES", "integer",
- "nonPositiveInteger", "negativeInteger", "long", "int", "short",
- "byte", "nonNegativeInteger", "unsignedLong", "unsignedInt",
- "unsignedShort", "unsignedByte", "positiveInteger" };
-
- {
- Arrays.sort(XSD_TYPES);
- }
-
- private static String PARENT = WSDLCMBASE_PREFIX + ":parent";
-
- private static String FEATURES = WSDLCMBASE_PREFIX + ":features";
-
- private static String PROPERTIES = WSDLCMBASE_PREFIX + ":properties";
+ private CmWriter cm;
/**
* Constructs a component model writer.
@@ -145,11 +57,31 @@
*/
public WsdlCm(PrintWriter out) {
super(out);
+
+ // create the writes for each namespace
+ new CmBaseWriter(this);
+ new CmExtensionsWriter(this);
+ new CmRpcWriter(this);
+ new CmHttpWriter(this);
+ new CmSoapWriter(this);
+ cm = new CmWriter(this);
+ }
+
+ /**
+ * Writes the Description component in the component model interchange format.
+ *
+ * @param descComp the Description component
+ */
+ public void write(Description descComp) {
+
+ cm.write(descComp);
}
/**
* Tests the component model interchange format writer.
*
+ * TODO Move this method into a tests package.
+ *
* @param args the command line arguments
*/
public static void main(String[] args) {
@@ -164,17 +96,17 @@
if (args.length > 0) {
wsdlLoc = args[0];
}
-
+
if (args.length > 1) {
wsdlCmLoc = args[1];
}
-
+
if (args.length > 2) {
reportLoc = args[2];
}
System.out.println("Starting: " + wsdlLoc);
-
+
Report reportWriter = Report.openReport(new File(reportLoc));
reportWriter.beginWsdl(wsdlLoc);
@@ -208,1189 +140,9 @@
e.printStackTrace();
}
-
+
reportWriter.closeReport();
System.out.println("Finished.");
-
- }
-
- /**
- * Writes the component model.
- *
- * @param component the root Description component
- */
- public void write(Description component) {
-
- xmlDeclaration("UTF-8");
-
- String attributes = "xmlns='" + WSDLCM_NS + "'\n";
- attributes += " xmlns:" + WSDLCMEXTENSIONS_PREFIX + "='"
- + WSDLCMEXTENSIONS_NS + "'\n";
- attributes += " xmlns:" + WSDLCMBASE_PREFIX + "='" + WSDLCMBASE_NS
- + "'\n";
- attributes += " xmlns:" + WSDLCMHTTP_PREFIX + "='" + WSDLCMHTTP_NS
- + "'\n";
- attributes += " xmlns:" + WSDLCMRPC_PREFIX + "='" + WSDLCMRPC_NS
- + "'\n";
- attributes += " xmlns:" + WSDLCMSOAP_PREFIX + "='" + WSDLCMSOAP_NS
- + "'\n";
- attributes += idAttribute(component);
- beginElement("descriptionComponent", attributes);
-
- URI[] extensions = { ComponentExtensions.URI_NS_EXTENSIONS,
- ComponentExtensions.URI_NS_HTTP,
- ComponentExtensions.URI_NS_RPC, ComponentExtensions.URI_NS_SOAP };
-
- writeUris("extensions", extensions);
- write("interfaces", component.getInterfaces());
- write("bindings", component.getBindings());
- write("services", component.getServices());
- write("elementDeclarations", component.getElementDeclarations());
- write("typeDefinitions", component.getTypeDefinitions());
-
- endElement();
- }
-
- private void writeRefs(String tag, Interface[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((Interface) o1).getName();
- QName x2 = ((Interface) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++) {
- writeRef("interface", components[i]);
- }
-
- endElement();
-
- }
-
- private void write(String tag, Interface[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((Interface) o1).getName();
- QName x2 = ((Interface) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("interfaceComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, Interface component) {
-
- beginElement(tag, idAttribute(component));
-
- write("name", component.getName());
- writeRefs("extendedInterfaces", component.getExtendedInterfaces());
- write("interfaceFaults", component.getInterfaceFaults());
- write("interfaceOperations", component.getInterfaceOperations());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
-
- endElement();
- }
-
- private void write(String tag, InterfaceFault[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((InterfaceFault) o1).getName();
- QName x2 = ((InterfaceFault) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("interfaceFaultComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, InterfaceFault component) {
-
- beginElement("interfaceFaultComponent", idAttribute(component));
-
- write("name", component.getName());
- writeOptionalRef("elementDeclaration", component
- .getElementDeclaration());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, InterfaceOperation[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((InterfaceOperation) o1).getName();
- QName x2 = ((InterfaceOperation) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("interfaceOperationComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, InterfaceOperation component) {
-
- beginElement("interfaceOperationComponent", idAttribute(component));
-
- write("name", component.getName());
- write("messageExchangePattern", component.getMessageExchangePattern());
- write("interfaceMessageReferences", component
- .getInterfaceMessageReferences());
- write("interfaceFaultReferences", component
- .getInterfaceFaultReferences());
- writeUris("style", component.getStyle());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- InterfaceOperationExtensions extensions = (InterfaceOperationExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_EXTENSIONS);
- if (extensions != null) {
-
- beginElement(WSDLCMEXTENSIONS_PREFIX
- + ":wsdlInterfaceOperationExtension");
-
- write(WSDLCMEXTENSIONS_PREFIX + ":safety", extensions.isSafety());
-
- endElement();
- }
-
- RPCInterfaceOperationExtensions rpcExtensions = (RPCInterfaceOperationExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_RPC);
- if (rpcExtensions != null) {
-
- beginElement(WSDLCMRPC_PREFIX + ":rpcInterfaceOperationExtension");
-
- write(WSDLCMRPC_PREFIX + ":rpcSignature", rpcExtensions
- .getRPCSignature());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, Argument[] rpcSignature) {
-
- beginElement(tag);
- for (int i = 0; i < rpcSignature.length; i++) {
-
- write(WSDLCMRPC_PREFIX + ":argument", rpcSignature[i]);
- }
- endElement();
- }
-
- private void write(String tag, Argument argument) {
-
- beginElement(tag);
-
- write(WSDLCMRPC_PREFIX + ":name", argument.getName());
- write(WSDLCMRPC_PREFIX + ":direction", argument.getDirection()
- .toString());
-
- endElement();
- }
-
- private void write(String tag, InterfaceMessageReference[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- String x1 = ((InterfaceMessageReference) o1).getMessageLabel()
- .toString();
- String x2 = ((InterfaceMessageReference) o2).getMessageLabel()
- .toString();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("interfaceMessageReferenceComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, InterfaceMessageReference component) {
-
- beginElement(tag, idAttribute(component));
-
- write("messageLabel", component.getMessageLabel().toString());
- write("direction", component.getDirection().toString());
- write("messageContentModel", component.getMessageContentModel());
- writeOptionalRef("elementDeclaration", component
- .getElementDeclaration());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, InterfaceFaultReference[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- InterfaceFaultReference i1 = (InterfaceFaultReference) o1;
- InterfaceFaultReference i2 = (InterfaceFaultReference) o2;
-
- InterfaceFault if1 = i1.getInterfaceFault();
- InterfaceFault if2 = i2.getInterfaceFault();
-
- if (if1 == if2)
- return 0;
- if (if1 == null)
- return -1;
- if (if2 == null)
- return 1;
-
- QName q1 = if1.getName();
- QName q2 = if2.getName();
-
- int result = compareQName(q1, q2);
- if (result != 0)
- return result;
-
- String x1 = i1.getMessageLabel().toString();
- String x2 = i2.getMessageLabel().toString();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("interfaceFaultReferenceComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, InterfaceFaultReference component) {
-
- beginElement(tag, idAttribute(component));
-
- writeRef("interfaceFault", component.getInterfaceFault());
- write("messageLabel", component.getMessageLabel().toString());
- write("direction", component.getDirection().toString());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, Binding[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((Binding) o1).getName();
- QName x2 = ((Binding) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("bindingComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, Binding component) {
-
- beginElement(tag, idAttribute(component));
-
- write("name", component.getName());
- writeOptionalRef("interface", component.getInterface());
- write("type", component.getType());
- write("bindingFaults", component.getBindingFaults());
- write("bindingOperations", component.getBindingOperations());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
-
- HTTPBindingExtensions http = (HTTPBindingExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_HTTP);
- if (http != null) {
-
- beginElement(WSDLCMHTTP_PREFIX + ":httpBindingExtension");
-
- write(WSDLCMHTTP_PREFIX + ":httpCookies", http.isHttpCookies());
- write(WSDLCMHTTP_PREFIX + ":httpMethodDefault", http
- .getHttpMethodDefault());
- write(WSDLCMHTTP_PREFIX + ":httpQueryParameterSeparatorDefault",
- http.getHttpQueryParameterSeparatorDefault());
- write(WSDLCMHTTP_PREFIX + ":httpTransferCodingDefault", http
- .getHttpTransferCodingDefault());
-
- endElement();
- }
-
- SOAPBindingExtensions soap = (SOAPBindingExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_SOAP);
- if (soap != null) {
-
- beginElement(WSDLCMSOAP_PREFIX + ":soapBindingExtension");
-
- write(WSDLCMSOAP_PREFIX + ":soapMepDefault", soap
- .getSoapMepDefault());
- write(WSDLCMSOAP_PREFIX + ":soapModules", soap.getSoapModules());
- write(WSDLCMSOAP_PREFIX + ":soapUnderlyingProtocols", soap
- .getSoapMepDefault());
- write(WSDLCMSOAP_PREFIX + ":soapVersion", soap.getSoapVersion());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, SOAPModule[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- URI uri1 = ((SOAPModule) o1).getRef();
- URI uri2 = ((SOAPModule) o2).getRef();
-
- return uri1.compareTo(uri2);
- }
- });
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("SoapModuleComponent", components[i]);
-
- endElement();
-
- }
-
- private void write(String tag, SOAPModule component) {
-
- beginElement(tag, idAttribute(component));
-
- write(WSDLCMSOAP_PREFIX + ":ref", component.getRef());
-
- write(WSDLCMSOAP_PREFIX + ":required", component.isRequired()
- .booleanValue());
-
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, BindingFault[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- InterfaceFault if1 = ((BindingFault) o1).getInterfaceFault();
- InterfaceFault if2 = ((BindingFault) o2).getInterfaceFault();
-
- if (if1 == if2)
- return 0;
- if (if1 == null)
- return -1;
- if (if2 == null)
- return 1;
-
- QName x1 = if1.getName();
- QName x2 = if2.getName();
-
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("bindingFaultComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, BindingFault component) {
-
- beginElement(tag, idAttribute(component));
-
- writeRef("interfaceFault", component.getInterfaceFault());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- HTTPBindingFaultExtensions http = (HTTPBindingFaultExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_HTTP);
- if (http != null) {
-
- beginElement(WSDLCMHTTP_PREFIX + ":httpBindingFaultExtension");
-
- write(WSDLCMHTTP_PREFIX + ":httpErrorStatusCode", http
- .getHttpErrorStatusCode());
- write(WSDLCMHTTP_PREFIX + ":httpHeaders", http.getHttpHeaders());
- write(WSDLCMHTTP_PREFIX + ":httpTransferCoding", http
- .getHttpTransferCoding());
-
- endElement();
- }
-
- SOAPBindingFaultExtensions soap = (SOAPBindingFaultExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_SOAP);
- if (soap != null) {
-
- beginElement(WSDLCMSOAP_PREFIX + ":soapBindingFaultExtension");
-
- write(WSDLCMSOAP_PREFIX + ":soapFaultCode", soap.getSoapFaultCode());
- write(WSDLCMSOAP_PREFIX + ":soapFaultSubcodes", soap
- .getSoapFaultSubcodes());
- write(WSDLCMSOAP_PREFIX + ":soapHeaders", soap.getSoapHeaders());
- write(WSDLCMSOAP_PREFIX + ":soapModules", soap.getSoapModules());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, HTTPErrorStatusCode httpErrorStatusCode) {
-
- if (httpErrorStatusCode == null)
- return;
-
- beginElement(tag);
-
- if (httpErrorStatusCode.isCodeUsed()) {
-
- write(WSDLCMHTTP_PREFIX + ":code", httpErrorStatusCode.toString());
- }
-
- endElement();
- }
-
- private void write(String tag, HTTPHeader[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- String n1 = ((HTTPHeader) o1).getName();
- String n2 = ((HTTPHeader) o2).getName();
-
- return n1.compareTo(n2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write(WSDLCMHTTP_PREFIX + ":HttpHeaderComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, HTTPHeader component) {
-
- beginElement(tag, idAttribute(component));
-
- write(WSDLCMHTTP_PREFIX + ":name", component.getName());
-
- writeRef(WSDLCMHTTP_PREFIX + ":typeDefinition", component
- .getTypeDefinition());
-
- write(WSDLCMHTTP_PREFIX + ":required", component.isRequired());
-
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, SOAPFaultSubcodes soapFaultSubcodes) {
-
- beginElement(tag);
- if (soapFaultSubcodes.isQNames()) {
- beginElement(WSDLCMSOAP_PREFIX + ":subcodes");
- QName[] codes = soapFaultSubcodes.getQNames();
- for (int i = 0; i < codes.length; i++) {
- write(WSDLCMSOAP_PREFIX + ":code", codes[i]);
- }
- endElement();
- }
- endElement();
- }
-
- private void write(String tag, SOAPFaultCode soapFaultCode) {
-
- beginElement(tag);
- if (soapFaultCode.isQName()) {
- write(WSDLCMSOAP_PREFIX + ":code", soapFaultCode.getQName());
- }
- endElement();
- }
-
- private void write(String tag, SOAPHeaderBlock[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- ElementDeclaration ed1 = ((SOAPHeaderBlock) o1)
- .getElementDeclaration();
- ElementDeclaration ed2 = ((SOAPHeaderBlock) o2)
- .getElementDeclaration();
-
- if (ed1 == ed2)
- return 0;
- if (ed1 == null)
- return -1;
- if (ed2 == null)
- return 1;
-
- QName x1 = ed1.getName();
- QName x2 = ed2.getName();
-
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write(WSDLCMSOAP_PREFIX + ":SoapHeaderBlockComponent",
- components[i]);
-
- endElement();
- }
-
- private void write(String tag, SOAPHeaderBlock component) {
-
- beginElement(tag, idAttribute(component));
-
- writeRef(WSDLCMSOAP_PREFIX + ":elementDeclaration", component
- .getElementDeclaration());
-
- write(WSDLCMSOAP_PREFIX + ":mustUnderstand", component.mustUnderstand()
- .booleanValue());
-
- write(WSDLCMSOAP_PREFIX + ":required", component.isRequired()
- .booleanValue());
-
- writeRef(WSDLCMSOAP_PREFIX + ":parent", component.getParent());
-
- endElement();
-
- }
-
- private void write(String tag, BindingOperation[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((BindingOperation) o1).getInterfaceOperation()
- .getName();
- QName x2 = ((BindingOperation) o1).getInterfaceOperation()
- .getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("bindingOperationComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, BindingOperation component) {
-
- beginElement(tag, idAttribute(component));
-
- writeRef("interfaceOperation", component.getInterfaceOperation());
- write("bindingFaultReferences", component.getBindingFaultReferences());
- write("bindingMessageReferences", component
- .getBindingMessageReferences());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- HTTPBindingOperationExtensions http = (HTTPBindingOperationExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_HTTP);
- if (http != null) {
-
- beginElement(WSDLCMHTTP_PREFIX + ":httpBindingOperationExtension");
-
- write(WSDLCMHTTP_PREFIX + ":httpFaultSerialization", http
- .getHttpFaultSerialization());
- write(WSDLCMHTTP_PREFIX + ":httpInputSerialization", http
- .getHttpInputSerialization());
- write(WSDLCMHTTP_PREFIX + ":httpLocation", http.getHttpLocation());
- write(WSDLCMHTTP_PREFIX + ":httpLocationIgnoreUncited", http
- .isHttpLocationIgnoreUncited());
- write(WSDLCMHTTP_PREFIX + ":httpMethod", http.getHttpMethod());
- write(WSDLCMHTTP_PREFIX + ":httpOutputSerialization", http
- .getHttpOutputSerialization());
- write(WSDLCMHTTP_PREFIX + ":httpQueryParameterSeparator", http
- .getHttpQueryParameterSeparator());
- write(WSDLCMHTTP_PREFIX + ":httpTransferCodingDefault", http
- .getHttpTransferCodingDefault());
-
- endElement();
- }
-
- SOAPBindingOperationExtensions soap = (SOAPBindingOperationExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_SOAP);
- if (soap != null) {
-
- beginElement(WSDLCMSOAP_PREFIX + ":soapBindingOperationExtension");
-
- write(WSDLCMSOAP_PREFIX + ":soapAction", soap.getSoapAction());
- write(WSDLCMSOAP_PREFIX + ":soapMep", soap.getSoapMep());
- write(WSDLCMSOAP_PREFIX + ":soapModules", soap.getSoapModules());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, BindingMessageReference[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- InterfaceMessageReference i1 = ((BindingMessageReference) o1)
- .getInterfaceMessageReference();
- InterfaceMessageReference i2 = ((BindingMessageReference) o2)
- .getInterfaceMessageReference();
-
- String x1 = i1.getMessageLabel().toString();
- String x2 = i2.getMessageLabel().toString();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("bindingMessageReferenceComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, BindingMessageReference component) {
-
- beginElement(tag, idAttribute(component));
-
- writeRef("interfaceMessageReference", component
- .getInterfaceMessageReference());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- HTTPBindingMessageReferenceExtensions http = (HTTPBindingMessageReferenceExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_HTTP);
- if (http != null) {
-
- beginElement(WSDLCMHTTP_PREFIX + ":httpBindingMessageReferenceExtension");
-
- write(WSDLCMHTTP_PREFIX + ":httpHeaders", http.getHttpHeaders());
- write(WSDLCMHTTP_PREFIX + ":httpTransferCoding", http
- .getHttpTransferCoding());
-
- endElement();
- }
-
- SOAPBindingMessageReferenceExtensions soap = (SOAPBindingMessageReferenceExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_SOAP);
- if (soap != null) {
-
- beginElement(WSDLCMSOAP_PREFIX + ":soapBindingMessageReferenceExtension");
-
- write(WSDLCMSOAP_PREFIX + ":soapHeaders", soap.getSoapHeaders());
- write(WSDLCMSOAP_PREFIX + ":soapModules", soap.getSoapModules());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, BindingFaultReference[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- InterfaceFaultReference i1 = ((BindingFaultReference) o1)
- .getInterfaceFaultReference();
- InterfaceFaultReference i2 = ((BindingFaultReference) o2)
- .getInterfaceFaultReference();
-
- QName q1 = i1.getInterfaceFault().getName();
- QName q2 = i2.getInterfaceFault().getName();
-
- int result = compareQName(q1, q2);
- if (result != 0)
- return result;
-
- String x1 = i1.getMessageLabel().toString();
- String x2 = i2.getMessageLabel().toString();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("bindingFaultReferenceComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, BindingFaultReference component) {
-
- beginElement(tag, idAttribute(component));
-
- writeRef("interfaceFaultReference", component
- .getInterfaceFaultReference());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- SOAPBindingFaultReferenceExtensions soap = (SOAPBindingFaultReferenceExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_SOAP);
- if (soap != null) {
-
- beginElement(WSDLCMSOAP_PREFIX + ":soapBindingFaultReferenceExtension");
-
- write(WSDLCMSOAP_PREFIX + ":soapModules", soap.getSoapModules());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, Service[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((Service) o1).getName();
- QName x2 = ((Service) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("serviceComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, Service component) {
-
- beginElement(tag, idAttribute(component));
-
- write("name", component.getName());
- writeRef("interface", component.getInterface());
- write("endpoints", component.getEndpoints());
- write(FEATURES, component.getFeatures());
- write(PROPERTIES, component.getProperties());
-
- endElement();
- }
-
- private void write(String tag, Endpoint[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- String x1 = ((Endpoint) o1).getName().toString();
- String x2 = ((Endpoint) o2).getName().toString();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++) {
- write("endpointComponent", components[i]);
- }
-
- endElement();
-
- }
-
- private void write(String tag, Endpoint component) {
-
- beginElement(tag, idAttribute(component));
-
- write("name", component.getName());
- writeRef("binding", component.getBinding());
- write("address", component.getAddress());
- write("feaures", component.getFeatures());
- write(PROPERTIES, component.getProperties());
- writeRef(PARENT, component.getParent());
-
- HTTPEndpointExtensions http = (HTTPEndpointExtensions) component
- .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_HTTP);
-
- if (http != null) {
-
- beginElement(WSDLCMHTTP_PREFIX + ":httpEndpointExtension");
-
- write(WSDLCMHTTP_PREFIX + ":httpAuthenticationRealm", http
- .getHttpAuthenticationRealm());
- write(WSDLCMHTTP_PREFIX + ":httpAuthenticationScheme", http
- .getHttpAuthenicationScheme());
-
- endElement();
- }
-
- endElement();
- }
-
- private void write(String tag, HTTPAuthenticationScheme scheme) {
-
- if (scheme == null)
- return;
-
- write(tag, scheme.toString());
- }
-
- private void write(String tag, ElementDeclaration[] components) {
-
- // filter out the XSD elements until Woden fixes the bug
- Vector filteredElements = new Vector();
- for (int i = 0; i < components.length; i++) {
- if (!XSD_NS.equals(components[i].getName().getNamespaceURI()))
- filteredElements.addElement(components[i]);
- }
- components = new ElementDeclaration[filteredElements.size()];
- filteredElements.copyInto(components);
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((ElementDeclaration) o1).getName();
- QName x2 = ((ElementDeclaration) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("elementDeclarationComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, ElementDeclaration component) {
-
- beginElement(tag, idAttribute(component));
-
- write("name", component.getName());
- write("system", component.getSystem());
-
- endElement();
- }
-
- private void write(String tag, TypeDefinition[] components) {
-
- // filter out the XSD non-built-in types until Woden fixes the bug
- Vector filteredTypes = new Vector();
- for (int i = 0; i < components.length; i++) {
- if (!XSD_NS.equals(components[i].getName().getNamespaceURI())) {
- filteredTypes.addElement(components[i]);
- } else {
- if (Arrays.binarySearch(XSD_TYPES, components[i].getName()
- .getLocalPart()) >= 0)
- filteredTypes.addElement(components[i]);
- }
- }
- components = new TypeDefinition[filteredTypes.size()];
- filteredTypes.copyInto(components);
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- QName x1 = ((TypeDefinition) o1).getName();
- QName x2 = ((TypeDefinition) o2).getName();
- return compareQName(x1, x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++)
- write("typeDefinitionComponent", components[i]);
-
- endElement();
- }
-
- private void write(String tag, TypeDefinition component) {
-
- beginElement(tag, idAttribute(component));
-
- write("name", component.getName());
- write("system", component.getSystem());
-
- endElement();
- }
-
- private void write(String tag, Feature[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- URI x1 = ((Feature) o1).getRef();
- URI x2 = ((Feature) o2).getRef();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++) {
- write("featureComponent", components[i]);
- }
- endElement();
- }
-
- private void write(String tag, Feature component) {
-
- beginElement(tag, idAttribute(component));
-
- write("ref", component.getRef());
- write("required", component.isRequired());
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, Property[] components) {
-
- if (components.length == 0)
- return;
-
- Arrays.sort(components, new Comparator() {
-
- public int compare(Object o1, Object o2) {
- URI x1 = ((Property) o1).getRef();
- URI x2 = ((Property) o2).getRef();
- return x1.compareTo(x2);
- }
- });
-
- beginElement(tag);
-
- for (int i = 0; i < components.length; i++) {
- write("propertyComponent", components[i]);
- }
-
- endElement();
- }
-
- private void write(String tag, Property component) {
-
- beginElement(tag, idAttribute(component));
-
- write("ref", component.getRef());
- writeOptionalRef("valueConstraint", component.getValueConstraint());
- writeAny("value", component.getValue());
- writeRef(PARENT, component.getParent());
-
- endElement();
- }
-
- private void write(String tag, QName qname) {
-
- if (qname == null)
- return;
-
- beginElement(tag);
-
- element(WSDLCMBASE_PREFIX + ":namespaceName", qname.getNamespaceURI());
- element(WSDLCMBASE_PREFIX + ":localName", qname.getLocalPart());
-
- endElement();
- }
-
- private void write(String tag, URI uri) {
-
- if (uri == null)
- return;
-
- element(tag, uri.toString());
- }
-
- private void writeAny(String tag, Object o) {
-
- if (o == null)
- return;
-
- // TODO: write element content correctly
- element(tag, o.toString());
- }
-
- private void writeOptionalRef(String tag, Object o) {
-
- if (o == null)
- return;
-
- writeRef(tag, o);
- }
-
- private void writeRef(String tag, Object o) {
-
- emptyElement(tag, refAttribute(o));
- }
-
- private void writeUris(String tag, URI[] uris) {
-
- if (uris.length == 0)
- return;
-
- Arrays.sort(uris);
-
- beginElement(tag);
-
- for (int i = 0; i < uris.length; i++)
- write(WSDLCMBASE_PREFIX + ":uri", uris[i]);
-
- endElement();
- }
-
- private static String id(Object o) {
-
- if (o == null) {
- return "id-null";
- }
-
- return "id-" + o.hashCode();
- }
-
- private static String idAttribute(Object o) {
-
- return "xml:id='" + id(o) + "'";
- }
-
- private static String refAttribute(Object o) {
-
- return "ref='" + id(o) + "'";
- }
-
- private static int compareQName(QName q1, QName q2) {
-
- if (q1.equals(q2))
- return 0;
-
- String n1 = q1.getNamespaceURI();
- String n2 = q2.getNamespaceURI();
- if (n1.equals(n2)) {
- String l1 = q1.getLocalPart();
- String l2 = q2.getLocalPart();
-
- return l1.compareTo(l2);
- } else {
- return n1.compareTo(n2);
- }
}
}
Modified: incubator/woden/java/src/org/apache/woden/ant/XMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/woden/java/src/org/apache/woden/ant/XMLWriter.java?rev=419116&r1=419115&r2=419116&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/ant/XMLWriter.java (original)
+++ incubator/woden/java/src/org/apache/woden/ant/XMLWriter.java Tue Jul 4 16:01:36 2006
@@ -1,6 +1,7 @@
package org.apache.woden.ant;
import java.io.PrintWriter;
+import java.util.HashMap;
import java.util.Stack;
import org.apache.woden.types.NCName;
@@ -12,6 +13,8 @@
*
*/
public class XMLWriter {
+
+ private HashMap registry = new HashMap();
private PrintWriter out;
@@ -263,5 +266,26 @@
}
return y.toString();
+ }
+
+ /**
+ * Registers a namespace writer for this XML writer.
+ *
+ * @param writer the namespace writer
+ */
+ public void register(NamespaceWriter writer) {
+
+ registry.put(writer.getNamespace(), writer);
+ }
+
+ /**
+ * Looks up a namespace writer for this XML writer.
+ *
+ * @param namespace the namespace to look up
+ * @return the namespace writer
+ */
+ public NamespaceWriter lookup(String namespace) {
+
+ return (NamespaceWriter) registry.get(namespace);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org