org.pfsw.joi
Class Inspector

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by org.pfsw.joi.Inspector
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener
Direct Known Subclasses:
BasicInspector

public abstract class Inspector
extends java.awt.event.MouseAdapter

This is the default inspector, which can display all normal java objects. Currently it opens a window on the object to inspect and displays all of its fields that are not static and not final, which means no class variables and no constants, but all instance variables (including inherited attributes).
For arrays it lists up all elements from 0 to n.
For deeper inspection it is possible to open a new inspector on each attribute.

Here is an example how to use the inspector:

Since:
JDK 1.5

Field Summary
protected static java.lang.String ActionSeparator
           
static java.lang.String EXPORTER_MAPPING_FILENAME
          The filename that will be looked up in each classpath element to load exporter classes ( implementors of ExportProvider ) automatically into the registry of JOI.
static java.lang.String EXPORTER_MAPPING_FILENAME_ALL
           
static java.lang.String EXPORTER_MAPPING_FILENAME_CLASSLOADER
           
protected static java.lang.String ExportPrefix
           
protected static java.lang.String ImportPrefix
           
static java.lang.String INSPECTOR_MAPPING_FILENAME
          The filename that will be looked up in each classpath element to load inspector classes ( subclasses of BasicInspector ) automatically into the registry of JOI.
static java.lang.String INSPECTOR_MAPPING_FILENAME_ALL
           
static java.lang.String INSPECTOR_MAPPING_FILENAME_CLASSLOADER
           
protected static java.lang.String PROG_COPYRIGHT
           
protected static java.lang.String PROG_FULL_SIGNATURE
           
protected static java.lang.String PROG_ID
           
protected static java.lang.String PROG_NAME
           
protected static java.lang.String PROG_SIGNATURE
           
protected static java.lang.String PROG_VERSION
           
 
Constructor Summary
protected Inspector()
          Initialize the new instance with default values.
 
Method Summary
protected static boolean anyInspectorActive()
          Returns whether at least one inspector is currently running.
protected static void basicBindInspector(java.lang.String className, java.lang.String inspectorName)
           
static Inspector basicInspect(java.lang.Object obj)
          Inspect the given object.
static Inspector basicInspect(java.lang.String name, java.lang.Object obj)
          Inspect the given object.
protected static BasicInspector basicInspectIn(InspectionWindowController controller, int where, java.lang.String name, java.lang.Object obj)
          Opens a new basic inspector with the given controller.
static void basicInspectWait(java.lang.Object obj)
          Inspect the given object like in basicInspect().
static void basicInspectWait(java.lang.String name, java.lang.Object obj)
          Inspect the given object like in basicInspect().
static void bindInspector(java.lang.String className, java.lang.String inspectorName)
          Bind a specific class or interface to a special inspector class.
protected static void closeAllControllers()
           
static void deactivateHalt()
          Continues the current process.
protected static org.pfsw.joi.ClassAssociations exportProviderRegistry()
           
protected static ExportProvider findExporterNamed(java.lang.String exporterId)
           
protected static org.pfsw.reflect.ClassInfo findInspectorClassInfoFor(java.lang.Object object)
           
static java.lang.String fullIdentification()
          Returns the component's long name and current version
protected static java.lang.String getAboutInfoText()
          Returns the JOI about information.
static AbstractObjectSpy getBasicObjectSpy(java.lang.Object obj)
          Returns the object spy wrapper for the given object.
static AbstractObjectSpy getBasicObjectSpy(java.lang.String name, java.lang.Object obj)
          Returns the object spy wrapper for the given object.
protected static java.util.List getControllerRegistry()
           
protected static org.pfsw.joi.ClassAssociations getExportProviderRegistry()
           
protected static boolean getHaltCurrentProccess()
           
protected  AbstractObjectSpy getInspectedObject()
           
protected static org.pfsw.joi.ClassAssociations getInspectorBinding()
           
protected static BasicInspector getInspectorFor(java.lang.Object obj)
           
static AbstractObjectSpy getObjectSpy(java.lang.Object obj)
          Returns the object spy wrapper for the given object.
static AbstractObjectSpy getObjectSpy(java.lang.String name, java.lang.Object obj)
          Returns the object spy wrapper for the given object.
static java.lang.String getProgSignature()
          Returns the name and current version of this component.
static void halt()
          Halts the current process.
protected static void initializeExportProviderRegistry()
           
protected static void initializeInspectorBinding()
           
static Inspector inspect(java.lang.Object obj)
          Inspect the given object.
