org.ksoap2.serialization
Class SoapObject

java.lang.Object
  extended by org.ksoap2.serialization.AttributeContainer
      extended by org.ksoap2.serialization.SoapObject
All Implemented Interfaces:
KvmSerializable

public class SoapObject
extends AttributeContainer
implements KvmSerializable

A simple dynamic object that can be used to build soap calls without implementing KvmSerializable

Essentially, this is what goes inside the body of a soap envelope - it is the direct subelement of the body and all further subelements

Instead of this this class, custom classes can be used if they implement the KvmSerializable interface.


Field Summary
protected  String name
          The name of this soap object.
protected  String namespace
          The namespace of this soap object.
protected  Vector properties
          The Vector of properties.
 
Constructor Summary
SoapObject(String namespace, String name)
          Creates a new SoapObject instance.
 
Method Summary
 SoapObject addProperty(PropertyInfo propertyInfo)
          Adds a property (parameter) to the object.
 SoapObject addProperty(PropertyInfo propertyInfo, Object value)
          Deprecated. property info now contains the value
 SoapObject addProperty(String name, Object value)
          Adds a property (parameter) to the object.
 boolean equals(Object obj)
           
 String getName()
           
 String getNamespace()
           
 Object getProperty(int index)
          Get the property at the given index
 Object getProperty(String name)
          Get the property with the given name
 int getPropertyCount()
          Returns the number of properties
 void getPropertyInfo(int index, Hashtable properties, PropertyInfo propertyInfo)
          Deprecated.  
 void getPropertyInfo(int index, PropertyInfo propertyInfo)
          Places PropertyInfo of desired property into a designated PropertyInfo object
 boolean hasProperty(String name)
          Knows whether the given property exists
 SoapObject newInstance()
          Creates a new SoapObject based on this, allows usage of SoapObjects as templates.
 Object safeGetProperty(String name)
          Get a property without chance of throwing an exception
 Object safeGetProperty(String name, Object defaultThing)
          Get a property without chance of throwing an exception.
 void setProperty(int index, Object value)
          Sets a specified property to a certain value.
 String toString()
          Generate a String describing this object.
 
Methods inherited from class org.ksoap2.serialization.AttributeContainer
addAttribute, addAttribute, attributesAreEqual, getAttribute, getAttribute, getAttributeCount, getAttributeInfo, hasAttribute, safeGetAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

namespace

protected String namespace
The namespace of this soap object.


name

protected String name
The name of this soap object.


properties

protected Vector properties
The Vector of properties.

Constructor Detail

SoapObject

public SoapObject(String namespace,
                  String name)
Creates a new SoapObject instance.

Parameters:
namespace - the namespace for the soap object
name - the name of the soap object
Method Detail

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getName

public String getName()

getNamespace

public String getNamespace()

getProperty

public Object getProperty(int index)
Description copied from interface: KvmSerializable
Get the property at the given index

Specified by:
getProperty in interface KvmSerializable

getProperty

public Object getProperty(String name)
Get the property with the given name

Throws:
RuntimeException - if the property does not exist

hasProperty

public boolean hasProperty(String name)
Knows whether the given property exists


safeGetProperty

public Object safeGetProperty(String name)
Get a property without chance of throwing an exception

Returns:
the property if it exists; if not, NullSoapObject is returned

safeGetProperty

public Object safeGetProperty(String name,
                              Object defaultThing)
Get a property without chance of throwing an exception. An object can be provided to this method; if the property is not found, this object will be returned.

Parameters:
defaultThing - the object to return if the property is not found
Returns:
the property if it exists; defaultThing if the property does not exist

getPropertyCount

public int getPropertyCount()
Returns the number of properties

Specified by:
getPropertyCount in interface KvmSerializable
Returns:
the number of properties

getPropertyInfo

public void getPropertyInfo(int index,
                            Hashtable properties,
                            PropertyInfo propertyInfo)
Deprecated. 

Places PropertyInfo of desired property into a designated PropertyInfo object

Specified by:
getPropertyInfo in interface KvmSerializable
Parameters:
index - index of desired property
propertyInfo - designated retainer of desired property
properties - information about the (de)serializer. Not frequently used.

getPropertyInfo

public void getPropertyInfo(int index,
                            PropertyInfo propertyInfo)
Places PropertyInfo of desired property into a designated PropertyInfo object

Parameters:
index - index of desired property
propertyInfo - designated retainer of desired property

newInstance

public SoapObject newInstance()
Creates a new SoapObject based on this, allows usage of SoapObjects as templates. One application is to set the expected return type of a soap call if the server does not send explicit type information.

Returns:
a copy of this.

setProperty

public void setProperty(int index,
                        Object value)
Sets a specified property to a certain value.

Specified by:
setProperty in interface KvmSerializable
Parameters:
index - the index of the specified property
value - the new value of the property

addProperty

public SoapObject addProperty(String name,
                              Object value)
Adds a property (parameter) to the object. This is essentially a sub element.

Parameters:
name - The name of the property
value - the value of the property

addProperty

public SoapObject addProperty(PropertyInfo propertyInfo,
                              Object value)
Deprecated. property info now contains the value

Adds a property (parameter) to the object. This is essentially a sub element.

Parameters:
propertyInfo - designated retainer of desired property
value - the value of the property

addProperty

public SoapObject addProperty(PropertyInfo propertyInfo)
Adds a property (parameter) to the object. This is essentially a sub element.

Parameters:
propertyInfo - designated retainer of desired property

toString

public String toString()
Generate a String describing this object.

Overrides:
toString in class Object
Returns:


Copyright © 2002-2011. All Rights Reserved.