arlut.csd.ganymede
Class DBLogEvent

java.lang.Object
  |
  +--arlut.csd.ganymede.DBLogEvent

public class DBLogEvent
extends java.lang.Object

This class stores a complete record of a single sub-transactional event, to be emitted to the DBLog log file, or sent to a set of users via email..


Field Summary
(package private)  Invid admin
           
(package private)  java.lang.String adminName
           
(package private)  boolean augmented
           
(package private) static boolean debug
           
(package private)  java.lang.String description
           
(package private)  java.lang.String eventClassToken
           
(package private)  SharedStringBuffer multibuffer
          We use this buffer everywhere in this class to avoid creating StringBuffers as much as we can.
(package private)  java.lang.String notifyList
           
(package private)  java.util.Vector notifyVect
           
(package private)  java.util.Vector objects
           
(package private)  java.lang.String subject
           
(package private)  java.util.Date time
           
(package private)  java.lang.String transactionID
           
 
Constructor Summary
DBLogEvent(java.lang.String line)
          Constructor to construct a DBLogEvent from a log file line.
DBLogEvent(java.lang.String line, SharedStringBuffer multibuffer)
          Constructor to construct a DBLogEvent from a log file line.
DBLogEvent(java.lang.String eventClassToken, java.lang.String description, Invid admin, java.lang.String adminName, java.util.Vector objects, java.util.Vector notifyVec)
           
DBLogEvent(java.lang.String eventClassToken, java.lang.String description, Invid admin, java.lang.String adminName, java.util.Vector objects, java.util.Vector notifyVec, SharedStringBuffer multibuffer)
           
DBLogEvent(java.util.Vector addresses, java.lang.String subject, java.lang.String description, Invid admin, java.lang.String adminName, java.util.Vector objects)
          Constructor to be used for a mailout event.
 
Method Summary
private  SharedStringBuffer escapeStr(java.lang.String in)
          This method makes the provided String safe for inclusion in the log file.
 void loadLine(java.lang.String line)
          This method sets the fields for this DBLogEvent from a logfile line.

Note that this method is designed to reuse as many of this DBLogEvent's fields as possible, so if external code keeps references to this.time or this.objects or this.notifyVect, that code should either not call loadLine(), or should make its own copies of those objects.
static void main(java.lang.String[] argv)
          Debug rig..
private  java.lang.String readNextField(char[] line, int startIndex)
          scan the string for this field, decoding backslash escapes in the process
private  java.util.Vector readNotifyVect(char[] line, int startIndex, java.util.Vector result)
          This method reads a vector of email addresses from a log file line
private  java.util.Vector readObjectVect(char[] line, int startIndex, java.util.Vector result)
          This method reads a vector of invid's from a log file line
private  int scanSep(char[] line, int startIndex)
          find the index of the next field separator, taking into account escaped chars
 void setMailTargets(java.util.Vector mailTargets)
          This method is used by DBLog to set the list of email targets that this event will need to be mailed to.
 java.lang.String toString()
           
 void writeEntry(java.io.PrintWriter logWriter, java.util.Date currentTime, java.lang.String transactionID)
          This method writes out this event to a log stream
private  void writeSep(java.io.PrintWriter logWriter)
          Write a field separator to the log file
private  void writeStr(java.io.PrintWriter logWriter, java.lang.String in)
          Write a field to the log file, escaping it for safety
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

debug

static final boolean debug

eventClassToken

java.lang.String eventClassToken

description

java.lang.String description

admin

Invid admin

adminName

java.lang.String adminName

objects

java.util.Vector objects

notifyList

java.lang.String notifyList

notifyVect

java.util.Vector notifyVect

subject

java.lang.String subject

transactionID

java.lang.String transactionID

time

java.util.Date time

augmented

boolean augmented

multibuffer

SharedStringBuffer multibuffer
We use this buffer everywhere in this class to avoid creating StringBuffers as much as we can. Note that everything in this class that uses the multibuffer must be sure not to call other methods that themselves use the multibuffer in a way that would conflict. We're buying efficiency with some fragility here.
Constructor Detail

DBLogEvent

public DBLogEvent(java.util.Vector addresses,
                  java.lang.String subject,
                  java.lang.String description,
                  Invid admin,
                  java.lang.String adminName,
                  java.util.Vector objects)
