org.apache.axis.wsdl.fromJava
Class Types

java.lang.Object
  extended by org.apache.axis.wsdl.fromJava.Types

public class Types
extends java.lang.Object

Description:

This class is used to recursively serializes a Java Class into an XML Schema representation.

It has utility methods to create a schema node, assosiate namespaces to the various types

Author:
unascribed

Field Summary
protected static org.apache.commons.logging.Log log
          Field log
 
Constructor Summary
Types(javax.wsdl.Definition def, TypeMapping tm, TypeMapping defaultTM, Namespaces namespaces, java.lang.String targetNamespace, java.util.List stopClasses, ServiceDesc serviceDesc)
          This class serailizes a Class to XML Schema.
Types(javax.wsdl.Definition def, TypeMapping tm, TypeMapping defaultTM, Namespaces namespaces, java.lang.String targetNamespace, java.util.List stopClasses, ServiceDesc serviceDesc, Emitter emitter)
          This class serailizes a Class to XML Schema.
 
Method Summary
 org.w3c.dom.Element createArrayElement(java.lang.String componentTypeName)
          Method createArrayElement
 org.w3c.dom.Element createAttributeElement(java.lang.String elementName, java.lang.Class javaType, QName xmlType, boolean nullable, org.w3c.dom.Document docHolder)
          Create Attribute Element with a given name and type
 org.w3c.dom.Element createElement(java.lang.String elementName)
          Create a DOM Element in this context
 org.w3c.dom.Element createElement(java.lang.String elementName, java.lang.String elementType, boolean nullable, boolean omittable, org.w3c.dom.Document docHolder)
          Create Element with a given name and type
 org.w3c.dom.Element createElementWithAnonymousType(java.lang.String elementName, java.lang.Class fieldType, boolean omittable, org.w3c.dom.Document ownerDocument)
          Write an <element> with an anonymous internal ComplexType
 org.w3c.dom.Element createLiteralArrayElement(java.lang.String componentType, QName itemName)
          Create an array which is a wrapper type for "item" elements of a component type.
static java.lang.String getLocalNameFromFullName(java.lang.String full)
          Utility method to get the local class name from a fully qualified java class name
 Namespaces getNamespaces()
          Return the namespaces object for the current context
static java.lang.String getPackageNameFromFullName(java.lang.String full)
          Utility method to get the package name from a fully qualified java class name
 java.lang.String getQNameString(QName qname)
          Return a string suitable for representing a given QName in the context of this WSDL document.
 ServiceDesc getServiceDesc()
          return the service description
 java.util.List getStopClasses()
          Return the list of classes that we should not emit WSDL for.
 QName getTypeQName(java.lang.Class javaType)
          Return the QName of the specified javaType
 void insertTypesFragment(org.w3c.dom.Document doc)
          Inserts the type fragment into the given wsdl document and ensures that definitions from each embedded schema are allowed to reference schema components from the other sibling schemas.
 boolean isAcceptableAsAttribute(java.lang.Class type)
          Is the given class acceptable as an attribute
static boolean isArray(java.lang.Class clazz)
           
protected  boolean isBeanCompatible(java.lang.Class javaType, boolean issueErrors)
          isBeanCompatible
static boolean isEnumClass(java.lang.Class cls)
          Returns true if indicated type matches the JAX-RPC enumeration class.
static boolean isNullable(java.lang.Class type)
          Determines if the field is nullable.
 void loadInputSchema(java.lang.String inputSchema)
          Loads the types from the input schema file.
 void loadInputTypes(java.lang.String inputWSDL)
          Load the types from the input wsdl file.
 void updateNamespaces()
          Method updateNamespaces
 void writeElementDecl(QName qname, java.lang.Class javaType, QName typeQName, boolean nillable, QName itemQName)
          Create a top-level element declaration in our generated schema
 QName writeElementForPart(java.lang.Class type, QName qname)
          Write out an element referenced by a part element attribute.
 org.w3c.dom.Element writeEnumType(QName qName, java.lang.Class cls)
          Write Enumeration Complex Type (Only supports enumeration classes of string types)
 void writeSchemaElement(QName qName, org.w3c.dom.Element element)
          Deprecated. Please use writeSchemaElement(String namespaceURI, Element element)
 void writeSchemaElement(java.lang.String namespaceURI, org.w3c.dom.Element element)
          Write out the given Element into the appropriate schema node.
 void writeSchemaElementDecl(QName qname, org.w3c.dom.Element element)
          Method writeSchemaElementDecl
 void writeSchemaTypeDecl(QName qname, org.w3c.dom.Element element)
          Method writeSchemaTypeDecl
 java.lang.String writeType(java.lang.Class type)
          Write a schema representation for the given Class.
 java.lang.String writeType(java.lang.Class type, QName qName)
          Write a schema representation for the given Class.
 QName writeTypeAndSubTypeForPart(java.lang.Class type, QName qname)
          Write out a type (and its subtypes) referenced by a part type attribute.
 QName writeTypeForPart(java.lang.Class type, QName qname)
          Write out a type referenced by a part type attribute.
 void writeWrappedParameter(org.w3c.dom.Element sequence, java.lang.String name, QName type, java.lang.Class javaType)
          Write a parameter (a sub-element) into a sequence generated by writeWrapperElement() above.
 org.w3c.dom.Element writeWrapperElement(QName qname, boolean request, boolean hasParams)
          Write the element definition for a WRAPPED operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Field log

