FileDocCategorySizeDatePackage
VectorSerializer.javaAPI DocApache Axis 1.44649Sat Apr 22 18:57:26 BST 2006org.apache.axis.encoding.ser

VectorSerializer

public class VectorSerializer extends Object implements org.apache.axis.encoding.Serializer
A VectorSerializer is be used to serialize and deserialize Vectors using the SOAP-ENC encoding style.

author
Rich Scheuerle (scheu@us.ibm.com)

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

 return Constants.AXIS_SAX; 
public booleanisRecursive(org.apache.axis.utils.IdentityHashMap map, java.util.Vector vector)

        map.add(vector);
        boolean recursive = false;
        for(int i=0;i<vector.size() && !recursive;i++)
        {
            Object o = vector.get(i);
            if(o instanceof Vector) {
                if(map.containsKey(o)) {
                    return true;
                } else { 
                    recursive = isRecursive(map, (Vector)o);
                }
            }
        }
        return recursive;
    
public voidserialize(javax.xml.namespace.QName name, org.xml.sax.Attributes attributes, java.lang.Object value, org.apache.axis.encoding.SerializationContext context)
Serialize a Vector Walk the collection of keys, serializing each key/value pair inside an element.

param
name the desired QName for the element
param
attributes the desired attributes for the element
param
value the Object to serialize
param
context the SerializationContext in which to do all this
exception
IOException


                                                           
         
                             
         
    
        if (!(value instanceof Vector))
            throw new IOException(
                Messages.getMessage("noVector00", "VectorSerializer", 
                                     value.getClass().getName()));

        Vector vector = (Vector)value;
        
        // Check for circular references. 
        if(isRecursive(new IdentityHashMap(), vector)){
            throw new IOException(Messages.getMessage("badVector00"));
        }
        
        context.startElement(name, attributes);
        for (Iterator i = vector.iterator(); i.hasNext(); )
        {
            Object item = i.next();
            context.serialize(Constants.QNAME_LITERAL_ITEM,  null, item);
        }
        context.endElement();
    
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

        Element complexType = types.createElement("complexType");
        complexType.setAttribute("name", "Vector");
        types.writeSchemaTypeDecl(Constants.SOAP_VECTOR, complexType);
        Element seq = types.createElement("sequence");
        complexType.appendChild(seq);

        Element element = types.createElement("element");
        element.setAttribute("name", "item");
        element.setAttribute("minOccurs", "0");
        element.setAttribute("maxOccurs", "unbounded");
        element.setAttribute("type", "xsd:anyType");
        seq.appendChild(element);

        return complexType;