TPTP 4.6.0 Platform Project
Public API Specification

org.eclipse.tptp.platform.probekit.util
Class InvalidProbeBundleException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.eclipse.tptp.platform.probekit.util.InvalidProbeBundleException
All Implemented Interfaces:
java.io.Serializable

public class InvalidProbeBundleException
extends java.lang.Exception

This exception encapsulates a number of things that might be wrong with a a collection of files/resources that represent a probe. Though this class was created primarily for use with ProbeFileBundle and ProbeResourceBundle, it may be useful elsewhere, such as by the registry.

The exception can hold one or many reasons for a bundle to be considered invalid - reason is a bit mask, not a single code. Additional bits of information may also be added, such as which file/resource is inaccessible. Callers should be prepared, however, for this extra info to be missing.

Unfortunately, since this exception does double duty for both File and IResource problems, pulling off the extra details can be tricky. You can always get it as an Object or a File, but not always as a resource (all Resources are Files, but not all Files are Resources).

To mitigate this problem somewhat, getFileOrResourceName() can be used to retrieve the most commonly interesting detail.

See Also:
Serialized Form

Field Summary
static int INACCESSIBLE_FILE
           
static int INACCESSIBLE_MODEL_FILE
           
static int INACCESSIBLE_SCRIPT_FILE
           
static int INACCESSIBLE_SUPPORT_FILE
           
static int INVALID_MODEL
           
static int MISSING_FILE
           
static int MISSING_MODEL_FILE
           
static int MISSING_SCRIPT_FILE
           
static int MISSING_SUPPORT_FILE
           
static int MODEL_FILE_ERR
           
static int SCRIPT_FILE_ERR
           
static int SUPPORT_FILE_ERR
           
static int TOO_MANY_FILES_WITH_EXT
           
 
Constructor Summary
InvalidProbeBundleException(int reason)
           
InvalidProbeBundleException(int reason, java.lang.Object o)
           
InvalidProbeBundleException(int reason, java.lang.Object o, java.lang.String extension)
           
InvalidProbeBundleException(int reason, java.lang.String extension)
           
InvalidProbeBundleException(int reason, java.lang.Throwable e)
           
 
Method Summary
 java.lang.String getExtension()
          If reason includes TOO_MANY_FILES_WITH_EXT, calling this method should reveal which type of file we found too many of.
 java.io.File getFileDetail()
          Retrieve exception detail as a File.
 java.lang.String getFileOrResourceName()
          Get the simple name of the file/resource detail, if available.
 java.lang.Object getObjectDetail()
          Retrieve exception detail as an Object.
 int getReason()
          The reasons behind this exception.
 org.eclipse.core.resources.IResource getResourceDetail()
          Retrieve exception detail as an IResource.
 boolean hasFileDetail()
          Determine whether or not there is File exception detail available.
 boolean hasResourceDetail()
          Determine whether or not there is IResource exception detail available.
 boolean testReason(int mask)
          Test to see whether or not mask is one of the causes of this exception.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MISSING_FILE

public static final int MISSING_FILE
See Also:
Constant Field Values

INACCESSIBLE_FILE

public static final int INACCESSIBLE_FILE
See Also:
Constant Field Values

TOO_MANY_FILES_WITH_EXT

public static final int TOO_MANY_FILES_WITH_EXT
See Also:
Constant Field Values

INVALID_MODEL

public static final int INVALID_MODEL
See Also:
Constant Field Values

MODEL_FILE_ERR

public static final int MODEL_FILE_ERR
See Also:
Constant Field Values

SCRIPT_FILE_ERR

public static final int SCRIPT_FILE_ERR
See Also:
Constant Field Values

SUPPORT_FILE_ERR

public static final int SUPPORT_FILE_ERR
See Also:
Constant Field Values

MISSING_MODEL_FILE

public static final int MISSING_MODEL_FILE
See Also:
Constant Field Values

MISSING_SCRIPT_FILE

public static final int MISSING_SCRIPT_FILE
See Also:
Constant Field Values

MISSING_SUPPORT_FILE

public static final int MISSING_SUPPORT_FILE
See Also:
Constant Field Values

INACCESSIBLE_MODEL_FILE

public static final int INACCESSIBLE_MODEL_FILE
See Also:
Constant Field Values

INACCESSIBLE_SCRIPT_FILE

public static final int INACCESSIBLE_SCRIPT_FILE
See Also:
Constant Field Values

INACCESSIBLE_SUPPORT_FILE

public static final int INACCESSIBLE_SUPPORT_FILE
See Also:
Constant Field Values
Constructor Detail

InvalidProbeBundleException

public InvalidProbeBundleException(int reason)

InvalidProbeBundleException

public InvalidProbeBundleException(int reason,
                                   java.lang.Throwable e)

InvalidProbeBundleException

public InvalidProbeBundleException(int reason,
                                   java.lang.String extension)

InvalidProbeBundleException

public InvalidProbeBundleException(int reason,
                                   java.lang.Object o)

InvalidProbeBundleException

public InvalidProbeBundleException(int reason,
                                   java.lang.Object o,
                                   java.lang.String extension)
Method Detail

getReason

public int getReason()
The reasons behind this exception. This is a bit field, composed of the bit flag constants declared above (MISSING_FILE, etc.). It should always be non-zero.

Returns:
Causes of this exception. May be one or many values.

getExtension

public java.lang.String getExtension()
If reason includes TOO_MANY_FILES_WITH_EXT, calling this method should reveal which type of file we found too many of.

Returns:
The file extension causing TOO_MANY_FILES_WITH_EXT, or null.

getObjectDetail

public java.lang.Object getObjectDetail()
Retrieve exception detail as an Object. If non-null, this should in theory be either a File or an IResource. It is expected that users will use getFileDetail() or getResourceDetail in preference to this method.

Returns:
The exception detail as an Object, or null if none is available.

getFileDetail

public java.io.File getFileDetail()
Retrieve exception detail as a File. If the exception was not decorated with either file or resource detail, null is returned. If it was decorated with an IResource, the resource is converted into a File and returned.

Returns:
The exception detail as a File, or null.

getResourceDetail

public org.eclipse.core.resources.IResource getResourceDetail()
Retrieve exception detail as an IResource. If the exception was not decorated with an IResource, null will be returned. This could mean either that no extra information was supplied, or that only a File was supplied.

Returns:
The exception detail as a IResource, or null.

hasFileDetail

public boolean hasFileDetail()
Determine whether or not there is File exception detail available. This will be the case whether the exception object was decorated with a File or a IResource.

Returns:
true if calling getFileDetail would return a non-null value.

hasResourceDetail

public boolean hasResourceDetail()
Determine whether or not there is IResource exception detail available.

Returns:
true if calling getResourceDetail would return a non-null value.

getFileOrResourceName

public java.lang.String getFileOrResourceName()
Get the simple name of the file/resource detail, if available. The simple name is just the filename, such as mumble.probe.

Returns:
The simple name of the file/resource detail, or none if no detail is available.

testReason

public boolean testReason(int mask)
Test to see whether or not mask is one of the causes of this exception. Mask should be one of the constants declared above.

Parameters:
mask - One of the constants declared by this class
Returns:
true if mask is a cause of this exception.

TPTP 4.6.0 Platform Project
Public API Specification