FileDocCategorySizeDatePackage
JDOException.javaAPI DocGlassfish v2 API7121Fri May 04 22:34:54 BST 2007com.sun.jdo.api.persistence.support

JDOException

public class JDOException extends RuntimeException
This is the root of all JDO Exceptions. It contains an optional nested Exception and an optional message.
author
Craig Russell
version
0.1

Fields Summary
Exception
nested
This exception was generated because of an exception in the runtime library.
transient Object[]
failed
This exception may be the result of incorrect parameters supplied to an API. This is the array from which the user can determine the cause of the problem. The failed Object array is transient because it might contain non-Serializable instances.
Constructors Summary
public JDOException()
Creates a new JDOException without detail message.

  
public JDOException(String msg)
Constructs a new JDOException with the specified detail message.

param
msg the detail message.

    super(msg);
  
public JDOException(String msg, Exception nested)
Constructs a new JDOException with the specified detail message and nested Exception.

param
msg the detail message.
param
nested the nested Exception.

    super(msg);
    this.nested = nested;
  
public JDOException(String msg, Object[] failed)
Constructs a new JDOException with the specified detail message and failed object array.

param
msg the detail message.
param
failed the failed object array.

    super(msg);
    this.failed = failed;
  
public JDOException(String msg, Exception nested, Object[] failed)
Constructs a new JDOException with the specified detail message, nested exception, and failed object array.

param
msg the detail message.
param
nested the nested Exception.
param
failed the failed object array.

    super(msg);
    this.nested = nested;
    this.failed = failed;
  
Methods Summary
public voidaddFailedObject(java.lang.Object o)
The exception may need to add objects to an array of failed objects.

param
o the failed object to add to an array.

    if (failed == null)
	//Create new
	failed = new Object[] {o};
    else {
	//Extend exisisting
    	int len = failed.length;
	Object[] ofailed = failed;
	failed = new Object[len + 1];
	for (int i = 0; i < len; i++)
		failed[i] = ofailed[i];

	failed[len] = o;
    }
  
public java.lang.Object[]getFailedObjectArray()
The exception may include an array of failed objects.

return
the failed object array.

    return failed;
  
public java.lang.ExceptiongetNestedException()
The exception may have been caused by an Exception in the runtime.

return
the nested Exception.

    return nested;
  
public voidprintStackTrace()
Prints this JDOException and its backtrace to the standard error output. Prints nested Throwables' stack trace as well.

    printStackTrace(System.err);
  
public voidprintStackTrace(java.io.PrintStream s)
Prints this JDOException and its backtrace to the specified print stream. Prints nested Throwable's stack trace as well.

param
s PrintStream to use for output

    synchronized (s) {
      super.printStackTrace(s);
      if (nested != null) {
        s.println("\nNestedStackTrace: "); //NOI18N
        nested.printStackTrace(s);
      }
    }
  
public voidprintStackTrace(java.io.PrintWriter s)
Prints this JDOException and its backtrace to the specified print writer. Prints nested Throwable's stack trace as well.

param
s PrintWriter to use for output

    synchronized (s) {
      super.printStackTrace(s);
      if (nested != null) {
        s.println("\nNestedStackTrace: "); //NOI18N
        nested.printStackTrace(s);
      }
    }
  
public java.lang.StringtoString()
The String representation includes the name of the class, the descriptive comment (if any), the String representation of the nested Exception (if any), and the String representation of the failed Object array (if any).

return
the String.

    int len = 0;
    if (failed != null) {
        len = failed.length;
    }
    // calculate approximate size of the String to return
    StringBuffer sb = new StringBuffer (100 + 10 * len);
    sb.append (super.toString());
    // include nested exception information
    if (nested != null) {
      sb.append ("\nNestedException: "); //NOI18N
      sb.append (nested.toString());
    }
    // include failed object information
    if (len > 0) {
      sb.append ("\nFailedObjectArray: ["); //NOI18N
      Object ofail = failed[0];
      sb.append (JDOHelper.printObject(ofail));
      for (int i=1; i<len; ++i) {
        sb.append (", "); //NOI18N
        ofail = failed[i];
        sb.append (JDOHelper.printObject(ofail));
      }
      sb.append ("]"); //NOI18N
    }
    return sb.toString();