com.jacob.activeX
Class ActiveXComponent

java.lang.Object
  extended by com.jacob.com.JacobObject
      extended by com.jacob.com.Dispatch
          extended by com.jacob.activeX.ActiveXComponent

public class ActiveXComponent
extends Dispatch

This class provides a higher level, more object like, wrapper for top of the Dispatch object. The Dispatch class's method essentially directly map to Microsoft C API including the first parameter that is almost always the target of the message. ActiveXComponent assumes the target of every message is the MS COM object behind the ActiveXComponent. This removes the need to pass the Dispatch object into every method.

It is really up to the developer as to whether they want to use the Dispatch interface or the ActiveXComponent interface.

This class simulates com.ms.activeX.ActiveXComponent only in the sense that it is used for creating Dispatch objects


Field Summary
static boolean shouldLogEvents
          This boolean determines if callback events should be logged
 
Fields inherited from class com.jacob.com.Dispatch
fdexNameCaseSensitive, Get, LOCALE_SYSTEM_DEFAULT, m_pDispatch, Method, Put, PutRef
 
Constructor Summary
ActiveXComponent(Dispatch dispatchToBeWrapped)
          Creates an active X component that is built on top of the COM pointers held in the passed in dispatch.
ActiveXComponent(String programId)
          Normally used to create a new connection to a microsoft application.
 
Method Summary
static ActiveXComponent connectToActiveInstance(String pRequestedProgramId)
          Most code should use the standard ActiveXComponent(String) constructor and not this factory method.
static ActiveXComponent createNewInstance(String pRequestedProgramId)
          Most code should use the standard ActiveXComponent(String) contructor and not this factory method.
protected  void finalize()
           
 Dispatch getObject()
          Probably was a cover for something else in the past.
 Variant getProperty(String propertyName)
          retrieves a property and returns it as a Variant
 boolean getPropertyAsBoolean(String propertyName)
          retrieves a property and returns it as a Boolean
 byte getPropertyAsByte(String propertyName)
          retrieves a property and returns it as a byte
 ActiveXComponent getPropertyAsComponent(String propertyName)
          retrieves a property and returns it as an ActiveX component
 int getPropertyAsInt(String propertyName)
          retrieves a property and returns it as a int
 String getPropertyAsString(String propertyName)
          retrieves a property and returns it as a String
 Variant invoke(String callAction)
          makes a dispatch call for the passed in action and no parameter
 Variant invoke(String actionCommand, boolean parameter)
          makes a dispatch call to the passed in action with a single boolean parameter
 Variant invoke(String actionCommand, int parameter)
          makes a dispatch call to the passed in action with a single int parameter
 Variant invoke(String actionCommand, int parameter1, int parameter2)
          makes a dispatch call to the passed in action with two integer parameters (this was put in for some application)
 Variant invoke(String actionCommand, String parameter)
          invokes a single parameter call on this dispatch that returns no value
 Variant invoke(String actionCommand, String parameter1, int parameter2)
          makes a dispatch call to the passed in action with a string and integer parameter (this was put in for some application)
 Variant invoke(String callAction, Variant parameter)
          makes a dispatch call for the passed in action and single parameter
 Variant invoke(String name, Variant[] args)
          This is really a cover for call(String,Variant[]) that should be eliminated call with a variable number of args mainly used for quit.
 Variant invoke(String callAction, Variant parameter1, Variant parameter2)
          makes a dispatch call for the passed in action and two parameter
 Variant invoke(String callAction, Variant parameter1, Variant parameter2, Variant parameter3)
          makes a dispatch call for the passed in action and two parameter
 Variant invoke(String callAction, Variant parameter1, Variant parameter2, Variant parameter3, Variant parameter4)
          calls call() with 4 variant parameters
 ActiveXComponent invokeGetComponent(String callAction)
          makes a dispatch call for the passed in action and no parameter
 ActiveXComponent invokeGetComponent(String callAction, Variant parameter)
          makes a dispatch call for the passed in action and single parameter
 ActiveXComponent invokeGetComponent(String callAction, Variant parameter1, Variant parameter2)
          makes a dispatch call for the passed in action and single parameter
 ActiveXComponent invokeGetComponent(String callAction, Variant parameter1, Variant parameter2, Variant parameter3)
          makes a dispatch call for the passed in action and single parameter
 ActiveXComponent invokeGetComponent(String callAction, Variant parameter1, Variant parameter2, Variant parameter3, Variant parameter4)
          makes a dispatch call for the passed in action and single parameter
 void logCallbackEvent(String description, Variant[] args)
          used by the doc and application listeners to get intelligent logging
 void setProperty(String propertyName, boolean propValue)
          sets a property as a boolean value
 void setProperty(String propertyName, byte propValue)
          sets a property as a boolean value
 void setProperty(String propertyName, Dispatch arg)
          sets a property on this object
 void setProperty(String propertyName, int propValue)
          sets the property as an int value
 void setProperty(String propertyName, String propertyValue)
          sets a property to be the value of the string
 void setProperty(String propertyName, Variant arg)
          sets a property on this object
 