Constructor Detail

Types

public Types(javax.wsdl.Definition def,
             TypeMapping tm,
             TypeMapping defaultTM,
             Namespaces namespaces,
             java.lang.String targetNamespace,
             java.util.List stopClasses,
             ServiceDesc serviceDesc)
This class serailizes a Class to XML Schema. The constructor provides the context for the streamed node within the WSDL document

Parameters:
def - WSDL Definition Element to declare namespaces
tm - TypeMappingRegistry to handle known types
defaultTM - default TM
namespaces - user defined or autogenerated namespace and prefix maps
targetNamespace - targetNamespace of the document
stopClasses -
serviceDesc -

Types

public Types(javax.wsdl.Definition def,
             TypeMapping tm,
             TypeMapping defaultTM,
             Namespaces namespaces,
             java.lang.String targetNamespace,
             java.util.List stopClasses,
             ServiceDesc serviceDesc,
             Emitter emitter)
This class serailizes a Class to XML Schema. The constructor provides the context for the streamed node within the WSDL document

Parameters:
def - WSDL Definition Element to declare namespaces
tm - TypeMappingRegistry to handle known types
defaultTM - default TM
namespaces - user defined or autogenerated namespace and prefix maps
targetNamespace - targetNamespace of the document
stopClasses -
serviceDesc -
emitter - Java2Wsdl emitter
Method Detail

isArray

public static boolean isArray(java.lang.Class clazz)

getNamespaces

public Namespaces getNamespaces()
Return the namespaces object for the current context

Returns:

loadInputSchema

public void loadInputSchema(java.lang.String inputSchema)
                     throws java.io.IOException,
                            javax.wsdl.WSDLException,
                            org.xml.sax.SAXException,
                            javax.xml.parsers.ParserConfigurationException
Loads the types from the input schema file.

Parameters:
inputSchema - file or URL
Throws:
java.io.IOException
javax.wsdl.WSDLException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

loadInputTypes

public void loadInputTypes(java.lang.String inputWSDL)
                    throws java.io.IOException,
                           javax.wsdl.WSDLException,
                           org.xml.sax.SAXException,
                           javax.xml.parsers.ParserConfigurationException
Load the types from the input wsdl file.

Parameters:
inputWSDL - file or URL
Throws:
java.io.IOException
javax.wsdl.WSDLException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

writeTypeForPart

public QName writeTypeForPart(java.lang.Class type,
                              QName qname)
                       throws AxisFault
Write out a type referenced by a part type attribute.

Parameters:
type - Class to generate the XML Schema info for
qname - QName of the type. If null, qname is defaulted from the class.
Returns:
the QName of the generated Schema type, null if void, if the Class type cannot be converted to a schema type then xsd:anytype is returned.
Throws:
AxisFault

writeTypeAndSubTypeForPart

public QName writeTypeAndSubTypeForPart(java.lang.Class type,
                                        QName qname)
                                 throws AxisFault
Write out a type (and its subtypes) referenced by a part type attribute.

Parameters:
type - Class to generate the XML Schema info for
qname - QName of the type. If null, qname is defaulted from the class.
Returns:
the QName of the generated Schema type, null if void, if the Class type cannot be converted to a schema type then xsd:anytype is returned.
Throws:
AxisFault

writeElementForPart

