Interface Map

The Map interface implements an associative set, where a name can be mapped to a value. Maps wrap the ASP collection which store Variants, but provide only the methods for getting/setting a value in the collection. Objects that implement Map, and which actually encapsulate the objects (i.e., ObjectDictionary, RequestDictionary) will also typically extend java.util.Dictionary, and the implement the Enumerator interface

The ASP Maps have been extended to allow auto-conversion between the variant representation and common Java types that have directly analogous variant types. So, for example, such as Object, String, Date, would map to IUnknown, BSTR, and OLE Date objects while intrinsic Java types such as int, boolean, float, etc., would be converted to appropriate Variant object types. So, for example, the programmer could use the Session collection, store and retrieve an integer or java.util.Date object, and conversions between the Java and Variant types would be done transparently. The goal is to allow the Java developer to interact with data types that are comfortable and natural, while exposing them to the script developer that is natural for that environment.

Note that there are some Maps, such as the various Request collections, that are read-only. For these, calls to a put method should throw an AspComponentException exception.

public interface Map {
    int
getType(String name);
    Object
getObject(String name) throws ClassCastException;
    boolean
getBoolean(String name) throws ClassCastException;
    byte
getByte(String name) throws ClassCastException;
    short
getShort(String name) throws ClassCastException;
    char
getChar(String name) throws ClassCastException;
    int
getInt(String name) throws ClassCastException;
    long
getLong(String name) throws ClassCastException;
    float
getFloat(String name) throws ClassCastException;
    double
getDouble(String name) throws ClassCastException;
    String
getString(String name) throws ClassCastException;
    java.util.Date
getDate(String name) throws ClassCastException;
    Variant
getVariant(String name) throws ClassCastException;
    void
setObject(String name, Object o) throws AspComponentException;
    void
setBoolean(String name,boolean b) throws AspComponentException;
    void
setByte(String name,byte b) throws AspComponentException;
    void
setShort(String name,short s) throws AspComponentException;
    void
setInt(String name,int i) throws AspComponentException;
    void
setFloat(String name,float f) throws AspComponentException;
    void
setDouble(String name,double d) throws AspComponentException;
    void
setString(String name,String str) throws AspComponentException;
    void
setDate(String name, java.util.Date d) throws AspComponentException;
    void
setVariant(String name, Variant var)
                                       throws AspComponentException;
}

int getType(String name)

Returns the variant type of the object identified by name.

Note, this method does not actually retrieve the object from the Map, but rather the value of the type field of the Variant that holds the object.

Object getObject(String name) throws ClassCastException

boolean getBoolean(String name) throws ClassCastException

byte getByte(String name) throws ClassCastException

short getShort(String name) throws ClassCastException

char getChar(String name) throws ClassCastException

int getInt(String name) throws ClassCastException

long getLong(String name) throws ClassCastException

float getFloat(String name) throws ClassCastException

double getDouble(String name) throws ClassCastException

String getString(String name) throws ClassCastException

java.util.Date getDate(String name) throws ClassCastException

Variant getVariant(String name) throws ClassCastException

Returns the object associated with name as the requested type.   Since all ASP collections store objects as variants, they can hold objects of various types.  The various get members allow you to retrieve the objects in the collection, converting them to the appropriate Java types.  For intrinsic types, you should use methods like getDouble, or getInt.  For the OLE Date type, use the getDate, which will convert it to a java.util.Date.

The getVariant method can be used to retrieve the object as the actual Variant stored in the collection.

Note: You can only retrieve an object whose variant type matches the type that you attempting to retrieve it as.  For example, if the actual variant is type int, you can not retrieve it using the getFloat method.  If you attempt to obtain a given object using a method that does not match the actual type, a ClassCastException will be thrown.

void setObject(String name, Object o) throws AspComponentException

void setBoolean(String name,boolean b) throws AspComponentException

void setByte(String name,byte b) throws AspComponentException

void setShort(String name,short s) throws AspComponentException

void setInt(String name,int i) throws AspComponentException

void setFloat(String name,float f) throws AspComponentException

void setDouble(String name,double d) throws AspComponentException

void setString(String name,String str) throws AspComponentException

void setDate(String name, Date d) throws AspComponentException

void setVariant(String name, Variant var) throws AspComponentException

Sets the object associated with name as the specified type.  Since all ASP collections store objects as variants, they can hold objects of various types.   The various set members allow you to store objects in the collection, passing them in as the native Java types, they will be converted to the appropriate variants for you. For intrinsic types, you should use methods like setDouble, or setInt.   For the java.util.Date type, use the setDate, which will convert it to an OLE Date.

The setVariant method can be used to store an actual Variant in the collection, with no conversion.