static Inspector inspect(java.lang.String name, java.lang.Object obj)
          Inspect the given object.
protected static BasicInspector inspectIn(InspectionWindowController controller, int where, java.lang.String name, java.lang.Object obj)
          Opens a new inspector controlled by the given controller.
protected  void inspectObject(java.lang.String name, java.lang.Object obj)
          Inspect the given object.
protected static org.pfsw.joi.ClassAssociations inspectorBinding()
           
static void inspectWait(java.lang.Object obj)
          Inspect the given object like in inspect().
static void inspectWait(java.lang.String name, java.lang.Object obj)
          Inspect the given object like in inspect().
protected static boolean isHaltActive()
          Returns whether or not the current process halt is still active
protected static Inspector launchInspectorOn(BasicInspector inspector, java.lang.String name, java.lang.Object obj)
          Starts the given inspector.
static void main(java.lang.String[] args)
           
protected  AbstractObjectSpy objectSpyFor(java.lang.Object obj)
          Returns the correct wrapper class (spy) for the given object.
protected  AbstractObjectSpy objectSpyFor(java.lang.String name, java.lang.Object obj)
          Returns the correct wrapper class (spy) for the given object.
protected static BasicInspector openInspectorIn(InspectionWindowController controller, int where, BasicInspector inspector, java.lang.String name, java.lang.Object obj)
          Opens a new inspector with the given controller.
protected static void registerController(InspectionWindowController controller)
          Registers the given controller.
protected static void setControllerRegistry(java.util.List newValue)
           
protected static void setExportProviderRegistry(org.pfsw.joi.ClassAssociations newValue)
           
protected static void setHaltCurrentProccess(boolean newValue)
           
protected  void setInspectedObject(AbstractObjectSpy newValue)
           
protected static void setInspectorBinding(org.pfsw.joi.ClassAssociations newValue)
           
static java.lang.String shortIdentification()
          Returns the component's short name and current version
protected static void unregisterController(InspectionWindowController controller)
          Unregisters the given controller.
protected static void waitWhileHaltActive()
          Runs an endless loop until the last inspector is closed or the current should explicitly be continued.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROG_NAME

protected static final java.lang.String PROG_NAME
See Also:
Constant Field Values

PROG_ID

protected static final java.lang.String PROG_ID
See Also:
Constant Field Values

PROG_VERSION

protected static final java.lang.String PROG_VERSION
See Also:
Constant Field Values

PROG_COPYRIGHT

protected static final java.lang.String PROG_COPYRIGHT
See Also:
Constant Field Values

PROG_SIGNATURE

protected static final java.lang.String PROG_SIGNATURE
See Also:
Constant Field Values

PROG_FULL_SIGNATURE

protected static final java.lang.String PROG_FULL_SIGNATURE
See Also:
Constant Field Values

ActionSeparator

protected static final java.lang.String ActionSeparator
See Also:
Constant Field Values

ExportPrefix

protected static final java.lang.String ExportPrefix
See Also:
Constant Field Values

ImportPrefix

protected static final java.lang.String ImportPrefix
See Also:
Constant Field Values

INSPECTOR_MAPPING_FILENAME

public static final java.lang.String INSPECTOR_MAPPING_FILENAME
The filename that will be looked up in each classpath element to load inspector classes ( subclasses of BasicInspector ) automatically into the registry of JOI.
Filename: "META-INF/joi.inspector"

See Also:
Constant Field Values

INSPECTOR_MAPPING_FILENAME_CLASSLOADER

public static final java.lang.String INSPECTOR_MAPPING_FILENAME_CLASSLOADER
See Also:
Constant Field Values

INSPECTOR_MAPPING_FILENAME_ALL

public static final java.lang.String INSPECTOR_MAPPING_FILENAME_ALL
See Also:
Constant Field Values

EXPORTER_MAPPING_FILENAME

public static final java.lang.String EXPORTER_MAPPING_FILENAME
The filename that will be looked up in each classpath element to load exporter classes ( implementors of ExportProvider ) automatically into the registry of JOI.
Filename: "META-INF/joi.exporter"

See Also:
Constant Field Values

EXPORTER_MAPPING_FILENAME_CLASSLOADER

public static final java.lang.String EXPORTER_MAPPING_FILENAME_CLASSLOADER
See Also:
Constant Field Values

EXPORTER_MAPPING_FILENAME_ALL

public static final java.lang.String EXPORTER_MAPPING_FILENAME_ALL
See Also:
Constant Field Values
Constructor Detail

