home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / LogRecord.java < prev    next >
Text File  |  1998-11-05  |  3KB  |  68 lines

  1. // Copyright (c) 1997, 1998 Symantec, Inc. All Rights Reserved.
  2.  
  3. import java.io.Serializable;
  4.  
  5. /*
  6. This class holds the results of one parsed log file line.
  7. It implements the Sortable interface so that it may be sorted with
  8. the quicksort utility method.
  9. It was written manually.
  10. It has no UI code.
  11. */
  12. public class LogRecord implements Serializable, Sortable {
  13.     // Parse line results
  14.     public String remoteHost;           // domain name/IP address of host requesting pages
  15.     public String remoteUserLogname;    // name of remote user
  16.     public String authenticatedUserName;// the user authenticated namae
  17.     public long requestTimestamp;       // time the request was made
  18.     public String clientRequest;        // the request that was made
  19.     public int httpStatusCode;          // the request HTTP result code
  20.     /* Unused in analysis so no need to have:
  21.     public int bytesTransferred;
  22.     public String referringURL;
  23.     public String userAgent;        // browser/agent info
  24.     public boolean bExtraText;     // There is extra text at the end of this line (ignored)
  25.     */
  26.  
  27.     // Constructs a log record, initializing its fields from the given log parse record.
  28.     public LogRecord(LogFile.Parser.LogParseRecord logParseRec) {
  29.         remoteHost = logParseRec.remoteHost.toString();
  30.         remoteUserLogname = logParseRec.remoteUserLogname.toString();
  31.         authenticatedUserName = logParseRec.authenticatedUserName.toString();
  32.         requestTimestamp = logParseRec.requestTimestamp;
  33.         clientRequest = logParseRec.clientRequest.toString();
  34.         httpStatusCode = logParseRec.httpStatusCode;
  35.         /* Unused in analysis so no need to have:
  36.         bytesTransferred = logParseRec.bytesTransferred;
  37.         referringURL = logParseRec.referringURL.toString();
  38.         userAgent = logParseRec.userAgent.toString();
  39.         bExtraText = logParseRec.bExtraText;
  40.         */
  41.             //{{INIT_CONTROLS
  42.         //}}
  43. }
  44.  
  45.     // -- Implement the Sortable interface
  46.     
  47.     // A Sortable interface method.
  48.     // Returns true if this "is before" the given obj
  49.     public boolean isLessThan(Object obj) {
  50.         if(obj instanceof LogRecord) {
  51.             LogRecord r = (LogRecord)obj;
  52.             return requestTimestamp > r.requestTimestamp;
  53.         }
  54.         return false;
  55.     }
  56.     
  57.     // A Sortable interface method.
  58.     // Returns true if this "is before or equal to" the given obj
  59.     public boolean isLessThanOrEqual(Object obj) {
  60.         if(obj instanceof LogRecord) {
  61.             LogRecord r = (LogRecord)obj;
  62.             return requestTimestamp >= r.requestTimestamp;
  63.         }
  64.         return false;
  65.     }
  66.     //{{DECLARE_CONTROLS
  67.     //}}
  68. }