import java.util.*;
/**
 * This class represents the results for one system identified by its ID.
 * One system has several segmentation results corresponding to the run of this system on a video.
 * used in shot boundary detection task programs of TREC 2001.
 *
 * @author NIST-ITL-IAD-Retrieval Group
 * This software was produced by NIST, an agency of the
 * U.S. government, and by statute is not subject to copyright in the
 * United States. Recipients of this software assume all
 * responsibilities associated with its operation, modification and
 * maintenance.
 *
 */
public class systemResult{

	/**
     * The segmentations for this system are stored in this Hashtable. 
     * The key is the name of the video the segmentation is done for.
     *     
     */
	private Hashtable segmentations = new Hashtable();
	/**
     * The system ID of the results.
     *     
     */
	private String sysId;
	
	/**
     * Instanciate a systemResult object with only the given system ID.
     * 
     */	
	public systemResult(String sysId){
		this.sysId = sysId;
	}
	/**
     * Add the given segmentation to the system results.
     * 
     */	
	public void addSegmentation(Segmentation s){
		if(s.getVideoName() == null){
			System.out.println("PROBLEM");
		}
		segmentations.put(s.getVideoName(), s);
	}
	/**
     * Returns an enumeration of segmentations.
     * 
     */	
	public Enumeration getSegmentations(){
		return segmentations.elements();	
	}
	/**
     * Returns the system ID.
     * 
     */
	public String getSysId(){
		return this.sysId; 
	}
	/**
     * Returns a Vector containing video names of the segmentations.
     * 
     */	
	public Vector getSegmentationsVideoNames(){
		Vector toReturn = new Vector();
		Enumeration e = segmentations.elements();
		while(e.hasMoreElements()){		
			Segmentation s = (Segmentation) e.nextElement();	
			toReturn.add(s.getVideoName());
		}
		return toReturn;
	}
    /**
     * Returns an Xml String of the system results including all segmentations.
     * 
     */		
	public String toString(){
		String toReturn = "<shotBoundaryResult sysId="+sysId+">"+System.getProperty("line.separator");
		Enumeration e = segmentations.elements();
		while(e.hasMoreElements()){
			Segmentation s = (Segmentation) e.nextElement();
			toReturn += s.toString();
		}
		toReturn += "</shotBoundaryResult>"+System.getProperty("line.separator");
		return toReturn;
	}
}