com.arsdigita.acs
Class AdSet

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

public class AdSet
extends java.lang.Object
implements DataSource

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


Field Summary
static java.lang.String cvsId
           
 
Constructor Summary
  AdSet()
           
protected AdSet(javax.servlet.http.HttpServletRequest request)
          Constructs an AdSet out of the parameter/value pairs in the servlet request.
  AdSet(java.lang.Object[][] objects)
          Constructs an AdSet out of an array of arrays of name-value pairs.
  AdSet(javax.servlet.ServletRequest request)
          Constructs an AdSet out of the parameter/value pairs in the servlet request.
 
Method Summary
 boolean contains(java.lang.String key)
          Returns true if AdSet contains key.
 void deleteKey(java.lang.String key)
          Removes key from this.
 java.lang.String get(java.lang.String key)
          Gets a value for a given key.
 java.lang.String[] getAll(java.lang.String key)
          Returns all values mapped from key.
 java.lang.String join(java.lang.String delim)
          Returns the values of an AdSet joined (in the Tcl sense) into one String.
 java.lang.String[] keys()
          Returns a list of valid keys in this datasource, for use with get().
 java.util.Enumeration keysAndValues()
           
 java.util.Enumeration keysAsEnumeration()
           
 boolean next()
          Returns false.
 void put(java.lang.String key, java.lang.Object value)
          Adds a key/value pair to this.
 void put(java.lang.String key, java.lang.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(java.lang.String key, java.lang.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
 

Field Detail

cvsId

public static final java.lang.String cvsId
Constructor Detail

AdSet

public AdSet()

AdSet

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

AdSet

protected AdSet(javax.servlet.http.HttpServletRequest request)
         throws java.lang.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. User code should never call this constructor; use the AdSet in acs.form instead.

Parameters:
request - The servlet request

AdSet

public AdSet(java.lang.Object[][] objects)
      throws java.lang.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

join

public java.lang.String join(java.lang.String delim)
Returns the values of an AdSet joined (in the Tcl sense) into one String. Order of the list is dependent on (ie, the same as) the order returned by the keysAndValues() method.
Parameters:
delim - what will be used to delimit the entries; null will default to ", ". Note however that "" will not default to anything.

put

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

put

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

get

public java.lang.String get(java.lang.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 java.lang.String[] getAll(java.lang.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(java.lang.String key)
Returns true if AdSet contains key.
Specified by:
contains in interface DataSource

next

public boolean next()
Returns false. For implementing DataSource.

rownum

public int rownum()
           throws DataSourceException
Returns the current row number.

update

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

deleteKey

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

keys

public java.lang.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 java.util.Enumeration keysAsEnumeration()
Returns:
An enumeration of keys in this AdSet.

keysAndValues

public java.util.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.