Map Interface

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

The ASP Maps have been extended to allow automatic conversion between the Variant representation and common Java types that have directly analogous Variant types. For example, Object, String, and Date map to IUnknown, BSTR, and OLE Date objects, while intrinsic Java types such as int, boolean, float, and so on, are converted to appropriate Variant object types. For example, you can 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 the data types to the him in an environment that is natural.

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

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;
}

Map Interface Methods

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. Because 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 such as getDouble or getInt. For the OLE Date type, use the getDate method, which will convert the type 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 are trying to retrieve. For example, if the actual Variant is type int, you cannot retrieve it using the getFloat method. If you try 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. Because 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 such as setDouble or setInt. For the java.util.Date type, use the setDate method, which will convert the java.util.Date type to an OLE Date.

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

© 1999 Microsoft Corporation. All rights reserved. Terms of use.