import java.io.*;
import java.util.*;
import com.perforce.api.*;

public class StatFile {

  public static void main(String[] argv) {
    /* Please see the Common.java file to see how the environment is being
     * set up. This is important, but it is common to all the examples.
     */
    Env env = Common.setup();
    String filename = "//guest/david_markley/p4package/index.html";
    Vector fileHistory = new Vector();
    FileEntry fent;
    Debug.setDebugLevel(Debug.ERROR);

    try {
	fileHistory = FileEntry.getFileLog(env, filename);

	// For display/testing purposes only
	System.out.println("Filelog for "+filename+": \n");
	Enumeration logs = fileHistory.elements();
	while(logs.hasMoreElements()) {
	    fent = (FileEntry)logs.nextElement();
	    fent.sync();  //Uncomment for exact time.
	    System.out.println("\tRev: "+fent.getHeadRev());
	    System.out.println("\t\tChange: "+fent.getHeadChange());
	    System.out.println("\t\tAction: "+fent.getHeadAction());
	    System.out.println("\t\tType: "+fent.getHeadType());
	    System.out.println("\t\tOwner: "+fent.getOwner());
	    System.out.println("\t\tDate: "+fent.getHeadTimeString());
	    System.out.println("\t\tDescription: "+fent.getDescription());
	}

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    Utils.cleanUp();
  }
}