Inspector

protected Inspector()
Initialize the new instance with default values.

Method Detail

getControllerRegistry

protected static java.util.List getControllerRegistry()

setControllerRegistry

protected static void setControllerRegistry(java.util.List newValue)

getInspectorBinding

protected static org.pfsw.joi.ClassAssociations getInspectorBinding()

setInspectorBinding

protected static void setInspectorBinding(org.pfsw.joi.ClassAssociations newValue)

getExportProviderRegistry

protected static org.pfsw.joi.ClassAssociations getExportProviderRegistry()

setExportProviderRegistry

protected static void setExportProviderRegistry(org.pfsw.joi.ClassAssociations newValue)

getHaltCurrentProccess

protected static boolean getHaltCurrentProccess()

setHaltCurrentProccess

protected static void setHaltCurrentProccess(boolean newValue)

getInspectedObject

protected AbstractObjectSpy getInspectedObject()

setInspectedObject

protected void setInspectedObject(AbstractObjectSpy newValue)

basicInspect

public static Inspector basicInspect(java.lang.Object obj)
Inspect the given object.
That means to display the internal state of the given object's attributes. This method is always using the basic inspector.

Parameters:
obj - The object to look inside

basicInspect

public static Inspector basicInspect(java.lang.String name,
                                     java.lang.Object obj)
Inspect the given object.
That means to display the internal state of the given object's attributes. This method is always using the basic inspector.

Parameters:
name - The name of the object in its program context
obj - The object to look inside

inspect

public static Inspector inspect(java.lang.Object obj)
Inspect the given object.
That means to display the internal state of the given object's attributes. The inspector can be a specialized one for the class of the given object.

Parameters:
obj - The object to look inside

inspect

public static Inspector inspect(java.lang.String name,
                                java.lang.Object obj)
Inspect the given object.
That means to display the internal state of the given object's attributes. The inspector can be a specialized one for the class of the given object.

Parameters:
obj - The object to look inside

basicInspectWait

public static void basicInspectWait(java.lang.Object obj)
Inspect the given object like in basicInspect().
But this method doesn't return until the inspector and all its sub-inspectors are closed again.

Parameters:
obj - The object to look inside

basicInspectWait

public static void basicInspectWait(java.lang.String name,
                                    java.lang.Object obj)
Inspect the given object like in basicInspect().
But this method doesn't return until the inspector and all its sub-inspectors are closed again.

Parameters:
name - The name of the object in its program context
obj - The object to look inside

inspectWait

public static void inspectWait(java.lang.Object obj)
Inspect the given object like in inspect().
But this method doesn't return until the inspector and all its sub-inspectors are closed again.

Parameters:
obj - The object to look inside

inspectWait

public static void inspectWait(java.lang.String name,
                               java.lang.Object obj)
Inspect the given object like in inspect().
But this method doesn't return until the inspector and all its sub-inspectors are closed again.

Parameters:
name - The name of the object in its program context
obj - The object to look inside

bindInspector

public static void bindInspector(java.lang.String className,
                                 java.lang.String inspectorName)
Bind a specific class or interface to a special inspector class.
This can be used to "install" self written specialized inspectors for specific classes or groups of classes.
If there is for example a special inspector for dates this method could look like the following:

Inspector.bindInspector( "java.util.Date", "com.xxx.debug.DateInspector" ) ;

or if there is a particular inspector for all objects that understand the BeanInfo interface:
Inspector.bindInspector( "java.beans.BeanInfo", "org.zzzz.inspect.BeanInfoInspector" ) ;

Parameters:
className - The fully qualified name of the class or interface
inspectorName - The fully qualified class name of the associated inspector

getBasicObjectSpy

public static AbstractObjectSpy getBasicObjectSpy(java.lang.Object obj)
Returns the object spy wrapper for the given object.
It will be wrapped by the basic inspector.

Parameters:
obj - The object to look inside

getBasicObjectSpy

public static AbstractObjectSpy getBasicObjectSpy(java.lang.String name,
                                                  java.lang.Object obj)
Returns the object spy wrapper for the given object.
It will be wrapped by the basic inspector.

Parameters:
name - The name of the object in its program context
obj - The object to look inside

getObjectSpy

public static AbstractObjectSpy getObjectSpy(java.lang.Object obj)
Returns the object spy wrapper for the given object.
It will be wrapped by the inspector that is registerd for the object's type.

Parameters:
obj - The object to look inside