public QName writeElementForPart(java.lang.Class type,
                                 QName qname)
                          throws AxisFault
Write out an element referenced by a part element attribute.

Parameters:
type - Class to generate the XML Schema info for
qname - QName of the element. If null, qname is defaulted from the class.
Returns:
the QName of the generated Schema type, null if no element
Throws:
AxisFault

writeWrapperElement

public org.w3c.dom.Element writeWrapperElement(QName qname,
                                               boolean request,
                                               boolean hasParams)
                                        throws AxisFault
Write the element definition for a WRAPPED operation. This will write out any necessary namespace/schema declarations, an an element definition with an internal (anonymous) complexType. The name of the element will be *foo*Request or *foo*Response depending on whether the request boolean is true. If the operation contains parameters, then we also generate a >sequence< node underneath the complexType, and return it for later use by writeWrappedParameter() below.

Parameters:
qname - the desired element QName
request - true if we're writing the request wrapper, false if writing the response.
hasParams - true if there are parameters, and thus a sequence node is needed
Returns:
a DOM Element for the sequence, inside which we'll write the parameters as elements, or null if there are no parameters
Throws:
AxisFault

writeWrappedParameter

public void writeWrappedParameter(org.w3c.dom.Element sequence,
                                  java.lang.String name,
                                  QName type,
                                  java.lang.Class javaType)
                           throws AxisFault
Write a parameter (a sub-element) into a sequence generated by writeWrapperElement() above.

Parameters:
sequence - the <sequence> in which we're writing
name - is the name of an element to add to the wrapper element.
type - is the QName of the type of the element.
javaType -
Throws:
AxisFault

getTypeQName

public QName getTypeQName(java.lang.Class javaType)
Return the QName of the specified javaType

Parameters:
javaType - input javaType Class
Returns:
QName

getQNameString

public java.lang.String getQNameString(QName qname)
Return a string suitable for representing a given QName in the context of this WSDL document. If the namespace of the QName is not yet registered, we will register it up in the Definitions.

Parameters:
qname - a QName (typically a type)
Returns:
a String containing a standard "ns:localPart" rep of the QName

getPackageNameFromFullName

public static java.lang.String getPackageNameFromFullName(java.lang.String full)
Utility method to get the package name from a fully qualified java class name

Parameters:
full - input class name
Returns:
package name

getLocalNameFromFullName

public static java.lang.String getLocalNameFromFullName(java.lang.String full)
Utility method to get the local class name from a fully qualified java class name

Parameters:
full - input class name
Returns:
package name

writeSchemaTypeDecl

public void writeSchemaTypeDecl(QName qname,
                                org.w3c.dom.Element element)
                         throws AxisFault
Method writeSchemaTypeDecl

Parameters:
qname -
element -
Throws:
AxisFault

writeSchemaElementDecl

public void writeSchemaElementDecl(QName qname,
                                   org.w3c.dom.Element element)
                            throws AxisFault
Method writeSchemaElementDecl

Parameters:
qname -
element -
Throws:
AxisFault

writeSchemaElement

public void writeSchemaElement(QName qName,
                               org.w3c.dom.Element element)
                        throws AxisFault
Deprecated. Please use writeSchemaElement(String namespaceURI, Element element)

Parameters:
qName - qName to get the namespace of the schema node
element - the Element to append to the Schema node
Throws:
AxisFault

writeSchemaElement

public void writeSchemaElement(java.lang.String namespaceURI,
                               org.w3c.dom.Element element)
                        throws AxisFault
Write out the given Element into the appropriate schema node. If need be create the schema node as well

Parameters:
namespaceURI - namespace this node should get dropped into
element - the Element to append to the Schema node
Throws:
AxisFault

writeType

public java.lang.String writeType(java.lang.Class type)
                           throws AxisFault
Write a schema representation for the given Class. Recurse through all the public fields as well as fields represented by java bean compliant accessor methods.

Then return the qualified string representation of the generated type

Parameters:
type - Class for which to generate schema
Returns:
a prefixed string for the schema type
Throws:
AxisFault

writeType

public java.lang.String writeType(java.lang.Class type,
                                  QName qName)
                           throws AxisFault
Write a schema representation for the given Class. Recurse through all the public fields as well as fields represented by java bean compliant accessor methods.

Then return the qualified string representation of the generated type

Parameters:
type - Class for which to generate schema
qName - of the type to write
Returns:
a prefixed string for the schema type or null if problems occur
Throws:
AxisFault