Constructor to be used for a mailout event.
Parameters:
addresses - A vector of Strings listing email addresses to send notification of this event to.
eventClassToken - a short string specifying a DBObject record describing the general category for the event
description - Descriptive text to be entered in the record of the event
admin - Invid pointing to the adminPersona that fired the event, if any
adminName - String containing the name of the adminPersona that fired the event, if any
objects - A vector of invids of objects involved in this event.

DBLogEvent

public DBLogEvent(java.lang.String eventClassToken,
                  java.lang.String description,
                  Invid admin,
                  java.lang.String adminName,
                  java.util.Vector objects,
                  java.util.Vector notifyVec)
Parameters:
eventClassToken - a short string specifying a DBObject record describing the general category for the event
description - Descriptive text to be entered in the record of the event
admin - Invid pointing to the adminPersona that fired the event, if any
adminName - String containing the name of the adminPersona that fired the event, if any
objects - A vector of invids of objects involved in this event.
notifyVec - A vector of Strings listing email addresses to send notification of this event to.

DBLogEvent

public DBLogEvent(java.lang.String eventClassToken,
                  java.lang.String description,
                  Invid admin,
                  java.lang.String adminName,
                  java.util.Vector objects,
                  java.util.Vector notifyVec,
                  SharedStringBuffer multibuffer)
Parameters:
eventClassToken - a short string specifying a DBObject record describing the general category for the event
description - Descriptive text to be entered in the record of the event
admin - Invid pointing to the adminPersona that fired the event, if any
adminName - String containing the name of the adminPersona that fired the event, if any
objects - A vector of invids of objects involved in this event.
notifyVec - A vector of Strings listing email addresses to send notification of this event to.
multibuffer - A SharedStringBuffer that this event can use to avoid an extra object create. If you provide a StringBuffer here, be aware that this object may use it both when this object is being constructed, and by the writeEvent() method. The code that uses this DBLogEvent may do whatever it likes with the buffer between method calls to this DBLogEvent, but any method called on this object might clobber the buffer.

DBLogEvent

public DBLogEvent(java.lang.String line)
           throws java.io.IOException
Constructor to construct a DBLogEvent from a log file line.
Parameters:
line - A line from the Ganymede log file

DBLogEvent

public DBLogEvent(java.lang.String line,
                  SharedStringBuffer multibuffer)
           throws java.io.IOException
Constructor to construct a DBLogEvent from a log file line.
Parameters:
line - A line from the Ganymede log file
multibuffer - A SharedStringBuffer that this event can use to avoid an extra object create
Method Detail

loadLine

public void loadLine(java.lang.String line)
              throws java.io.IOException
This method sets the fields for this DBLogEvent from a logfile line.

Note that this method is designed to reuse as many of this DBLogEvent's fields as possible, so if external code keeps references to this.time or this.objects or this.notifyVect, that code should either not call loadLine(), or should make its own copies of those objects.

scanSep

private int scanSep(char[] line,
                    int startIndex)
find the index of the next field separator, taking into account escaped chars

readNextField

private java.lang.String readNextField(char[] line,
                                       int startIndex)
scan the string for this field, decoding backslash escapes in the process

readObjectVect

private java.util.Vector readObjectVect(char[] line,
                                        int startIndex,
                                        java.util.Vector result)
This method reads a vector of invid's from a log file line
Parameters:
line - The character array containing the Invid's to be extracted
startIndex - Where to start scanning the Invid's from in the line
result - The vector to place the results in, or null if this method should create its own result vector.

readNotifyVect

private java.util.Vector readNotifyVect(char[] line,
                                        int startIndex,
                                        java.util.Vector result)
This method reads a vector of email addresses from a log file line
Parameters:
line - The character array containing the addresses's to be extracted
startIndex - Where to start scanning the addresses's from in the line
result - The vector to place the results in, or null if this method should create its own result vector.

writeEntry

public void writeEntry(java.io.PrintWriter logWriter,
                       java.util.Date currentTime,
                       java.lang.String transactionID)
This method writes out this event to a log stream

setMailTargets

public void setMailTargets(java.util.Vector mailTargets)
This method is used by DBLog to set the list of email targets that this event will need to be mailed to.

writeSep

private final void writeSep(java.io.PrintWriter logWriter)
Write a field separator to the log file

writeStr

private final void writeStr(java.io.PrintWriter logWriter,
                            java.lang.String in)
Write a field to the log file, escaping it for safety

escapeStr

private final SharedStringBuffer escapeStr(java.lang.String in)
This method makes the provided String safe for inclusion in the log file.

main

public static void main(java.lang.String[] argv)
Debug rig.. this will scan a log file and attempt to parse lines out of it

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object