com.ap.jdbcunit
Class MediaStack

java.lang.Object
  extended bycom.ap.jdbcunit.MediaStack
All Implemented Interfaces:
Media

public class MediaStack
extends java.lang.Object
implements Media


Constructor Summary
MediaStack()
           
 
Method Summary
 void close()
          Close the media, the media flushes everything that need to be saved to the persistent store.
 void closeTrack()
          Close the current track
 int countTracks()
           
 void delete()
          Deletes everything that is related to this media
 void deleteTrack(java.lang.String dbURL, java.lang.String sql)
          Deletes the track identified by the given URL and SQL statement
 boolean existsTrack(java.lang.String dbURL, java.lang.String sql)
          Answers the question "Does this media contain some SQL statement?"
 void foreachTrack(MediaVisitor visitor)
          Start visiting all the tracks contained in this media.
 java.util.Iterator getTrack(java.lang.String dbURL, java.lang.String sql)
          Return the track (the results) identified by the given URL and SQL statement
 void newTrack(java.lang.String dbURL, java.lang.String sql, java.util.List columnNames)
          Adds a new track of result, the result was obtained by executing the given SQL statement on the database (identified by the URL).
 void open()
          Open the media so that it can be used
 void push(Media media)
           
 void write(java.util.List row)
          Add a row to the current track.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaStack

public MediaStack()
Method Detail

push

public void push(Media media)

open

public void open()
Description copied from interface: Media
Open the media so that it can be used

Specified by:
open in interface Media

close

public void close()
Description copied from interface: Media
Close the media, the media flushes everything that need to be saved to the persistent store.

Specified by:
close in interface Media

delete

public void delete()
Description copied from interface: Media
Deletes everything that is related to this media

Specified by:
delete in interface Media

countTracks

public int countTracks()
Specified by:
countTracks in interface Media
Returns:
the number of tracks (result sets) that are contained in this media

foreachTrack

public void foreachTrack(MediaVisitor visitor)
Description copied from interface: Media
Start visiting all the tracks contained in this media.

Specified by:
foreachTrack in interface Media
Parameters:
visitor - the MediaVisitor object interrested in handling all the tracks contained in this media

existsTrack

public boolean existsTrack(java.lang.String dbURL,
                           java.lang.String sql)
Description copied from interface: Media
Answers the question "Does this media contain some SQL statement?"

Specified by:
existsTrack in interface Media
Parameters:
dbURL - the database URL as String
sql - the SQL statement as String
Returns:
true if this media contain the given statement executed on the given database

newTrack

public void newTrack(java.lang.String dbURL,
                     java.lang.String sql,
                     java.util.List columnNames)
Description copied from interface: Media
Adds a new track of result, the result was obtained by executing the given SQL statement on the database (identified by the URL). The result is a table with the diven header (column names). When the method return the new created track is the current track.

Specified by:
newTrack in interface Media
Parameters:
dbURL - the database that returned some result
sql - the executed SQL statement
columnNames - the list of all the columns
See Also:
Media.write

write

public void write(java.util.List row)
Description copied from interface: Media
Add a row to the current track.

Specified by:
write in interface Media
Parameters:
row - a list of values (the size of the list should be thes as the current track's number of columns.

closeTrack

public void closeTrack()
Description copied from interface: Media
Close the current track

Specified by:
closeTrack in interface Media

getTrack

public java.util.Iterator getTrack(java.lang.String dbURL,
                                   java.lang.String sql)
Description copied from interface: Media
Return the track (the results) identified by the given URL and SQL statement

Specified by:
getTrack in interface Media
Parameters:
dbURL - the database URL
sql - the SQL statement
Returns:
an iterator or the result ot the query execution

deleteTrack

public void deleteTrack(java.lang.String dbURL,
                        java.lang.String sql)
Description copied from interface: Media
Deletes the track identified by the given URL and SQL statement

Specified by:
deleteTrack in interface Media
Parameters:
dbURL - the database URL
sql - the SQL statement