com.northconcepts.datapipeline.core
Class DataException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.northconcepts.datapipeline.core.DataException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ParseException

public class DataException
extends RuntimeException

Indicates an error has occurred during the course of execution. DataException retrofits RuntimeException with the ability to contain properties and to prepend text to the message after construction.

See Also:
Serialized Form

Constructor Summary
DataException()
          Constructs a new exception.
DataException(String message)
          Constructs a new exception with the specified detail message.
DataException(String message, Throwable cause)
          Constructs a new exception with the specified detail message and cause.
DataException(Throwable cause)
          Constructs a new exception with the specified cause.
 
Method Summary
 Object get(String name)
          Returns the value mapped to the specified key or null.
 boolean getAsBoolean(String name)
          Returns the value mapped to the specified key as a boolean or throws NullPointeException.
 Date getAsDatetime(String name)
          Returns the value mapped to the specified key as a Date or null.
 double getAsDouble(String name)
          Returns the value mapped to the specified key as a double or throws NullPointeException.
 int getAsInteger(String name)
          Returns the value mapped to the specified key as an int or throws NullPointeException.
 long getAsLong(String name)
          Returns the value mapped to the specified key as a long or throws NullPointeException.
 String getAsString(String name)
          Returns the value mapped to the specified key as a String or null.
 String getFieldName()
          Returns the field name associated with this exception.
 String getMessage()
          Returns the detail message string of this exception along with any prefixed text.
 String getMessageWithProperties()
          Returns the detail message string of this exception along with any prefixed text and properties (name-value pairs).
 Map<String,Object> getProperties()
          Returns the values associated with this exception as a Map.
 String getPropertiesAsString()
           
 Record getRecord()
          Returns the record associated with this exception.
 DataException prefixMessageWith(String message)
          Prefixes this exception's message with the specified text.
 void printStackTrace(PrintStream s)
          Prints this throwable and its backtrace to the specified print stream.
 void printStackTrace(PrintWriter s)
          Prints this throwable and its backtrace to the specified print writer.
 DataException set(String name, boolean value)
          Maps a boolean value to the specified key, overwriting any previous association.
 DataException set(String name, char value)
          Maps a character value to the specified key, overwriting any previous association.
 DataException set(String name, double value)
          Maps a double value to the specified key, overwriting any previous association.
 DataException set(String name, int value)
          Maps an int value to the specified key, overwriting any previous association.
 DataException set(String name, long value)
          Maps a long value to the specified key, overwriting any previous association.
 DataException set(String name, Object value)
          Maps a value to the specified key, overwriting any previous association.
 DataException setFieldName(String fieldName)
          sets the field name associated with this exception.
 DataException setRecord(Record record)
          Sets the record associated with this exception.
static DataException wrap(String message, Throwable exception)
          Converts an exception to a DataException and prefixes the original message with the specified text.
static DataException wrap(Throwable exception)
          Converts an exception to a DataException.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataException

public DataException()
Constructs a new exception.


DataException

public DataException(String message)
Constructs a new exception with the specified detail message.


DataException

public DataException(Throwable cause)
Constructs a new exception with the specified cause.


DataException

public DataException(String message,
                     Throwable cause)
Constructs a new exception with the specified detail message and cause.

Method Detail

wrap

public static DataException wrap(String message,
                                 Throwable exception)
Converts an exception to a DataException and prefixes the original message with the specified text. If the supplied exception is an instanceof DataException, it will be returned, otherwise it will be nested inside a DataException. In either case the result message will be prefixed with the supplied text.

Parameters:
message - the text to prefix to the original message
exception - the exception to convert
Returns:
the converted exception

wrap

public static DataException wrap(Throwable exception)
Converts an exception to a DataException. If the supplied exception is an instanceof DataException, it will be returned, otherwise it will be nested inside a DataException.

Parameters:
exception - the exception to convert
Returns:
the converted exception

get

public Object get(String name)
Returns the value mapped to the specified key or null.


getAsString

public String getAsString(String name)
Returns the value mapped to the specified key as a String or null.


getAsInteger

public int getAsInteger(String name)
Returns the value mapped to the specified key as an int or throws NullPointeException.


getAsLong

public long getAsLong(String name)
Returns the value mapped to the specified key as a long or throws NullPointeException.


getAsDouble

public double getAsDouble(String name)
Returns the value mapped to the specified key as a double or throws NullPointeException.


getAsBoolean

public boolean getAsBoolean(String name)
Returns the value mapped to the specified key as a boolean or throws NullPointeException.


getAsDatetime

public Date getAsDatetime(String name)
Returns the value mapped to the specified key as a Date or null.


set

public DataException set(String name,
                         Object value)
Maps a value to the specified key, overwriting any previous association.

Parameters:
name - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
this exception

set

public DataException set(String name,
                         char value)
Maps a character value to the specified key, overwriting any previous association. If the character represents a special, non-printable value (end-of-file, new-line, carriage return, etc.), it will be converted to a human-readable string.

Parameters:
name - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
this exception

set

public DataException set(String name,
                         int value)
Maps an int value to the specified key, overwriting any previous association.

Parameters:
name - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
this exception

set

public DataException set(String name,
                         long value)
Maps a long value to the specified key, overwriting any previous association.

Parameters:
name - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
this exception

set

public DataException set(String name,
                         double value)
Maps a double value to the specified key, overwriting any previous association.

Parameters:
name - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
this exception

set

public DataException set(String name,
                         boolean value)
Maps a boolean value to the specified key, overwriting any previous association.

Parameters:
name - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
this exception

getFieldName

public String getFieldName()
Returns the field name associated with this exception.


setFieldName

public DataException setFieldName(String fieldName)
sets the field name associated with this exception.

Returns:
this exception

getRecord

public Record getRecord()
Returns the record associated with this exception.


setRecord

public DataException setRecord(Record record)
Sets the record associated with this exception.

Returns:
this exception

getProperties

public Map<String,Object> getProperties()
Returns the values associated with this exception as a Map.

Returns:
a non-null array of value names.
See Also:
set(String, Object), get(String)

getPropertiesAsString

public String getPropertiesAsString()

prefixMessageWith

public DataException prefixMessageWith(String message)
Prefixes this exception's message with the specified text.

Parameters:
message - the text to prefix to the original message
Returns:
this exception

getMessage

public String getMessage()
Returns the detail message string of this exception along with any prefixed text. This method is equivalent to calling <getOriginalMessageWithPrefix().

Overrides:
getMessage in class Throwable

getMessageWithProperties

public String getMessageWithProperties()
Returns the detail message string of this exception along with any prefixed text and properties (name-value pairs).


printStackTrace

public void printStackTrace(PrintStream s)
Prints this throwable and its backtrace to the specified print stream.

Overrides:
printStackTrace in class Throwable
Parameters:
s - PrintStream to use for output

printStackTrace

public void printStackTrace(PrintWriter s)
Prints this throwable and its backtrace to the specified print writer.

Overrides:
printStackTrace in class Throwable
Parameters:
s - PrintWriter to use for output


Copyright (c) 2007-2012 North Concepts Inc. All Rights Reserved.