FileDocCategorySizeDatePackage
CastorSerializer.javaAPI DocApache Axis 1.46094Sat Apr 22 18:57:26 BST 2006org.apache.axis.encoding.ser.castor

CastorSerializer

public class CastorSerializer extends Object implements org.apache.axis.encoding.Serializer
Castor serializer
author
Olivier Brand (olivier.brand@vodafone.com)
author
Steve Loughran
version
1.0

Fields Summary
protected static Log
log
Constructors Summary
Methods Summary
public java.lang.StringgetMechanismType()

        return Constants.AXIS_SAX;
    
public voidserialize(javax.xml.namespace.QName name, org.xml.sax.Attributes attributes, java.lang.Object value, org.apache.axis.encoding.SerializationContext context)
Serialize a Castor object.

param
name
param
attributes
param
value this must be a castor object for marshalling
param
context
throws
IOException for XML schema noncompliance, bad object type, and any IO trouble.


                                                                   
       
                           
                           
                           
              
        try {
            AxisContentHandler hand = new AxisContentHandler(context);
            Marshaller marshaller = new Marshaller(hand);

            // Don't include the DOCTYPE, otherwise an exception occurs due to
            //2 DOCTYPE defined in the document. The XML fragment is included in
            //an XML document containing already a DOCTYPE
            marshaller.setMarshalAsDocument(false);
            String localPart = name.getLocalPart();
            int arrayDims = localPart.indexOf('[");
            if (arrayDims != -1) {
                localPart = localPart.substring(0, arrayDims);
            }
            marshaller.setRootElement(localPart);
            // Marshall the Castor object into the stream (sink)
            marshaller.marshal(value);
        } catch (MarshalException me) {
            log.error(Messages.getMessage("castorMarshalException00"), me);
            throw new IOException(Messages.getMessage(
                    "castorMarshalException00")
                    + me.getLocalizedMessage());
        } catch (ValidationException ve) {
            log.error(Messages.getMessage("castorValidationException00"), ve);
            throw new IOException(Messages.getMessage(
                    "castorValidationException00")
                    + ve.getLocation() + ": " + ve.getLocalizedMessage());
        }
    
public org.w3c.dom.ElementwriteSchema(java.lang.Class javaType, org.apache.axis.wsdl.fromJava.Types types)
Return XML schema for the specified type, suitable for insertion into the <types> element of a WSDL document, or underneath an <element> or <attribute> declaration.

param
javaType the Java Class we're writing out schema for
param
types the Java2WSDL Types object which holds the context for the WSDL being generated.
return
a type element containing a schema simpleType/complexType
see
org.apache.axis.wsdl.fromJava.Types

        return null;