com.sun.electric.tool.user
Class ErrorLogger

java.lang.Object
  extended by com.sun.electric.tool.user.ErrorLogger
All Implemented Interfaces:
java.io.Serializable

public class ErrorLogger
extends java.lang.Object
implements java.io.Serializable

Class for logging errors. Holds a log of errors:

ErrorLogger errorLogger = ErrorLogger.newInstance(String s): get new logger for s

MessageLog errorLog = errorLogger.logError(string msg, cell c, int k): Create a new log with message 'msg', for cell 'c', with sortKey 'k'.

Various methods for adding highlights to errorLog:

To end logging, call errorLogger.termLogging(boolean explain).

See Also:
Serialized Form

Nested Class Summary
static class ErrorLogger.MessageLog
          Create a Log of a single message.
static class ErrorLogger.WarningLog
          Create a Log of a single warning.
static class ErrorLogger.XMLParser
           
 
Constructor Summary
ErrorLogger()
           
 
Method Summary
 void addMessages(java.util.List<ErrorLogger.MessageLog> messages)
           
 void clearAllLogs()
          Method to remove all errors and warnings
 boolean clearLogs(Cell cell)
          Removes all errors and warnings associated with Cell cell.
 void deleteLog(int i)
           
 void deleteMessages(java.util.List<ErrorLogger.MessageLog> messages)
           
 void exportErrorLogger(java.lang.String filePath)
           
 boolean findMessage(Cell cell, Geometric geom1, Cell cell2, Geometric geom2, boolean searchInError)
          Method to determine if existing report was not looged already as error or warning
 java.util.List<ErrorLogger.MessageLog> getAllLogs(Cell cell)
          Method to retrieve all MessageLogs associated with a given Cell
 java.lang.String getGroupName(int sortKey)
          Get a group name for a sortKey.
 java.lang.String getInfo()
          Method to retrieve general information about the errorLogger.
 ErrorLogger.MessageLog getLog(int i)
           
 int getLogIndex(ErrorLogger.MessageLog log)
           
 java.util.Iterator<ErrorLogger.MessageLog> getLogs()
          Method to list all logged errors and warnings.
 int getNumErrors()
          Method to tell the number of logged errors.
 int getNumLogs()
          Method to tell the number of logged errors.
 int getNumMessages(Cell cell, boolean searchInError)
           
 int getNumWarnings()
          Method to tell the number of logged errors.
 java.util.Map<java.lang.Integer,java.lang.String> getSortKeyToGroupNames()
           
 java.lang.String getSystem()
           
 boolean isPersistent()
           
 void logError(java.lang.String message, CellId cellId, int sortKey)
          Factory method to log an error message.
 void logError(java.lang.String message, Cell cell, int sortKey)
          Factory method to log an error message.
 void logError(java.lang.String message, EPoint pt, Cell cell, int sortKey)
          Factory method to log an error message.
 void logError(java.lang.String message, Export pp, int sortKey)
          Factory method to log an error message.
 void logError(java.lang.String message, Geometric geom, Cell cell, VarContext context, int sortKey)
          Factory method to log an error message.
 void logError(java.lang.String message, int sortKey)
          Factory method to log an error message.
 void logError(java.lang.String message, PolyBase poly, Cell cell, int sortKey)
          Factory method to log an error message.
 void logMessage(java.lang.String message, java.util.List<?> list, Cell cell, int sortKey, boolean isErrorMsg)
          Factory method to log an error or warning message.
 void logMessage(java.lang.String message, java.util.List<Geometric> geomList, java.util.List<PolyBase> polyList, Cell cell, int sortKey, boolean errorMsg)
          Factory method to log an error or a warning message.
 void logMessageWithLines(java.lang.String message, java.util.List<?> list, java.util.List<EPoint> lineList, Cell cell, int sortKey, boolean isErrorMsg)
          Factory method to log an error or warning message with extra lines.
 void logWarning(java.lang.String message, Cell cell, int sortKey)
          Factory method to log a warning message.
 void logWarning(java.lang.String message, Export pp, Cell cell, VarContext context, int sortKey)
          Factory method to log a warning message.
 void logWarning(java.lang.String message, Geometric geom, Cell cell, VarContext context, int sortKey)
          Factory method to log a warning message.
