org.ejen
Class EjenErrors

java.lang.Object
  |
  +--org.ejen.EjenErrors

public class EjenErrors
extends Object

Ejen errors class utility.

Version:
1.0
Author:
F. Wolff

Nested Class Summary
static class EjenErrors.EjenError
          Class that represents one error.
 
Field Summary
static String EJEN_INFORMATION
           
static String ID_COLUMN
           
static String ID_FILE
           
static String ID_LINE
           
static String ID_MESSAGE
           
static String ID_NOTE
           
static String ID_PUBLIC_ID
           
static String ID_SYSTEM_ID
           
static String LINE_SEPARATOR
           
static String STACK_TRACE
           
 
Method Summary
static EjenErrors.EjenError[] get(String file, String note, Throwable t)
          Returns an EjenError array (no stack trace).
static EjenErrors.EjenError[] get(String file, String note, Throwable t, boolean printStackTrace)
          Returns an EjenError array.
static String toString(EjenErrors.EjenError[] errors)
          Returns a String representation of the errors argument.
static String toString(String file, String note, Throwable t)
          Identical to toString(get(file, note, t, false)).
static String toString(String file, String note, Throwable t, boolean printStackTrace)
          Identical to toString(get(file, note, t, printStackTrace)).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EJEN_INFORMATION

public static final String EJEN_INFORMATION
See Also:
Constant Field Values

STACK_TRACE

public static final String STACK_TRACE
See Also:
Constant Field Values

ID_FILE

public static final String ID_FILE
See Also:
Constant Field Values

ID_NOTE

public static final String ID_NOTE
See Also:
Constant Field Values

ID_MESSAGE

public static final String ID_MESSAGE
See Also:
Constant Field Values

ID_PUBLIC_ID

public static final String ID_PUBLIC_ID
See Also:
Constant Field Values

ID_SYSTEM_ID

public static final String ID_SYSTEM_ID
See Also:
Constant Field Values

ID_LINE

public static final String ID_LINE
See Also:
Constant Field Values

ID_COLUMN

public static final String ID_COLUMN
See Also:
Constant Field Values

LINE_SEPARATOR

public static final String LINE_SEPARATOR
Method Detail

get

public static EjenErrors.EjenError[] get(String file,
                                         String note,
                                         Throwable t)
Returns an EjenError array (no stack trace). See get(String file, String note, Throwable t, boolean printStackTrace).

Parameters:
file - name of the file where the error occured.
note - additional message.
t - the exception to be analysed in order to retrieve all embedded exceptions information.
Returns:
the EjenError array.

get

public static EjenErrors.EjenError[] get(String file,
                                         String note,
                                         Throwable t,
                                         boolean printStackTrace)
Returns an EjenError array.

If the file or the note argument is not null, the first EjenError will be an "Ejen information" with the properties "file" or "note" filled in (at least one those properties, depending on nullity).

If the t argument is not null, the following EjenError(s) will have the name of the exception as name and (if not null) the property "message" set to the exception message. While there is an embedded exception in the current exception, a new EjenError is appended to the array (with specific information from the embedded exception) and the embedded exception becomes the current exception. If one of those exception is a SAXParseException or a TransformerException, the properties "column", "line", "public-id" and "system-id" may be included as well (depending on nullity).

If printStackTrace is true, an EjenError is finally appended to the array with name set to the last embedded exception name and a "stack-trace" property is added (whose value is the stack trace).

Parameters:
file - name of the file where the error occured.
note - additional message.
t - the exception to be analysed in order to retrieve all embedded exceptions information.
printStackTrace - should stack trace be provided or not.
Returns:
the EjenError array.

toString

public static String toString(EjenErrors.EjenError[] errors)
Returns a String representation of the errors argument.

If the errors argument is null, "errors.null" is returned.

Otherwise, for each EjenError in the array, a String with the following structure is appended:

[<name of the EjenError>] {
  <name of property>: <value of property>
  <name of property>: <value of property>
  ...
}

Parameters:
errors - an EjenError array.
Returns:
the String representation.

toString

public static String toString(String file,
                              String note,
                              Throwable t)
Identical to toString(get(file, note, t, false)).

Parameters:
file - name of the file where the error occured.
note - additional message.
t - the exception to be analysed in order to retrieve all embedded exceptions information.
Returns:
the String representation.

toString

public static String toString(String file,
                              String note,
                              Throwable t,
                              boolean printStackTrace)
Identical to toString(get(file, note, t, printStackTrace)).

Parameters:
file - name of the file where the error occured.
note - additional message.
t - the exception to be analysed in order to retrieve all embedded exceptions information.
printStackTrace - should stack trace be provided or not.
Returns:
the String representation.