Methods inherited from class com.jacob.com.Dispatch
call, call, call, call, call, call, call, call, call, call, call, call, call, call, call, call, call, call, callN_CaseSensitive, callN, callN, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSub, callSubN, callSubN, coCreateInstance, get_CaseSensitive, get, get, getActiveInstance, getIDOfName, getIDsOfNames, getIDsOfNames, getProgramId, invoke, invoke, invoke, invokeSub, invokeSub, invokeSub, invokeSubv, invokeSubv, invokeSubv, invokev, invokev, invokev, invokev, isAttached, put_Casesensitive, put, put, putRef, putRef, QueryInterface, safeRelease
 
Methods inherited from class com.jacob.com.JacobObject
debug, getBuildDate, getBuildVersion, isDebugEnabled
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shouldLogEvents

public static boolean shouldLogEvents
This boolean determines if callback events should be logged

Constructor Detail

ActiveXComponent

public ActiveXComponent(String programId)
Normally used to create a new connection to a microsoft application. The passed in parameter is the name of the program as registered in the registry. It can also be the object name.

This constructor causes a new Windows object of the requested type to be created. The windows CoCreate() function gets called to create the underlying windows object.

 new ActiveXComponent("ScriptControl");
 

Parameters:
programId -

ActiveXComponent

public ActiveXComponent(Dispatch dispatchToBeWrapped)
Creates an active X component that is built on top of the COM pointers held in the passed in dispatch. This widens the Dispatch object to pick up the ActiveXComponent API

Parameters:
dispatchToBeWrapped -
Method Detail

getObject

public Dispatch getObject()
Probably was a cover for something else in the past. Should be deprecated.

Returns:
Now it actually returns this exact same object.

createNewInstance

public static ActiveXComponent createNewInstance(String pRequestedProgramId)
Most code should use the standard ActiveXComponent(String) contructor and not this factory method. This method exists for applications that need special behavior. Experimental in release 1.9.2.

Factory that returns a Dispatch object wrapped around the result of a CoCreate() call. This differs from the standard constructor in that it throws no exceptions and returns null on failure.

This will fail for any prog id with a ":" in it.

Parameters:
pRequestedProgramId -
Returns:
Dispatch pointer to the COM object or null if couldn't create

connectToActiveInstance

public static ActiveXComponent connectToActiveInstance(String pRequestedProgramId)
Most code should use the standard ActiveXComponent(String) constructor and not this factory method. This method exists for applications that need special behavior. Experimental in release 1.9.2.

Factory that returns a Dispatch wrapped around the result of a getActiveObject() call. This differs from the standard constructor in that it throws no exceptions and returns null on failure.

This will fail for any prog id with a ":" in it

Parameters:
pRequestedProgramId -
Returns:
Dispatch pointer to a COM object or null if wasn't already running

finalize

protected void finalize()
Overrides:
finalize in class Dispatch
See Also:
Dispatch.finalize()

getProperty

public Variant getProperty(String propertyName)
retrieves a property and returns it as a Variant

Parameters:
propertyName -
Returns:
variant value of property

getPropertyAsComponent

public ActiveXComponent getPropertyAsComponent(String propertyName)
retrieves a property and returns it as an ActiveX component

Parameters:
propertyName -
Returns:
Dispatch representing the object under the property name

getPropertyAsBoolean

public boolean getPropertyAsBoolean(String propertyName)
retrieves a property and returns it as a Boolean

Parameters:
propertyName - property we are looking up
Returns:
boolean value of property

getPropertyAsByte

public byte getPropertyAsByte(String propertyName)
retrieves a property and returns it as a byte

Parameters:
propertyName - property we are looking up
Returns:
byte value of property

getPropertyAsString

public String getPropertyAsString(String propertyName)
retrieves a property and returns it as a String

Parameters:
propertyName -
Returns:
String value of property

getPropertyAsInt

public int getPropertyAsInt(String propertyName)
retrieves a property and returns it as a int

Parameters:
propertyName -
Returns:
the property value as an int

setProperty

public void setProperty(String propertyName,
                        Variant arg)
sets a property on this object

Parameters:
propertyName - property name
arg - variant value to be set

setProperty

public void setProperty(String propertyName,
                        Dispatch arg)
sets a property on this object

Parameters:
propertyName - property name
arg - variant value to be set

setProperty

public void setProperty(String propertyName,
                        String propertyValue)
sets a property to be the value of the string

Parameters:
propertyName -
propertyValue -

setProperty

public void setProperty(String propertyName,
                        boolean propValue)
sets a property as a boolean value

Parameters:
propertyName -
propValue - the boolean value we want the prop set to

