
/**
 * This class represents a known-item which is a known portion of a video.
 * It inherits attributes and behaviour from Item abstract class.
 *
 * @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 KnownItem extends Item{

    /**
     * Constructs a KnownItem object with the given parameters.
     *
     * @param     start The start time of the item in a defined format ("*h*m*s*ms").
     * @param     stop The stop time of the item in a defined format ("*h*m*s*ms").
     * @param     src The source of the item or video that the item is part of.
     * @exception TransitionDefinitionException Thrown if the pre frame is not strictly less than the post frame.
     */
    public KnownItem(String start, String stop, String src) throws Exception{
    	super(start, stop, src);
    }
    /**
     * Returns a known-item representing the intersection with the given item.
     *
     */
	public KnownItem intersection(Item t){
	
		try{
			if(this.src.equals(t.getSrc()) && this.intersected(t))
				return (new KnownItem(maxTime(this.start, t.getStart()), 
								 minTime(this.stop, t.getStop()), this.src));
			else
				return null;
		}
		catch(Exception e){
			return null;
		}
	}
    /**
     * Returns a Xml formatted string representation of this known-item. 
     * For example: "<knownItem src="aVideoName" start="1h10m10s" stop="1h10m25s" />"
     * 
     */
	public String toString(){
		return "<knownItem src=\""+this.src+"\" start=\""+this.start+"\" stop=\""+this.stop+
				"\"/>"+System.getProperty("line.separator");	
	}
	/**
     * Returns a Xml formatted string representation of this item and its start and stop values,
     * without a line separator.
     * For example: "<knownItem src="aVideoName" start="1h10m10s" stop="1h10m25s" />"
     * 
     */
	public String toStringOut(){
		return "<knownItem src=\""+this.src+"\" start=\""+this.start+"\" stop=\""+this.stop+
				"\"/>";
	}
}