getObjectSpy

public static AbstractObjectSpy getObjectSpy(java.lang.String name,
                                             java.lang.Object obj)
Returns the object spy wrapper for the given object.
It will be wrapped by the inspector that is registerd for the object's type.

Parameters:
name - The name the object has in the program context
obj - The object to look inside

fullIdentification

public static java.lang.String fullIdentification()
Returns the component's long name and current version


shortIdentification

public static java.lang.String shortIdentification()
Returns the component's short name and current version


deactivateHalt

public static void deactivateHalt()
Continues the current process.


halt

public static void halt()
Halts the current process.


getProgSignature

public static java.lang.String getProgSignature()
Returns the name and current version of this component.


main

public static void main(java.lang.String[] args)

inspectIn

protected static BasicInspector inspectIn(InspectionWindowController controller,
                                          int where,
                                          java.lang.String name,
                                          java.lang.Object obj)
Opens a new inspector controlled by the given controller. No new window will be opened.

Parameters:
controller - The controller to open the object with.
where - Defines where to open the new inspection view (see InspectionWindowController)
name - The name of the object
obj - The object to inspect

basicInspectIn

protected static BasicInspector basicInspectIn(InspectionWindowController controller,
                                               int where,
                                               java.lang.String name,
                                               java.lang.Object obj)
Opens a new basic inspector with the given controller. No new window will be opened.

Parameters:
controller - The controller to open the object with.
where - Defines where to open the new inspection view (see InspectionWindowController)
name - The name of the object
obj - The object to inspect

openInspectorIn

protected static BasicInspector openInspectorIn(InspectionWindowController controller,
                                                int where,
                                                BasicInspector inspector,
                                                java.lang.String name,
                                                java.lang.Object obj)
Opens a new inspector with the given controller. No new window will be opened.

Parameters:
controller - The controller to open the object with.
where - Defines where to open the new inspection view (see InspectionWindowController)
name - The name of the object
obj - The object to inspect

launchInspectorOn

protected static Inspector launchInspectorOn(BasicInspector inspector,
                                             java.lang.String name,
                                             java.lang.Object obj)
Starts the given inspector.
Before starting an inspector it is registered for overall inspector management.

Parameters:
inspector - The inspector that should be started.

getInspectorFor

protected static BasicInspector getInspectorFor(java.lang.Object obj)

findInspectorClassInfoFor

protected static org.pfsw.reflect.ClassInfo findInspectorClassInfoFor(java.lang.Object object)

inspectorBinding

protected static org.pfsw.joi.ClassAssociations inspectorBinding()

initializeInspectorBinding

protected static void initializeInspectorBinding()

basicBindInspector

protected static void basicBindInspector(java.lang.String className,
                                         java.lang.String inspectorName)

registerController

protected static void registerController(InspectionWindowController controller)
Registers the given controller.

Parameters:
controller - The controller that should be registered.

unregisterController

protected static void unregisterController(InspectionWindowController controller)
Unregisters the given controller.

Parameters:
controller - The controller to be unregistered.

anyInspectorActive

protected static boolean anyInspectorActive()
Returns whether at least one inspector is currently running.


isHaltActive

protected static boolean isHaltActive()
Returns whether or not the current process halt is still active


waitWhileHaltActive

protected static void waitWhileHaltActive()
Runs an endless loop until the last inspector is closed or the current should explicitly be continued.


exportProviderRegistry

protected static org.pfsw.joi.ClassAssociations exportProviderRegistry()

initializeExportProviderRegistry

protected static void initializeExportProviderRegistry()

closeAllControllers

protected static void closeAllControllers()

getAboutInfoText

protected static java.lang.String getAboutInfoText()
Returns the JOI about information.


findExporterNamed

protected static ExportProvider findExporterNamed(java.lang.String exporterId)

inspectObject

protected void inspectObject(java.lang.String name,
                             java.lang.Object obj)
Inspect the given object.
That means to display the internal state of the given object's attributes.

Parameters:
obj - The object to look inside

objectSpyFor

protected AbstractObjectSpy objectSpyFor(java.lang.Object obj)
Returns the correct wrapper class (spy) for the given object.
Subclasses probably must override this method to support their own spy classes.

Parameters:
obj - The object to inspect

objectSpyFor

protected AbstractObjectSpy objectSpyFor(java.lang.String name,
                                         java.lang.Object obj)
Returns the correct wrapper class (spy) for the given object.
The wrapper then gets the given name.

Parameters:
obj - The object to inspect