static ErrorLogger newInstance(java.lang.String system)
          Create a new ErrorLogger instance.
static ErrorLogger newInstance(java.lang.String system, boolean persistent)
          Create a new ErrorLogger instance.
static ErrorLogger read(IdReader reader)
           
 void setGroupName(int sortKey, java.lang.String groupName)
          Set a group name for a sortKey.
 void sortLogs()
          Method to sort the errors by their "key" (a value provided to "logerror()").
 void termLogging_(boolean terminate)
           
 void termLogging(boolean explain)
          Method called when all errors are logged.
 void write(IdWriter writer)
           
static void writeXmlHeader(java.lang.String indent, java.io.PrintStream ps)
          Function to write all headers related to ErrorLogger classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorLogger

public ErrorLogger()
Method Detail

writeXmlHeader

public static void writeXmlHeader(java.lang.String indent,
                                  java.io.PrintStream ps)
Function to write all headers related to ErrorLogger classes.

Parameters:
indent -
ps -

getSortKeyToGroupNames

public java.util.Map<java.lang.Integer,java.lang.String> getSortKeyToGroupNames()

getSystem

public java.lang.String getSystem()

isPersistent

public boolean isPersistent()

write

public void write(IdWriter writer)
           throws java.io.IOException
Throws:
java.io.IOException

read

public static ErrorLogger read(IdReader reader)
                        throws java.io.IOException
Throws:
java.io.IOException

newInstance

public static ErrorLogger newInstance(java.lang.String system)
Create a new ErrorLogger instance.

Returns:
a new ErrorLogger for logging errors

newInstance

public static ErrorLogger newInstance(java.lang.String system,
                                      boolean persistent)
Create a new ErrorLogger instance.

Returns:
a new ErrorLogger for logging errors

addMessages

public void addMessages(java.util.List<ErrorLogger.MessageLog> messages)

deleteMessages

public void deleteMessages(java.util.List<ErrorLogger.MessageLog> messages)

logError