createArrayElement

public org.w3c.dom.Element createArrayElement(java.lang.String componentTypeName)
Method createArrayElement

Parameters:
componentTypeName -
Returns:

createLiteralArrayElement

public org.w3c.dom.Element createLiteralArrayElement(java.lang.String componentType,
                                                     QName itemName)
Create an array which is a wrapper type for "item" elements of a component type. This is basically the unencoded parallel to a SOAP-encoded array.

Parameters:
componentType -
itemName - the QName of the inner element (right now we only use the localPart)
Returns:

isEnumClass

public static boolean isEnumClass(java.lang.Class cls)
Returns true if indicated type matches the JAX-RPC enumeration class. Note: supports JSR 101 version 0.6 Public Draft

Parameters:
cls -
Returns:

writeEnumType

public org.w3c.dom.Element writeEnumType(QName qName,
                                         java.lang.Class cls)
                                  throws java.lang.NoSuchMethodException,
                                         java.lang.IllegalAccessException,
                                         AxisFault
Write Enumeration Complex Type (Only supports enumeration classes of string types)

Parameters:
qName - QName of type.
cls - class of type
Returns:
Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
AxisFault

writeElementDecl

public void writeElementDecl(QName qname,
                             java.lang.Class javaType,
                             QName typeQName,
                             boolean nillable,
                             QName itemQName)
                      throws AxisFault
Create a top-level element declaration in our generated schema

Parameters:
qname -
javaType -
typeQName -
nillable - nillable attribute of the element
itemQName -
Throws:
AxisFault

createElement

public org.w3c.dom.Element createElement(java.lang.String elementName,
                                         java.lang.String elementType,
                                         boolean nullable,
                                         boolean omittable,
                                         org.w3c.dom.Document docHolder)
Create Element with a given name and type

Parameters:
elementName - the name of the created element
elementType - schema type representation of the element
nullable - nullable attribute of the element
omittable -
docHolder -
Returns:
the created Element

createAttributeElement

public org.w3c.dom.Element createAttributeElement(java.lang.String elementName,
                                                  java.lang.Class javaType,
                                                  QName xmlType,
                                                  boolean nullable,
                                                  org.w3c.dom.Document docHolder)
                                           throws AxisFault
Create Attribute Element with a given name and type

Parameters:
elementName - the name of the created element
javaType -
xmlType -
nullable - nullable attribute of the element
docHolder -
Returns:
the created Element
Throws:
AxisFault

isAcceptableAsAttribute

public boolean isAcceptableAsAttribute(java.lang.Class type)
Is the given class acceptable as an attribute

Parameters:
type - input Class
Returns:
true if the type is a simple, enum type or extends SimpleType

isNullable

public static boolean isNullable(java.lang.Class type)
Determines if the field is nullable. All non-primitives are nillable.

Parameters:
type - input Class
Returns:
true if nullable

updateNamespaces

public void updateNamespaces()
Method updateNamespaces


insertTypesFragment

public void insertTypesFragment(org.w3c.dom.Document doc)
Inserts the type fragment into the given wsdl document and ensures that definitions from each embedded schema are allowed to reference schema components from the other sibling schemas.

Parameters:
doc -

getStopClasses

public java.util.List getStopClasses()
Return the list of classes that we should not emit WSDL for.

Returns:

createElement

public org.w3c.dom.Element createElement(java.lang.String elementName)
Create a DOM Element in this context

Parameters:
elementName -
Returns:

isBeanCompatible

protected boolean isBeanCompatible(java.lang.Class javaType,
                                   boolean issueErrors)
isBeanCompatible

Parameters:
javaType - Class
issueErrors - if true, issue messages if not compatible Returns true if it appears that this class is a bean and can be mapped to a complexType
Returns:

createElementWithAnonymousType

public org.w3c.dom.Element createElementWithAnonymousType(java.lang.String elementName,
                                                          java.lang.Class fieldType,
                                                          boolean omittable,
                                                          org.w3c.dom.Document ownerDocument)
                                                   throws AxisFault
Write an <element> with an anonymous internal ComplexType

Parameters:
elementName -
fieldType -
omittable -
ownerDocument -
Returns:
Throws:
AxisFault

getServiceDesc

public ServiceDesc getServiceDesc()
return the service description

Returns:


Copyright ? 2005 Apache Web Services Project. All Rights Reserved.