genopt.simulation
Class ErrorChecker

java.lang.Object
  extended by genopt.simulation.ErrorChecker
All Implemented Interfaces:
java.lang.Cloneable

public class ErrorChecker
extends java.lang.Object
implements java.lang.Cloneable

Object that scans a String array for any number of possible error messages. Instances of this class are used to detect whether the simulation program terminated with an error.

This project was carried out at:

and supported by

GenOpt Copyright (c) 1998-2011, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

Version:
GenOpt(R) 3.1.0 (December 8, 2011)

Author:
Michael Wetter

Field Summary
protected  java.lang.String[] errInd
          Array with error messages that may be written by the simulation program.
private static java.lang.String LS
          System dependent line separator
protected  int nErr
          Number of error messages.
 
Constructor Summary
ErrorChecker()
          Constructor.
ErrorChecker(java.lang.String[] ErrorIndicator)
          Constructor that assigns the strings of error messages that may be written by the simulation program in case the simulation terminates with an error.
 
Method Summary
 java.util.Vector<java.lang.String> check(java.lang.String fileName, java.lang.String AdditionalErrorInformation)
          Checks the argument for possible error messages.
protected  java.lang.Object clone()
          Clones the object.
 java.lang.String getErrorString(int Position)
          Gets a single possible error string.
 int getNumberOfErrors()
          Gets the number of possible error strings.
static void main(java.lang.String[] args)
          The main method.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LS

private static final java.lang.String LS
System dependent line separator


errInd

protected java.lang.String[] errInd
Array with error messages that may be written by the simulation program.


nErr

protected int nErr
Number of error messages.

Constructor Detail

ErrorChecker

public ErrorChecker()
Constructor. Does nothing.


ErrorChecker

public ErrorChecker(java.lang.String[] ErrorIndicator)
Constructor that assigns the strings of error messages that may be written by the simulation program in case the simulation terminates with an error.

Parameters:
ErrorIndicator - Array of strings that contain all messages that are written to a log file by the simulation program in case of an error.
Method Detail

clone

protected java.lang.Object clone()
Clones the object.

Overrides:
clone in class java.lang.Object

check

public java.util.Vector<java.lang.String> check(java.lang.String fileName,
                                                java.lang.String AdditionalErrorInformation)
                                         throws java.io.IOException
Checks the argument for possible error messages. This method checks the argument StringToCheck for any error messages. If no errors are found, it returns an empty Vector. Otherwise, a Vector with all found errors and an additional error information as the first entry are returned.

Parameters:
fileName - Name of file that has to be checked for errors
AdditionalErrorInformation - Additional string that is added at the beginning of the returned the error message
Returns:
A trimed empty Vector if no error message could be found, otherwise a trimed Vector with all the error messages that were found and the string 'ErrorMessage' as the first entry.
Throws:
java.io.IOException - if the file cannot be read

getNumberOfErrors

public int getNumberOfErrors()
Gets the number of possible error strings.
Note: This method returns the number possible error strings that were set by the constructor ErrorChecker(String[] ErrorIndicator) and not the number of found error strings passed by check(String StringToCheck, String AdditionalErrorInformation).

Returns:
Number of possible error strings

getErrorString

public java.lang.String getErrorString(int Position)
Gets a single possible error string.
Note: This method returns a possible error string that was set that were set by the constructor ErrorChecker(String[] ErrorIndicator) and not the number of found error Strings passed by check(String StringToCheck, String AdditionalErrorInformation).

Parameters:
Position - 0-based index of error string
Returns:
A possible error string

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
The main method. This method is used for testing only

Throws:
java.io.IOException