public void logError(java.lang.String message,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
sortKey - the sorting order of this message.

logError

public void logError(java.lang.String message,
                     Cell cell,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
cell - the cell in which this message applies.
sortKey - the sorting order of this message.

logError

public void logError(java.lang.String message,
                     CellId cellId,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
cellId - the Id of the cell in which this message applies.
sortKey - the sorting order of this message.

logError

public void logError(java.lang.String message,
                     Geometric geom,
                     Cell cell,
                     VarContext context,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
geom - the node or arc to display
cell - the cell in which this message applies.
context - the VarContext of the Cell.
sortKey - the sorting order of this message.

logError

public void logError(java.lang.String message,
                     Export pp,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
pp - the Export to display
sortKey - the sorting order of this message.

logError

public void logError(java.lang.String message,
                     EPoint pt,
                     Cell cell,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
pt - the point to display
cell - the cell in which this message applies.
sortKey - the sorting order of this message.

logError

public void logError(java.lang.String message,
                     PolyBase poly,
                     Cell cell,
                     int sortKey)
Factory method to log an error message.

Parameters:
message - the string to display.
poly - the polygon to display
cell - the cell in which this message applies.
sortKey - the sorting order of this message.

logMessage

public void logMessage(java.lang.String message,
                       java.util.List<?> list,
                       Cell cell,
                       int sortKey,
                       boolean isErrorMsg)
Factory method to log an error or warning message.

Parameters:
message - the string to display.
list - a list of nodes, arcs, exports or polygons, points to display. Must be no null.
cell - the cell in which this message applies.
sortKey - the sorting order of this message.
isErrorMsg - true if an error message is logged

logMessageWithLines

public void logMessageWithLines(java.lang.String message,
                                java.util.List<?> list,
                                java.util.List<EPoint> lineList,
                                Cell cell,
                                int sortKey,
                                boolean isErrorMsg)
Factory method to log an error or warning message with extra lines.

Parameters:
message - the string to display.
list - a list of nodes, arcs, exports or polygons, points to display. Must be no null.
lineList - a list of points defining a set of lines (may be null)
cell - the cell in which this message applies.
sortKey - the sorting order of this message.
isErrorMsg - true if an error message is logged

logMessage

public void logMessage(java.lang.String message,
                       java.util.List<Geometric> geomList,
                       java.util.List<PolyBase> polyList,
                       Cell cell,
                       int sortKey,
                       boolean errorMsg)
Factory method to log an error or a warning message.

Parameters:
message - the string to display.
geomList - a list of nodes or arcs to display (may be null).
polyList - a list of polygons to display (may be null).
cell - the cell in which this message applies.
sortKey - the sorting order of this message.
errorMsg -

logWarning

public void logWarning(java.lang.String message,
                       Cell cell,
                       int sortKey)
Factory method to log a warning message.

Parameters:
message - the string to display.
cell - the cell in which this message applies.
sortKey - the sorting order of this message.

logWarning

public void logWarning(java.lang.String message,
                       Geometric geom,
                       Cell cell,
                       VarContext context,
                       int sortKey)
Factory method to log a warning message.

Parameters:
message - the string to display.
geom - a node or arc to display.
cell - the cell in which this message applies.
context - the VarContext of the Cell.
sortKey - the sorting order of this message.

logWarning

public void logWarning(java.lang.String message,
                       Export pp,
                       Cell cell,
                       VarContext context,
                       int sortKey)
Factory method to log a warning message.

Parameters:
message - the string to display.
pp - an Exports to display.
cell - the cell in which this message applies.
context - the VarContext of the Cell.
sortKey - the sorting order of this message.

getNumMessages

public int getNumMessages(Cell cell,
                          boolean searchInError)

findMessage

public boolean findMessage(Cell cell,
                           Geometric geom1,
                           Cell cell2,
                           Geometric geom2,
                           boolean searchInError)
Method to determine if existing report was not looged already as error or warning


clearAllLogs

public void clearAllLogs()
Method to remove all errors and warnings


getAllLogs

public java.util.List<ErrorLogger.MessageLog> getAllLogs(Cell cell)
Method to retrieve all MessageLogs associated with a given Cell

Parameters:
cell - the Cell to examine.
Returns:
all MessageLogs associated with the Cell.

clearLogs

public boolean clearLogs(Cell cell)
Removes all errors and warnings associated with Cell cell.

Parameters:
cell - the cell for which errors and warnings will be removed
Returns:
true if any log was removed.

exportErrorLogger

public void exportErrorLogger(java.lang.String filePath)

setGroupName

public void setGroupName(int sortKey,
                         java.lang.String groupName)
Set a group name for a sortKey. Doing so causes all errors with this sort key to be put in a sub-tree of the error tree with the groupName as the title of the sub-tree.

Parameters:
sortKey - the error log sortKey
groupName - the group name

getGroupName

public java.lang.String getGroupName(int sortKey)
Get a group name for a sortKey. It creates the hash map if it doesn't exist

Parameters:
sortKey - the error log sortKey
Returns:
the group name. Null if no group name was found

termLogging

public void termLogging(boolean explain)
Method called when all errors are logged. Initializes pointers for replay of errors.


termLogging_

public void termLogging_(boolean terminate)

getInfo

public java.lang.String getInfo()
Method to retrieve general information about the errorLogger.

Returns:
general information about the errorLogger.

sortLogs

public void sortLogs()
Method to sort the errors by their "key" (a value provided to "logerror()"). Obviously, this should be called after all errors have been reported.


getNumErrors

public int getNumErrors()
Method to tell the number of logged errors.

Returns:
the number of "ErrorLog" objects logged.

getNumWarnings

public int getNumWarnings()
Method to tell the number of logged errors.

Returns:
the number of "ErrorLog" objects logged.

getNumLogs

public int getNumLogs()
Method to tell the number of logged errors.

Returns:
the number of "ErrorLog" objects logged.

getLog

public ErrorLogger.MessageLog getLog(int i)

getLogIndex

public int getLogIndex(ErrorLogger.MessageLog log)

getLogs

public java.util.Iterator<ErrorLogger.MessageLog> getLogs()
Method to list all logged errors and warnings.

Returns:
an Iterator over all of the "ErrorLog" objects.

deleteLog

public void deleteLog(int i)