FileDocCategorySizeDatePackage
RPCParam.javaAPI DocApache Axis 1.48351Sat Apr 22 18:57:28 BST 2006org.apache.axis.message

RPCParam

public class RPCParam extends MessageElement implements Serializable
An RPC parameter
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
protected static Log
log
private Object
value
private int
countSetCalls
private org.apache.axis.description.ParameterDesc
paramDesc
private Boolean
wantXSIType
Do we definitely want (or don't want) to send xsi:types? If null (the default), just do whatever our SerializationContext is configured to do. If TRUE or FALSE, the SerializationContext will do what we want.
private static Method
valueSetMethod
Constructors Summary
public RPCParam(String name, Object value)
Constructor for building up messages.

     
        Class cls = RPCParam.class;
        try {
            valueSetMethod = cls.getMethod("set", new Class[] {Object.class});
        } catch (NoSuchMethodException e) {
            log.error(Messages.getMessage("noValue00", "" + e));
            throw new RuntimeException(e.getMessage());
        }
    
        this(new QName("", name), value);
    
public RPCParam(QName qname, Object value)

        super(qname);
        if (value instanceof java.lang.String) {
            try {
                this.addTextNode((String) value);
            } catch (SOAPException e) {
                throw new RuntimeException(Messages.getMessage("cannotCreateTextNode00"));
            } 
        } else {
            this.value = value;
        }
    
public RPCParam(String namespace, String name, Object value)

        this(new QName(namespace, name), value);
    
Methods Summary
public javax.xml.soap.SOAPElementaddTextNode(java.lang.String s)

see
javax.xml.soap.SOAPElement#addTextNode(java.lang.String)

        value = s;
        return super.addTextNode(s);
    
public java.lang.ObjectgetObjectValue()

        return value;
    
public org.apache.axis.description.ParameterDescgetParamDesc()

        return paramDesc;
    
public java.lang.StringgetValue()

        return getValueDOM();
    
public static java.lang.reflect.MethodgetValueSetMethod()

        return valueSetMethod;
    
public java.lang.BooleangetXSITypeGeneration()

        return this.wantXSIType;
    
protected voidoutputImpl(org.apache.axis.encoding.SerializationContext context)

        serialize(context);
    
private voidreadObject(java.io.ObjectInputStream in)

        if (in.readBoolean()) {
            setQName(new QName((String)in.readObject(),
                              (String)in.readObject()));
        } 
        in.defaultReadObject();
    
public voidserialize(org.apache.axis.encoding.SerializationContext context)

        // Set the javaType to value's class unless 
        // parameter description information exists.
        // Set the xmlType using the parameter description
        // information.  (an xmlType=null causes the
        // serialize method to search for a compatible xmlType)
        Class javaType = value == null ? null: value.getClass();
        QName xmlType = null;
        // we'll send a null unless our description tells us
        // that we may be omitted
        Boolean sendNull = Boolean.TRUE;
        if (paramDesc != null) {
            if (javaType == null) {
                javaType = paramDesc.getJavaType() != null ?
                    paramDesc.getJavaType(): javaType;
            } else if (!(javaType.equals(paramDesc.getJavaType()))) {
                Class clazz = JavaUtils.getPrimitiveClass(javaType);
                if(clazz == null || !clazz.equals(paramDesc.getJavaType())) {
                    if (!(javaType.equals(
                            JavaUtils.getHolderValueType(paramDesc.getJavaType())))) {

                        // This must (assumedly) be a polymorphic type - in ALL
                        // such cases, we must send an xsi:type attribute.
                        wantXSIType = Boolean.TRUE;
                    }
                }
            }
            xmlType = paramDesc.getTypeQName();
            QName itemQName = paramDesc.getItemQName();
            if (itemQName == null) {
                MessageContext mc = context.getMessageContext();
                if (mc != null && mc.getOperation() != null && mc.getOperation().getStyle() == Style.DOCUMENT) {
                    itemQName = Constants.QNAME_LITERAL_ITEM;
                }
            }
            context.setItemQName(itemQName);

            QName itemType = paramDesc.getItemType();
            context.setItemType(itemType);

            // don't send anything if we're able to be omitted,
            // although we'll prefer to send xsi:nill if possible
            if (paramDesc.isOmittable() && !paramDesc.isNillable())
                sendNull = Boolean.FALSE;
        }
        context.serialize(getQName(),  // element qname
                          null,   // no extra attrs
                          value,  // value
                          xmlType, // java/xml type
                          sendNull, wantXSIType);
    
public voidset(java.lang.Object newValue)
This set method is registered during deserialization to set the deserialized value. If the method is called multiple times, the value is automatically changed into a container to hold all of the values.

param
newValue is the deserialized object

        countSetCalls++;
        // If this is the first call,
        // simply set the value.
        if (countSetCalls==1) {
            this.value = newValue;
            return;
        }
        // If this is the second call, create an
        // ArrayList to hold all the values
        else if (countSetCalls==2) {
            ArrayList list = new ArrayList();
            list.add(this.value);
            this.value = list;
        } 
        // Add the new value to the list
        ((ArrayList) this.value).add(newValue);
    
public voidsetObjectValue(java.lang.Object value)

        this.value = value;
    
public voidsetParamDesc(org.apache.axis.description.ParameterDesc paramDesc)

        this.paramDesc = paramDesc;
    
public voidsetRPCCall(RPCElement call)

        parent = call;
    
public voidsetValue(java.lang.String value)

see
javax.xml.soap.Node#setValue(java.lang.String)

        this.value = value;
        super.setValue(value);
    
public voidsetXSITypeGeneration(java.lang.Boolean value)

        this.wantXSIType = value; 
    
private voidwriteObject(java.io.ObjectOutputStream out)

        if (getQName() == null) {
            out.writeBoolean(false);
        } else {
            out.writeBoolean(true);
            out.writeObject(getQName().getNamespaceURI());
            out.writeObject(getQName().getLocalPart());
        }
        out.defaultWriteObject();