setProperty

public void setProperty(String propertyName,
                        byte propValue)
sets a property as a boolean value

Parameters:
propertyName -
propValue - the boolean value we want the prop set to

setProperty

public void setProperty(String propertyName,
                        int propValue)
sets the property as an int value

Parameters:
propertyName -
propValue - the int value we want the prop to be set to.

logCallbackEvent

public void logCallbackEvent(String description,
                             Variant[] args)
used by the doc and application listeners to get intelligent logging

Parameters:
description - event description
args - args passed in (variants)

invokeGetComponent

public ActiveXComponent invokeGetComponent(String callAction)
makes a dispatch call for the passed in action and no parameter

Parameters:
callAction -
Returns:
ActiveXComponent representing the results of the call

invokeGetComponent

public ActiveXComponent invokeGetComponent(String callAction,
                                           Variant parameter)
makes a dispatch call for the passed in action and single parameter

Parameters:
callAction -
parameter -
Returns:
ActiveXComponent representing the results of the call

invokeGetComponent

public ActiveXComponent invokeGetComponent(String callAction,
                                           Variant parameter1,
                                           Variant parameter2)
makes a dispatch call for the passed in action and single parameter

Parameters:
callAction -
parameter1 -
parameter2 -
Returns:
ActiveXComponent representing the results of the call

invokeGetComponent

public ActiveXComponent invokeGetComponent(String callAction,
                                           Variant parameter1,
                                           Variant parameter2,
                                           Variant parameter3)
makes a dispatch call for the passed in action and single parameter

Parameters:
callAction -
parameter1 -
parameter2 -
parameter3 -
Returns:
ActiveXComponent representing the results of the call

invokeGetComponent

public ActiveXComponent invokeGetComponent(String callAction,
                                           Variant parameter1,
                                           Variant parameter2,
                                           Variant parameter3,
                                           Variant parameter4)
makes a dispatch call for the passed in action and single parameter

Parameters:
callAction -
parameter1 -
parameter2 -
parameter3 -
parameter4 -
Returns:
ActiveXComponent representing the results of the call

invoke

public Variant invoke(String actionCommand,
                      String parameter)
invokes a single parameter call on this dispatch that returns no value

Parameters:
actionCommand -
parameter -
Returns:
a Variant but that may be null for some calls

invoke

public Variant invoke(String actionCommand,
                      boolean parameter)
makes a dispatch call to the passed in action with a single boolean parameter

Parameters:
actionCommand -
parameter -
Returns:
Variant result

invoke

public Variant invoke(String actionCommand,
                      int parameter)
makes a dispatch call to the passed in action with a single int parameter

Parameters:
actionCommand -
parameter -
Returns:
Variant result of the invoke (Dispatch.call)

invoke

public Variant invoke(String actionCommand,
                      String parameter1,
                      int parameter2)
makes a dispatch call to the passed in action with a string and integer parameter (this was put in for some application)

Parameters:
actionCommand -
parameter1 -
parameter2 -
Returns:
Variant result

invoke

public Variant invoke(String actionCommand,
                      int parameter1,
                      int parameter2)
makes a dispatch call to the passed in action with two integer parameters (this was put in for some application)

Parameters:
actionCommand -
parameter1 -
parameter2 -
Returns:
a Variant but that may be null for some calls

invoke

public Variant invoke(String callAction,
                      Variant parameter)
makes a dispatch call for the passed in action and single parameter

Parameters:
callAction -
parameter -
Returns:
a Variant but that may be null for some calls

invoke

public Variant invoke(String callAction,
                      Variant parameter1,
                      Variant parameter2)
makes a dispatch call for the passed in action and two parameter

Parameters:
callAction -
parameter1 -
parameter2 -
Returns:
a Variant but that may be null for some calls

invoke

public Variant invoke(String callAction,
                      Variant parameter1,
                      Variant parameter2,
                      Variant parameter3)
makes a dispatch call for the passed in action and two parameter

Parameters:
callAction -
parameter1 -
parameter2 -
parameter3 -
Returns:
Variant result data

invoke

public Variant invoke(String callAction,
                      Variant parameter1,
                      Variant parameter2,
                      Variant parameter3,
                      Variant parameter4)
calls call() with 4 variant parameters

Parameters:
callAction -
parameter1 -
parameter2 -
parameter3 -
parameter4 -
Returns:
Variant result data

invoke

public Variant invoke(String callAction)
makes a dispatch call for the passed in action and no parameter

Parameters:
callAction -
Returns:
a Variant but that may be null for some calls

invoke

public Variant invoke(String name,
                      Variant[] args)
This is really a cover for call(String,Variant[]) that should be eliminated call with a variable number of args mainly used for quit.

Parameters:
name -
args -
Returns:
Variant returned by the invoke (Dispatch.callN)


http://jacob-project.sourceforge.net