com.arsdigita.acs
Class AdSet

java.lang.Object
  |
  +--com.arsdigita.acs.AdSet
All Implemented Interfaces:
DataSource

public class AdSet
extends Object
implements DataSource

Implements a multiset of name-value pairs. Analogous to ns_set. Not really a Set implementation.... Implemented as Hashtable of Vectors.


Constructor Summary
AdSet()
           
AdSet(HttpServletRequest request)
          Constructs an AdSet out of the parameter/value pairs in the servlet request.
AdSet(Object[][] objects)
          Constructs an AdSet out of an array of arrays of name-value pairs.
AdSet(ServletRequest request)
          Constructs an AdSet out of the parameter/value pairs in the servlet request.
 
Method Summary
 boolean contains(String key)
          Returns true if AdSet contains key.
 void deleteKey(String key)
          Removes key from this.
 String get(String key)
          Gets a value for a given key.
 String[] getAll(String key)
          Returns all values mapped from key.
 String[] keys()
          Returns a list of valid keys in this datasource, for use with get().
 Enumeration keysAndValues()
           
 Enumeration keysAsEnumeration()
           
 boolean next()
          Returns false.
 void put(String key, Object value)
          Adds a key/value pair to this.
 void put(String key, String value)
          Adds a key/value pair to this.
 int rownum()
          Returns the current row number.
 int size()
          Returns number of keys in this AdSet.
 void update(String key, String value)
          Changes the first mapping from key to value.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdSet

public AdSet()

AdSet

public AdSet(ServletRequest request)
Constructs an AdSet out of the parameter/value pairs in the servlet request.
Parameters:
request - The servlet request

AdSet

public AdSet(HttpServletRequest request)
      throws Exception
Constructs an AdSet out of the parameter/value pairs in the servlet request. Handles multipart requests for uploading files; adds an element named param_tmpfile if a supplied form parameter named param is type=FILE.

Warning: this should only be called once for any given servlet request, because we cannot rewind the input stream for a multipart request.

Parameters:
request - The servlet request

AdSet

public AdSet(Object[][] objects)
      throws Exception
Constructs an AdSet out of an array of arrays of name-value pairs.
Parameters:
objects - an array of arrays of name value pairs. The first of the pair must be assignment compatible with String and the second with Object. ie, something of the form:
 new Object[][] = { {"foo", new Foo()},
                    {"bar", new Bar()},
                    {"baz", new Baz()},
                    {"glorp", new Glorp()} }
Method Detail

put

public void put(String key,
                String value)
Adds a key/value pair to this. Ignores null values.
Parameters:
key - The key
name - The value

put

public void put(String key,
                Object value)
Adds a key/value pair to this. Ignores null values.
Parameters:
key - The key
name - The value

get

public String get(String key)
Gets a value for a given key.
Specified by:
get in interface DataSource
Parameters:
key - The key
Returns:
name The first value mapped from key, or null if key is not mapped.

getAll

public String[] getAll(String key)
Returns all values mapped from key.
Parameters:
key - The key
Returns:
An array of all values mapped from key

contains

public boolean contains(String key)
Returns true if AdSet contains key.
Specified by:
contains in interface DataSource

next

public boolean next()
Returns false. For implementing DataSource.
Specified by:
next in interface DataSource

rownum

public int rownum()
           throws DataSourceException
Returns the current row number.
Specified by:
rownum in interface DataSource

update

public void update(String key,
                   String value)
Changes the first mapping from key to value.
Parameters:
key - The key
value - The value

deleteKey

public void deleteKey(String key)
Removes key from this.
Parameters:
key - The key to remove

keys

public String[] keys()
Description copied from interface: DataSource
Returns a list of valid keys in this datasource, for use with get().
Specified by:
keys in interface DataSource
Returns:
An array of keys in this AdSet.

keysAsEnumeration

public Enumeration keysAsEnumeration()
Returns:
An enumeration of keys in this AdSet.

keysAndValues

public Enumeration keysAndValues()
Returns:
An iterator of String[2], where the first element is a key in this and the second element is a value mapped from that key.

size

public int size()
Returns number of keys in this AdSet.
Returns:
the number of keys in this AdSet.