Replace tabs with spaces

This commit is contained in:
2015-09-01 13:12:04 +01:00
parent e51103215c
commit 0bab3d8ace
111 changed files with 22231 additions and 22231 deletions

View File

@@ -13,71 +13,71 @@ import com.jacob.com.Variant;
* options.
*/
class MathTest {
/**
* standard main program to run the sample
*
* @param args
* command line parameters
*/
public static void main(String[] args) {
MathTest me = new MathTest();
me.runTest();
}
/**
* standard main program to run the sample
*
* @param args
* command line parameters
*/
public static void main(String[] args) {
MathTest me = new MathTest();
me.runTest();
}
/** default constructor */
public MathTest() {
}
/** default constructor */
public MathTest() {
}
/**
* not clear why we need a class and run method but that's the way it was
* written
*/
public void runTest() {
// deprecated
// System.runFinalizersOnExit(true);
Dispatch test = new ActiveXComponent("MathTest.Math");
TestEvents te = new TestEvents();
DispatchEvents de = new DispatchEvents(test, te);
if (de == null) {
System.out
.println("null returned when trying to create DispatchEvents");
}
System.out.println(Dispatch.call(test, "Add", new Variant(1),
new Variant(2)));
System.out.println(Dispatch.call(test, "Mult", new Variant(2),
new Variant(2)));
Variant v = Dispatch.call(test, "Mult", new Variant(2), new Variant(2));
// this should return false
System.out.println("v.isNull=" + v.isNull());
v = Dispatch.call(test, "getNothing");
// these should return nothing
System.out.println("v.isNull=" + v.isNull());
System.out.println("v.toDispatch=" + v.toDispatch());
}
/**
* not clear why we need a class and run method but that's the way it was
* written
*/
public void runTest() {
// deprecated
// System.runFinalizersOnExit(true);
Dispatch test = new ActiveXComponent("MathTest.Math");
TestEvents te = new TestEvents();
DispatchEvents de = new DispatchEvents(test, te);
if (de == null) {
System.out
.println("null returned when trying to create DispatchEvents");
}
System.out.println(Dispatch.call(test, "Add", new Variant(1),
new Variant(2)));
System.out.println(Dispatch.call(test, "Mult", new Variant(2),
new Variant(2)));
Variant v = Dispatch.call(test, "Mult", new Variant(2), new Variant(2));
// this should return false
System.out.println("v.isNull=" + v.isNull());
v = Dispatch.call(test, "getNothing");
// these should return nothing
System.out.println("v.isNull=" + v.isNull());
System.out.println("v.toDispatch=" + v.toDispatch());
}
/**
*
* sample class to catch the events
*
*/
public class TestEvents {
/**
* catches the DoneAdd event
*
* @param args
*/
public void DoneAdd(Variant[] args) {
System.out.println("DoneAdd called in java");
}
/**
*
* sample class to catch the events
*
*/
public class TestEvents {
/**
* catches the DoneAdd event
*
* @param args
*/
public void DoneAdd(Variant[] args) {
System.out.println("DoneAdd called in java");
}
/**
* catches the DoneMult event
*
* @param args
*/
public void DoneMult(Variant[] args) {
System.out.println("DoneMult called in java");
}
}
/**
* catches the DoneMult event
*
* @param args
*/
public void DoneMult(Variant[] args) {
System.out.println("DoneMult called in java");
}
}
}

View File

@@ -31,114 +31,114 @@ import com.jacob.com.Variant;
*
*/
class Access {
/**
* the main loop for the test
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ComThread.InitSTA();
// original test used this
// ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine");
// my xp box with a later release of access needed this
ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine.35");
// this only works for access files pre-access-2000
// this line doesn't work on my xp box in Eclipse
// Dispatch db = open(ax, ".\\sample2.mdb");
// this works when running in eclipse because the test cases run pwd
// project root
Dispatch db = open(ax, "samples/com/jacob/samples/access/sample2.mdb");
String sql = "select * from MainTable";
// make a temporary querydef
Dispatch qd = Dispatch.call(db, "CreateQueryDef", "").toDispatch();
// set the SQL string on it
Dispatch.put(qd, "SQL", sql);
Variant result = getByQueryDef(qd);
// the 2-d safearray is transposed from what you might expect
System.out.println("resulting array is " + result.toSafeArray());
close(db);
System.out.println("about to call ComThread.Release()");
ComThread.Release();
}
/**
* the main loop for the test
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ComThread.InitSTA();
// original test used this
// ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine");
// my xp box with a later release of access needed this
ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine.35");
// this only works for access files pre-access-2000
// this line doesn't work on my xp box in Eclipse
// Dispatch db = open(ax, ".\\sample2.mdb");
// this works when running in eclipse because the test cases run pwd
// project root
Dispatch db = open(ax, "samples/com/jacob/samples/access/sample2.mdb");
String sql = "select * from MainTable";
// make a temporary querydef
Dispatch qd = Dispatch.call(db, "CreateQueryDef", "").toDispatch();
// set the SQL string on it
Dispatch.put(qd, "SQL", sql);
Variant result = getByQueryDef(qd);
// the 2-d safearray is transposed from what you might expect
System.out.println("resulting array is " + result.toSafeArray());
close(db);
System.out.println("about to call ComThread.Release()");
ComThread.Release();
}
/**
* Open a database
*
* @param ax
* @param fileName
* @return dispatch object that was opened
*/
public static Dispatch open(ActiveXComponent ax, String fileName) {
Variant f = new Variant(false);
// open the file in read-only mode
Variant[] args = new Variant[] { new Variant(fileName), f, f };
Dispatch openDB = ax.invoke("OpenDatabase", args).toDispatch();
return openDB;
}
/**
* Open a database
*
* @param ax
* @param fileName
* @return dispatch object that was opened
*/
public static Dispatch open(ActiveXComponent ax, String fileName) {
Variant f = new Variant(false);
// open the file in read-only mode
Variant[] args = new Variant[] { new Variant(fileName), f, f };
Dispatch openDB = ax.invoke("OpenDatabase", args).toDispatch();
return openDB;
}
/**
* Close a database
*
* @param openDB
* db to be closed
*/
public static void close(Dispatch openDB) {
Dispatch.call(openDB, "Close");
}
/**
* Close a database
*
* @param openDB
* db to be closed
*/
public static void close(Dispatch openDB) {
Dispatch.call(openDB, "Close");
}
/**
* Extract the values from the recordset
*
* @param recset
* @return Variant that is the returned values
*/
public static Variant getValues(Dispatch recset) {
Dispatch.callSub(recset, "moveFirst");
Variant vi = new Variant(4096);
Variant v = Dispatch.call(recset, "GetRows", vi);
return v;
}
/**
* Extract the values from the recordset
*
* @param recset
* @return Variant that is the returned values
*/
public static Variant getValues(Dispatch recset) {
Dispatch.callSub(recset, "moveFirst");
Variant vi = new Variant(4096);
Variant v = Dispatch.call(recset, "GetRows", vi);
return v;
}
/**
* should return ?? for the passed in ??
*
* @param qd
* @return Variant results of query?
*/
public static Variant getByQueryDef(Dispatch qd) {
// get a reference to the recordset
Dispatch recset = Dispatch.call(qd, "OpenRecordset").toDispatch();
// get the values as a safe array
String[] cols = getColumns(recset);
for (int i = 0; i < cols.length; i++) {
System.out.print(cols[i] + " ");
}
System.out.println("");
Variant vals = getValues(recset);
return vals;
}
/**
* should return ?? for the passed in ??
*
* @param qd
* @return Variant results of query?
*/
public static Variant getByQueryDef(Dispatch qd) {
// get a reference to the recordset
Dispatch recset = Dispatch.call(qd, "OpenRecordset").toDispatch();
// get the values as a safe array
String[] cols = getColumns(recset);
for (int i = 0; i < cols.length; i++) {
System.out.print(cols[i] + " ");
}
System.out.println("");
Variant vals = getValues(recset);
return vals;
}
/**
* gets the columns form the rec set
*
* @param recset
* @return list of column names
*/
public static String[] getColumns(Dispatch recset) {
Dispatch flds = Dispatch.get(recset, "Fields").toDispatch();
int n_flds = Dispatch.get(flds, "Count").getInt();
String[] s = new String[n_flds];
Variant vi = new Variant();
for (int i = 0; i < n_flds; i++) {
vi.putInt(i);
// must use the invoke method because this is a method call
// that wants to have a Dispatch.Get flag...
Dispatch fld = Dispatch.invoke(recset, "Fields", Dispatch.Get,
new Object[] { vi }, new int[1]).toDispatch();
Variant name = Dispatch.get(fld, "Name");
s[i] = name.toString();
}
return s;
}
/**
* gets the columns form the rec set
*
* @param recset
* @return list of column names
*/
public static String[] getColumns(Dispatch recset) {
Dispatch flds = Dispatch.get(recset, "Fields").toDispatch();
int n_flds = Dispatch.get(flds, "Count").getInt();
String[] s = new String[n_flds];
Variant vi = new Variant();
for (int i = 0; i < n_flds; i++) {
vi.putInt(i);
// must use the invoke method because this is a method call
// that wants to have a Dispatch.Get flag...
Dispatch fld = Dispatch.invoke(recset, "Fields", Dispatch.Get,
new Object[] { vi }, new int[1]).toDispatch();
Variant name = Dispatch.get(fld, "Name");
s[i] = name.toString();
}
return s;
}
}

View File

@@ -9,199 +9,199 @@ import com.jacob.com.Variant;
*
*/
public class Command extends Dispatch {
/**
* standard constructor
*/
public Command() {
super("ADODB.Command");
}
/**
* standard constructor
*/
public Command() {
super("ADODB.Command");
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*
* @param dispatchTarget
*/
public Command(Dispatch dispatchTarget) {
super(dispatchTarget);
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*
* @param dispatchTarget
*/
public Command(Dispatch dispatchTarget) {
super(dispatchTarget);
}
/**
* runs the "Properties" command
*
* @return the properties
*/
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
/**
* runs the "Properties" command
*
* @return the properties
*/
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
/**
* runs the "ActiveConnection" command
*
* @return a Connection object
*/
public Connection getActiveConnection() {
return new Connection(Dispatch.get(this, "ActiveConnection")
.toDispatch());
}
/**
* runs the "ActiveConnection" command
*
* @return a Connection object
*/
public Connection getActiveConnection() {
return new Connection(Dispatch.get(this, "ActiveConnection")
.toDispatch());
}
/**
* Sets the "ActiveConnection" object
*
* @param ppvObject
* the new connection
*/
public void setActiveConnection(Connection ppvObject) {
Dispatch.put(this, "ActiveConnection", ppvObject);
}
/**
* Sets the "ActiveConnection" object
*
* @param ppvObject
* the new connection
*/
public void setActiveConnection(Connection ppvObject) {
Dispatch.put(this, "ActiveConnection", ppvObject);
}
/**
*
* @return the results from "CommandText"
*/
public String getCommandText() {
return Dispatch.get(this, "CommandText").toString();
}
/**
*
* @return the results from "CommandText"
*/
public String getCommandText() {
return Dispatch.get(this, "CommandText").toString();
}
/**
*
* @param pbstr
* the new "CommandText"
*/
public void setCommandText(String pbstr) {
Dispatch.put(this, "CommandText", pbstr);
}
/**
*
* @param pbstr
* the new "CommandText"
*/
public void setCommandText(String pbstr) {
Dispatch.put(this, "CommandText", pbstr);
}
/**
*
* @return the results of "CommandTimeout"
*/
public int getCommandTimeout() {
return Dispatch.get(this, "CommandTimeout").getInt();
}
/**
*
* @return the results of "CommandTimeout"
*/
public int getCommandTimeout() {
return Dispatch.get(this, "CommandTimeout").getInt();
}
/**
*
* @param plTimeout
* the new "CommandTimeout"
*/
public void setCommandTimeout(int plTimeout) {
Dispatch.put(this, "CommandTimeout", new Variant(plTimeout));
}
/**
*
* @param plTimeout
* the new "CommandTimeout"
*/
public void setCommandTimeout(int plTimeout) {
Dispatch.put(this, "CommandTimeout", new Variant(plTimeout));
}
/**
*
* @return results from "Prepared"
*/
public boolean getPrepared() {
return Dispatch.get(this, "Prepared").getBoolean();
}
/**
*
* @return results from "Prepared"
*/
public boolean getPrepared() {
return Dispatch.get(this, "Prepared").getBoolean();
}
/**
*
* @param pfPrepared
* the new value for "Prepared"
*/
public void setPrepared(boolean pfPrepared) {
Dispatch.put(this, "Prepared", new Variant(pfPrepared));
}
/**
*
* @param pfPrepared
* the new value for "Prepared"
*/
public void setPrepared(boolean pfPrepared) {
Dispatch.put(this, "Prepared", new Variant(pfPrepared));
}
/**
* "Execute"s a command
*
* @param RecordsAffected
* @param Parameters
* @param Options
* @return
*/
public Recordset Execute(Variant RecordsAffected, Variant Parameters,
int Options) {
return (Recordset) Dispatch.call(this, "Execute", RecordsAffected,
Parameters, new Variant(Options)).toDispatch();
}
/**
* "Execute"s a command
*
* @param RecordsAffected
* @param Parameters
* @param Options
* @return
*/
public Recordset Execute(Variant RecordsAffected, Variant Parameters,
int Options) {
return (Recordset) Dispatch.call(this, "Execute", RecordsAffected,
Parameters, new Variant(Options)).toDispatch();
}
/**
* "Execute"s a command
*
* @return
*/
public Recordset Execute() {
Variant dummy = new Variant();
return new Recordset(Dispatch.call(this, "Execute", dummy).toDispatch());
}
/**
* "Execute"s a command
*
* @return
*/
public Recordset Execute() {
Variant dummy = new Variant();
return new Recordset(Dispatch.call(this, "Execute", dummy).toDispatch());
}
/**
* creates a parameter
*
* @param Name
* @param Type
* @param Direction
* @param Size
* @param Value
* @return
*/
public Variant CreateParameter(String Name, int Type, int Direction,
int Size, Variant Value) {
return Dispatch.call(this, "CreateParameter", Name, new Variant(Type),
new Variant(Direction), new Variant(Size), Value);
}
/**
* creates a parameter
*
* @param Name
* @param Type
* @param Direction
* @param Size
* @param Value
* @return
*/
public Variant CreateParameter(String Name, int Type, int Direction,
int Size, Variant Value) {
return Dispatch.call(this, "CreateParameter", Name, new Variant(Type),
new Variant(Direction), new Variant(Size), Value);
}
// need to wrap Parameters
/**
* @return "Parameters"
*/
public Variant getParameters() {
return Dispatch.get(this, "Parameters");
}
// need to wrap Parameters
/**
* @return "Parameters"
*/
public Variant getParameters() {
return Dispatch.get(this, "Parameters");
}
/**
*
* @param plCmdType
* new "CommandType"
*/
public void setCommandType(int plCmdType) {
Dispatch.put(this, "CommandType", new Variant(plCmdType));
}
/**
*
* @param plCmdType
* new "CommandType"
*/
public void setCommandType(int plCmdType) {
Dispatch.put(this, "CommandType", new Variant(plCmdType));
}
/**
*
* @return current "CommandType"
*/
public int getCommandType() {
return Dispatch.get(this, "CommandType").getInt();
}
/**
*
* @return current "CommandType"
*/
public int getCommandType() {
return Dispatch.get(this, "CommandType").getInt();
}
/**
*
* @return "Name"
*/
public String getName() {
return Dispatch.get(this, "Name").toString();
}
/**
*
* @return "Name"
*/
public String getName() {
return Dispatch.get(this, "Name").toString();
}
/**
*
* @param pbstrName
* new "Name"
*/
public void setName(String pbstrName) {
Dispatch.put(this, "Name", pbstrName);
}
/**
*
* @param pbstrName
* new "Name"
*/
public void setName(String pbstrName) {
Dispatch.put(this, "Name", pbstrName);
}
/**
*
* @return curent "State"
*/
public int getState() {
return Dispatch.get(this, "State").getInt();
}
/**
*
* @return curent "State"
*/
public int getState() {
return Dispatch.get(this, "State").getInt();
}
/**
* cancel whatever it is we're doing
*/
public void Cancel() {
Dispatch.call(this, "Cancel");
}
/**
* cancel whatever it is we're doing
*/
public void Cancel() {
Dispatch.call(this, "Cancel");
}
}

View File

@@ -3,11 +3,11 @@ package com.jacob.samples.ado;
// Enum: CommandTypeEnum
public interface CommandTypeEnum {
public static final int adCmdUnspecified = -1;
public static final int adCmdUnknown = 8;
public static final int adCmdText = 1;
public static final int adCmdTable = 2;
public static final int adCmdStoredProc = 4;
public static final int adCmdFile = 256;
public static final int adCmdTableDirect = 512;
public static final int adCmdUnspecified = -1;
public static final int adCmdUnknown = 8;
public static final int adCmdText = 1;
public static final int adCmdTable = 2;
public static final int adCmdStoredProc = 4;
public static final int adCmdFile = 256;
public static final int adCmdTableDirect = 512;
}

View File

@@ -4,148 +4,148 @@ import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Connection extends Dispatch {
public Connection() {
super("ADODB.Connection");
}
public Connection() {
super("ADODB.Connection");
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Connection(Dispatch d) {
super(d);
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Connection(Dispatch d) {
super(d);
}
// need to wrap Properties
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
// need to wrap Properties
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
public String getConnectionString() {
return Dispatch.get(this, "ConnectionString").toString();
}
public String getConnectionString() {
return Dispatch.get(this, "ConnectionString").toString();
}
public void setConnectionString(String pbstr) {
Dispatch.put(this, "ConnectionString", pbstr);
}
public void setConnectionString(String pbstr) {
Dispatch.put(this, "ConnectionString", pbstr);
}
public int getCommandTimeout() {
return Dispatch.get(this, "CommandTimeout").getInt();
}
public int getCommandTimeout() {
return Dispatch.get(this, "CommandTimeout").getInt();
}
public void setCommandTimeout(int plTimeout) {
Dispatch.put(this, "CommandTimeout", new Variant(plTimeout));
}
public void setCommandTimeout(int plTimeout) {
Dispatch.put(this, "CommandTimeout", new Variant(plTimeout));
}
public int getConnectionTimeout() {
return Dispatch.get(this, "ConnectionTimeout").getInt();
}
public int getConnectionTimeout() {
return Dispatch.get(this, "ConnectionTimeout").getInt();
}
public void setConnectionTimeout(int plTimeout) {
Dispatch.put(this, "ConnectionTimeout", new Variant(plTimeout));
}
public void setConnectionTimeout(int plTimeout) {
Dispatch.put(this, "ConnectionTimeout", new Variant(plTimeout));
}
public String getVersion() {
return Dispatch.get(this, "Version").toString();
}
public String getVersion() {
return Dispatch.get(this, "Version").toString();
}
public void Close() {
Dispatch.call(this, "Close");
}
public void Close() {
Dispatch.call(this, "Close");
}
// how to deal with RecordsAffected being output?
public Variant Execute(String CommandText, Variant RecordsAffected,
int Options) {
return Dispatch.call(this, CommandText, RecordsAffected, new Variant(
Options));
}
// how to deal with RecordsAffected being output?
public Variant Execute(String CommandText, Variant RecordsAffected,
int Options) {
return Dispatch.call(this, CommandText, RecordsAffected, new Variant(
Options));
}
public int BeginTrans() {
return Dispatch.call(this, "BeginTrans").getInt();
}
public int BeginTrans() {
return Dispatch.call(this, "BeginTrans").getInt();
}
public void CommitTrans() {
Dispatch.call(this, "CommitTrans");
}
public void CommitTrans() {
Dispatch.call(this, "CommitTrans");
}
public void RollbackTrans() {
Dispatch.call(this, "RollbackTrans");
}
public void RollbackTrans() {
Dispatch.call(this, "RollbackTrans");
}
public void Open(String ConnectionString, String UserID, String Password,
int Options) {
Dispatch.call(this, "Open", ConnectionString, UserID, Password,
new Variant(Options));
}
public void Open(String ConnectionString, String UserID, String Password,
int Options) {
Dispatch.call(this, "Open", ConnectionString, UserID, Password,
new Variant(Options));
}
public void Open() {
Dispatch.call(this, "Open");
}
public void Open() {
Dispatch.call(this, "Open");
}
public Variant getErrors() {
return Dispatch.get(this, "Errors");
}
public Variant getErrors() {
return Dispatch.get(this, "Errors");
}
public String getDefaultDatabase() {
return Dispatch.get(this, "DefaultDatabase").toString();
}
public String getDefaultDatabase() {
return Dispatch.get(this, "DefaultDatabase").toString();
}
public void setDefaultDatabase(String pbstr) {
Dispatch.put(this, "DefaultDatabase", pbstr);
}
public void setDefaultDatabase(String pbstr) {
Dispatch.put(this, "DefaultDatabase", pbstr);
}
public int getIsolationLevel() {
return Dispatch.get(this, "IsolationLevel").getInt();
}
public int getIsolationLevel() {
return Dispatch.get(this, "IsolationLevel").getInt();
}
public void setIsolationLevel(int Level) {
Dispatch.put(this, "IsolationLevel", new Variant(Level));
}
public void setIsolationLevel(int Level) {
Dispatch.put(this, "IsolationLevel", new Variant(Level));
}
public int getAttributes() {
return Dispatch.get(this, "Attributes").getInt();
}
public int getAttributes() {
return Dispatch.get(this, "Attributes").getInt();
}
public void setAttributes(int plAttr) {
Dispatch.put(this, "Attributes", new Variant(plAttr));
}
public void setAttributes(int plAttr) {
Dispatch.put(this, "Attributes", new Variant(plAttr));
}
public int getCursorLocation() {
return Dispatch.get(this, "CursorLocation").getInt();
}
public int getCursorLocation() {
return Dispatch.get(this, "CursorLocation").getInt();
}
public void setCursorLocation(int plCursorLoc) {
Dispatch.put(this, "CursorLocation", new Variant(plCursorLoc));
}
public void setCursorLocation(int plCursorLoc) {
Dispatch.put(this, "CursorLocation", new Variant(plCursorLoc));
}
public int getMode() {
return Dispatch.get(this, "Mode").getInt();
}
public int getMode() {
return Dispatch.get(this, "Mode").getInt();
}
public void setMode(int plMode) {
Dispatch.put(this, "Mode", new Variant(plMode));
}
public void setMode(int plMode) {
Dispatch.put(this, "Mode", new Variant(plMode));
}
public String getProvider() {
return Dispatch.get(this, "Provider").toString();
}
public String getProvider() {
return Dispatch.get(this, "Provider").toString();
}
public void setProvider(String pbstr) {
Dispatch.put(this, "Provider", pbstr);
}
public void setProvider(String pbstr) {
Dispatch.put(this, "Provider", pbstr);
}
public int getState() {
return Dispatch.get(this, "State").getInt();
}
public int getState() {
return Dispatch.get(this, "State").getInt();
}
public Variant OpenSchema(int Schema, Variant Restrictions, Variant SchemaID) {
return Dispatch.call(this, "OpenSchema", new Variant(Schema),
Restrictions, SchemaID);
}
public Variant OpenSchema(int Schema, Variant Restrictions, Variant SchemaID) {
return Dispatch.call(this, "OpenSchema", new Variant(Schema),
Restrictions, SchemaID);
}
public void Cancel() {
Dispatch.call(this, "Cancel");
}
public void Cancel() {
Dispatch.call(this, "Cancel");
}
}

View File

@@ -4,98 +4,98 @@ import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Field extends Dispatch {
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Field(Dispatch d) {
super(d);
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Field(Dispatch d) {
super(d);
}
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
public int getActualSize() {
return Dispatch.get(this, "ActualSize").getInt();
}
public int getActualSize() {
return Dispatch.get(this, "ActualSize").getInt();
}
public int getAttributes() {
return Dispatch.get(this, "Attributes").getInt();
}
public int getAttributes() {
return Dispatch.get(this, "Attributes").getInt();
}
public int getDefinedSize() {
return Dispatch.get(this, "DefinedSize").getInt();
}
public int getDefinedSize() {
return Dispatch.get(this, "DefinedSize").getInt();
}
public String getName() {
return Dispatch.get(this, "Name").toString();
}
public String getName() {
return Dispatch.get(this, "Name").toString();
}
public int getType() {
return Dispatch.get(this, "Type").getInt();
}
public int getType() {
return Dispatch.get(this, "Type").getInt();
}
public Variant getValue() {
return Dispatch.get(this, "Value");
}
public Variant getValue() {
return Dispatch.get(this, "Value");
}
public void setValue(Variant pvar) {
Dispatch.put(this, "Value", pvar);
}
public void setValue(Variant pvar) {
Dispatch.put(this, "Value", pvar);
}
public byte getPrecision() {
return Dispatch.get(this, "Precision").getByte();
}
public byte getPrecision() {
return Dispatch.get(this, "Precision").getByte();
}
public byte getNumericScale() {
return Dispatch.get(this, "NumericScale").getByte();
}
public byte getNumericScale() {
return Dispatch.get(this, "NumericScale").getByte();
}
public void AppendChunk(Variant Data) {
Dispatch.call(this, "AppendChunk", Data);
}
public void AppendChunk(Variant Data) {
Dispatch.call(this, "AppendChunk", Data);
}
public Variant GetChunk(int Length) {
return Dispatch.call(this, "GetChunk", new Variant(Length));
}
public Variant GetChunk(int Length) {
return Dispatch.call(this, "GetChunk", new Variant(Length));
}
public Variant getOriginalValue() {
return Dispatch.get(this, "OriginalValue");
}
public Variant getOriginalValue() {
return Dispatch.get(this, "OriginalValue");
}
public Variant getUnderlyingValue() {
return Dispatch.get(this, "UnderlyingValue");
}
public Variant getUnderlyingValue() {
return Dispatch.get(this, "UnderlyingValue");
}
public Variant getDataFormat() {
return Dispatch.get(this, "DataFormat");
}
public Variant getDataFormat() {
return Dispatch.get(this, "DataFormat");
}
public void setDataFormat(Variant ppiDF) {
Dispatch.put(this, "DataFormat", ppiDF);
}
public void setDataFormat(Variant ppiDF) {
Dispatch.put(this, "DataFormat", ppiDF);
}
public void setPrecision(byte pb) {
Dispatch.put(this, "Precision", new Variant(pb));
}
public void setPrecision(byte pb) {
Dispatch.put(this, "Precision", new Variant(pb));
}
public void setNumericScale(byte pb) {
Dispatch.put(this, "NumericScale", new Variant(pb));
}
public void setNumericScale(byte pb) {
Dispatch.put(this, "NumericScale", new Variant(pb));
}
public void setType(int pDataType) {
Dispatch.put(this, "Type", new Variant(pDataType));
}
public void setType(int pDataType) {
Dispatch.put(this, "Type", new Variant(pDataType));
}
public void setDefinedSize(int pl) {
Dispatch.put(this, "DefinedSize", new Variant(pl));
}
public void setDefinedSize(int pl) {
Dispatch.put(this, "DefinedSize", new Variant(pl));
}
public void setAttributes(int pl) {
Dispatch.put(this, "Attributes", new Variant(pl));
}
public void setAttributes(int pl) {
Dispatch.put(this, "Attributes", new Variant(pl));
}
}

View File

@@ -4,40 +4,40 @@ import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Fields extends Dispatch {
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Fields(Dispatch d) {
super(d);
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Fields(Dispatch d) {
super(d);
}
public int getCount() {
return Dispatch.get(this, "Count").getInt();
}
public int getCount() {
return Dispatch.get(this, "Count").getInt();
}
public Variant _NewEnum() {
return Dispatch.call(this, "_NewEnum");
}
public Variant _NewEnum() {
return Dispatch.call(this, "_NewEnum");
}
public void Refresh() {
Dispatch.call(this, "Refresh");
}
public void Refresh() {
Dispatch.call(this, "Refresh");
}
public Field getItem(int Index) {
return new Field(Dispatch.call(this, "Item", new Variant(Index))
.toDispatch());
}
public Field getItem(int Index) {
return new Field(Dispatch.call(this, "Item", new Variant(Index))
.toDispatch());
}
public void Append(String Name, int Type, int DefinedSize, int Attrib) {
Dispatch.call(this, "Append", Name, new Variant(Type), new Variant(
DefinedSize), new Variant(Attrib));
}
public void Append(String Name, int Type, int DefinedSize, int Attrib) {
Dispatch.call(this, "Append", Name, new Variant(Type), new Variant(
DefinedSize), new Variant(Attrib));
}
public void Delete(Variant Index) {
Dispatch.call(this, "Delete", Index);
}
public void Delete(Variant Index) {
Dispatch.call(this, "Delete", Index);
}
}

View File

@@ -4,339 +4,339 @@ import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Recordset extends Dispatch {
public Recordset() {
super("ADODB.Recordset");
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Recordset(Dispatch d) {
super(d);
}
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
public int getAbsolutePosition() {
return Dispatch.get(this, "AbsolutePosition").getInt();
}
public void setAbsolutePosition(int pl) {
Dispatch.put(this, "AbsolutePosition", new Variant(pl));
}
public Connection getActiveConnection() {
return new Connection(Dispatch.get(this, "ActiveConnection")
.toDispatch());
}
public void setActiveConnection(Connection ppvObject) {
Dispatch.put(this, "ActiveConnection", ppvObject);
}
public void setActiveConnection(Variant ppvObject) {
Dispatch.put(this, "ActiveConnection", ppvObject);
}
public boolean getBOF() {
return Dispatch.get(this, "BOF").getBoolean();
}
public Variant getBookmark() {
return Dispatch.get(this, "Bookmark");
}
public void setBookmark(Variant pvBookmark) {
Dispatch.put(this, "Bookmark", pvBookmark);
}
public int getCacheSize() {
return Dispatch.get(this, "CacheSize").getInt();
}
public void setCacheSize(int pl) {
Dispatch.put(this, "CacheSize", new Variant(pl));
}
public int getCursorType() {
return Dispatch.get(this, "CursorType").getInt();
}
public void setCursorType(int pl) {
Dispatch.put(this, "CursorType", new Variant(pl));
}
public boolean getEOF() {
return Dispatch.get(this, "EOF").getBoolean();
}
public Fields getFields() {
return new Fields(Dispatch.get(this, "Fields").toDispatch());
}
public int getLockType() {
return Dispatch.get(this, "LockType").getInt();
}
public void setLockType(int plLockType) {
Dispatch.put(this, "LockType", new Variant(plLockType));
}
public int getMaxRecords() {
return Dispatch.get(this, "MaxRecords").getInt();
}
public void setMaxRecords(int pl) {
Dispatch.put(this, "MaxRecords", new Variant(pl));
}
public int getRecordCount() {
return Dispatch.get(this, "RecordCount").getInt();
}
public void setSource(Object pvSource) {
Dispatch.put(this, "Source", pvSource);
}
public void setSource(String pvSource) {
Dispatch.put(this, "Source", pvSource);
}
public Variant getSource() {
return Dispatch.get(this, "Source");
}
public void AddNew(Variant FieldList, Variant Values) {
Dispatch.call(this, "AddNew", FieldList, Values);
}
public void CancelUpdate() {
Dispatch.call(this, "CancelUpdate");
}
public void Close() {
Dispatch.call(this, "Close");
}
public void Delete(int AffectRecords) {
Dispatch.call(this, "Delete", new Variant(AffectRecords));
}
public Variant GetRows(int Rows, Variant Start, Variant Fields) {
return Dispatch.call(this, "GetRows", new Variant(Rows), Start, Fields);
}
// get all rows
public Variant GetRows() {
return Dispatch.call(this, "GetRows");
}
public void Move(int NumRecords, Variant Start) {
Dispatch.call(this, "Move", new Variant(NumRecords), Start);
}
public void MoveNext() {
Dispatch.call(this, "MoveNext");
}
public void MovePrevious() {
Dispatch.call(this, "MovePrevious");
}
public void MoveFirst() {
Dispatch.call(this, "MoveFirst");
}
public void MoveLast() {
Dispatch.call(this, "MoveLast");
}
public void Open(Variant Source, Variant ActiveConnection, int CursorType,
int LockType, int Options) {
Dispatch.call(this, "Open", Source, ActiveConnection, new Variant(
CursorType), new Variant(LockType), new Variant(Options));
}
public void Open(Variant Source, Variant ActiveConnection) {
Dispatch.call(this, "Open", Source, ActiveConnection);
}
public void Requery(int Options) {
Dispatch.call(this, "Requery", new Variant(Options));
}
public void Update(Variant Fields, Variant Values) {
Dispatch.call(this, "Update", Fields, Values);
}
public int getAbsolutePage() {
return Dispatch.get(this, "AbsolutePage").getInt();
}
public void setAbsolutePage(int pl) {
Dispatch.put(this, "AbsolutePage", new Variant(pl));
}
public int getEditMode() {
return Dispatch.get(this, "EditMode").getInt();
}
public Variant getFilter() {
return Dispatch.get(this, "Filter");
}
public void setFilter(Variant Criteria) {
Dispatch.put(this, "Filter", Criteria);
}
public int getPageCount() {
return Dispatch.get(this, "PageCount").getInt();
}
public int getPageSize() {
return Dispatch.get(this, "PageSize").getInt();
}
public void setPageSize(int pl) {
Dispatch.put(this, "PageSize", new Variant(pl));
}
public String getSort() {
return Dispatch.get(this, "Sort").toString();
}
public void setSort(String Criteria) {
Dispatch.put(this, "Sort", Criteria);
}
public int getStatus() {
return Dispatch.get(this, "Status").getInt();
}
public int getState() {
return Dispatch.get(this, "State").getInt();
}
public void UpdateBatch(int AffectRecords) {
Dispatch.call(this, "UpdateBatch", new Variant(AffectRecords));
}
public void CancelBatch(int AffectRecords) {
Dispatch.call(this, "CancelBatch", new Variant(AffectRecords));
}
public int getCursorLocation() {
return Dispatch.get(this, "CursorLocation").getInt();
}
public void setCursorLocation(int pl) {
Dispatch.put(this, "CursorLocation", new Variant(pl));
}
public Recordset NextRecordset(Variant RecordsAffected) {
return new Recordset(Dispatch.call(this, "NextRecordset",
RecordsAffected).toDispatch());
}
public boolean Supports(int CursorOptions) {
return Dispatch.call(this, "Supports", new Variant(CursorOptions))
.getBoolean();
}
public Variant getCollect(Variant Index) {
return Dispatch.get(this, "Collect");
}
public void setCollect(Variant Index, Variant pvar) {
Dispatch.call(this, "Collect", Index, pvar);
}
public int getMarshalOptions() {
return Dispatch.get(this, "MarshalOptions").getInt();
}
public void setMarshalOptions(int pl) {
Dispatch.put(this, "MarshalOptions", new Variant(pl));
}
public void Find(String Criteria, int SkipRecords, int SearchDirection,
Variant Start) {
Dispatch.call(this, "Find", Criteria, new Variant(SkipRecords),
new Variant(SearchDirection), Start);
}
public void Cancel() {
Dispatch.call(this, "Cancel");
}
public Variant getDataSource() {
return Dispatch.get(this, "DataSource");
}
public void setDataSource(Variant ppunkDataSource) {
Dispatch.put(this, "DataSource", ppunkDataSource);
}
public void Save(String FileName, int PersistFormat) {
Dispatch.call(this, "Save", FileName, new Variant(PersistFormat));
}
public Variant getActiveCommand() {
return Dispatch.get(this, "ActiveCommand");
}
public void setStayInSync(boolean pb) {
Dispatch.put(this, "StayInSync", new Variant(pb));
}
public boolean getStayInSync() {
return Dispatch.get(this, "StayInSync").getBoolean();
}
public String GetString(int StringFormat, int NumRows,
String ColumnDelimeter, String RowDelimeter, String NullExpr) {
return Dispatch.call(this, "GetString", new Variant(StringFormat),
new Variant(NumRows), ColumnDelimeter, RowDelimeter, NullExpr)
.toString();
}
public String getDataMember() {
return Dispatch.get(this, "DataMember").toString();
}
public void setDataMember(String pl) {
Dispatch.put(this, "DataMember", new Variant(pl));
}
public int CompareBookmarks(Variant Bookmark1, Variant Bookmark2) {
return Dispatch.call(this, "CompareBookmarks", Bookmark1, Bookmark2)
.getInt();
}
public Recordset Clone(int LockType) {
return new Recordset(Dispatch
.call(this, "Clone", new Variant(LockType)).toDispatch());
}
public void Resync(int AffectRecords, int ResyncValues) {
Dispatch.call(this, "Resync", new Variant(AffectRecords), new Variant(
ResyncValues));
}
public void Seek(Variant KeyValues, int SeekOption) {
Dispatch.call(this, "Seek", KeyValues, new Variant(SeekOption));
}
public void setIndex(String pl) {
Dispatch.put(this, "Index", new Variant(pl));
}
public String getIndex() {
return Dispatch.get(this, "Index)").toString();
}
public Recordset() {
super("ADODB.Recordset");
}
/**
* This constructor is used instead of a case operation to turn a Dispatch
* object into a wider object - it must exist in every wrapper class whose
* instances may be returned from method calls wrapped in VT_DISPATCH
* Variants.
*/
public Recordset(Dispatch d) {
super(d);
}
public Variant getProperties() {
return Dispatch.get(this, "Properties");
}
public int getAbsolutePosition() {
return Dispatch.get(this, "AbsolutePosition").getInt();
}
public void setAbsolutePosition(int pl) {
Dispatch.put(this, "AbsolutePosition", new Variant(pl));
}
public Connection getActiveConnection() {
return new Connection(Dispatch.get(this, "ActiveConnection")
.toDispatch());
}
public void setActiveConnection(Connection ppvObject) {
Dispatch.put(this, "ActiveConnection", ppvObject);
}
public void setActiveConnection(Variant ppvObject) {
Dispatch.put(this, "ActiveConnection", ppvObject);
}
public boolean getBOF() {
return Dispatch.get(this, "BOF").getBoolean();
}
public Variant getBookmark() {
return Dispatch.get(this, "Bookmark");
}
public void setBookmark(Variant pvBookmark) {
Dispatch.put(this, "Bookmark", pvBookmark);
}
public int getCacheSize() {
return Dispatch.get(this, "CacheSize").getInt();
}
public void setCacheSize(int pl) {
Dispatch.put(this, "CacheSize", new Variant(pl));
}
public int getCursorType() {
return Dispatch.get(this, "CursorType").getInt();
}
public void setCursorType(int pl) {
Dispatch.put(this, "CursorType", new Variant(pl));
}
public boolean getEOF() {
return Dispatch.get(this, "EOF").getBoolean();
}
public Fields getFields() {
return new Fields(Dispatch.get(this, "Fields").toDispatch());
}
public int getLockType() {
return Dispatch.get(this, "LockType").getInt();
}
public void setLockType(int plLockType) {
Dispatch.put(this, "LockType", new Variant(plLockType));
}
public int getMaxRecords() {
return Dispatch.get(this, "MaxRecords").getInt();
}
public void setMaxRecords(int pl) {
Dispatch.put(this, "MaxRecords", new Variant(pl));
}
public int getRecordCount() {
return Dispatch.get(this, "RecordCount").getInt();
}
public void setSource(Object pvSource) {
Dispatch.put(this, "Source", pvSource);
}
public void setSource(String pvSource) {
Dispatch.put(this, "Source", pvSource);
}
public Variant getSource() {
return Dispatch.get(this, "Source");
}
public void AddNew(Variant FieldList, Variant Values) {
Dispatch.call(this, "AddNew", FieldList, Values);
}
public void CancelUpdate() {
Dispatch.call(this, "CancelUpdate");
}
public void Close() {
Dispatch.call(this, "Close");
}
public void Delete(int AffectRecords) {
Dispatch.call(this, "Delete", new Variant(AffectRecords));
}
public Variant GetRows(int Rows, Variant Start, Variant Fields) {
return Dispatch.call(this, "GetRows", new Variant(Rows), Start, Fields);
}
// get all rows
public Variant GetRows() {
return Dispatch.call(this, "GetRows");
}
public void Move(int NumRecords, Variant Start) {
Dispatch.call(this, "Move", new Variant(NumRecords), Start);
}
public void MoveNext() {
Dispatch.call(this, "MoveNext");
}
public void MovePrevious() {
Dispatch.call(this, "MovePrevious");
}
public void MoveFirst() {
Dispatch.call(this, "MoveFirst");
}
public void MoveLast() {
Dispatch.call(this, "MoveLast");
}
public void Open(Variant Source, Variant ActiveConnection, int CursorType,
int LockType, int Options) {
Dispatch.call(this, "Open", Source, ActiveConnection, new Variant(
CursorType), new Variant(LockType), new Variant(Options));
}
public void Open(Variant Source, Variant ActiveConnection) {
Dispatch.call(this, "Open", Source, ActiveConnection);
}
public void Requery(int Options) {
Dispatch.call(this, "Requery", new Variant(Options));
}
public void Update(Variant Fields, Variant Values) {
Dispatch.call(this, "Update", Fields, Values);
}
public int getAbsolutePage() {
return Dispatch.get(this, "AbsolutePage").getInt();
}
public void setAbsolutePage(int pl) {
Dispatch.put(this, "AbsolutePage", new Variant(pl));
}
public int getEditMode() {
return Dispatch.get(this, "EditMode").getInt();
}
public Variant getFilter() {
return Dispatch.get(this, "Filter");
}
public void setFilter(Variant Criteria) {
Dispatch.put(this, "Filter", Criteria);
}
public int getPageCount() {
return Dispatch.get(this, "PageCount").getInt();
}
public int getPageSize() {
return Dispatch.get(this, "PageSize").getInt();
}
public void setPageSize(int pl) {
Dispatch.put(this, "PageSize", new Variant(pl));
}
public String getSort() {
return Dispatch.get(this, "Sort").toString();
}
public void setSort(String Criteria) {
Dispatch.put(this, "Sort", Criteria);
}
public int getStatus() {
return Dispatch.get(this, "Status").getInt();
}
public int getState() {
return Dispatch.get(this, "State").getInt();
}
public void UpdateBatch(int AffectRecords) {
Dispatch.call(this, "UpdateBatch", new Variant(AffectRecords));
}
public void CancelBatch(int AffectRecords) {
Dispatch.call(this, "CancelBatch", new Variant(AffectRecords));
}
public int getCursorLocation() {
return Dispatch.get(this, "CursorLocation").getInt();
}
public void setCursorLocation(int pl) {
Dispatch.put(this, "CursorLocation", new Variant(pl));
}
public Recordset NextRecordset(Variant RecordsAffected) {
return new Recordset(Dispatch.call(this, "NextRecordset",
RecordsAffected).toDispatch());
}
public boolean Supports(int CursorOptions) {
return Dispatch.call(this, "Supports", new Variant(CursorOptions))
.getBoolean();
}
public Variant getCollect(Variant Index) {
return Dispatch.get(this, "Collect");
}
public void setCollect(Variant Index, Variant pvar) {
Dispatch.call(this, "Collect", Index, pvar);
}
public int getMarshalOptions() {
return Dispatch.get(this, "MarshalOptions").getInt();
}
public void setMarshalOptions(int pl) {
Dispatch.put(this, "MarshalOptions", new Variant(pl));
}
public void Find(String Criteria, int SkipRecords, int SearchDirection,
Variant Start) {
Dispatch.call(this, "Find", Criteria, new Variant(SkipRecords),
new Variant(SearchDirection), Start);
}
public void Cancel() {
Dispatch.call(this, "Cancel");
}
public Variant getDataSource() {
return Dispatch.get(this, "DataSource");
}
public void setDataSource(Variant ppunkDataSource) {
Dispatch.put(this, "DataSource", ppunkDataSource);
}
public void Save(String FileName, int PersistFormat) {
Dispatch.call(this, "Save", FileName, new Variant(PersistFormat));
}
public Variant getActiveCommand() {
return Dispatch.get(this, "ActiveCommand");
}
public void setStayInSync(boolean pb) {
Dispatch.put(this, "StayInSync", new Variant(pb));
}
public boolean getStayInSync() {
return Dispatch.get(this, "StayInSync").getBoolean();
}
public String GetString(int StringFormat, int NumRows,
String ColumnDelimeter, String RowDelimeter, String NullExpr) {
return Dispatch.call(this, "GetString", new Variant(StringFormat),
new Variant(NumRows), ColumnDelimeter, RowDelimeter, NullExpr)
.toString();
}
public String getDataMember() {
return Dispatch.get(this, "DataMember").toString();
}
public void setDataMember(String pl) {
Dispatch.put(this, "DataMember", new Variant(pl));
}
public int CompareBookmarks(Variant Bookmark1, Variant Bookmark2) {
return Dispatch.call(this, "CompareBookmarks", Bookmark1, Bookmark2)
.getInt();
}
public Recordset Clone(int LockType) {
return new Recordset(Dispatch
.call(this, "Clone", new Variant(LockType)).toDispatch());
}
public void Resync(int AffectRecords, int ResyncValues) {
Dispatch.call(this, "Resync", new Variant(AffectRecords), new Variant(
ResyncValues));
}
public void Seek(Variant KeyValues, int SeekOption) {
Dispatch.call(this, "Seek", KeyValues, new Variant(SeekOption));
}
public void setIndex(String pl) {
Dispatch.put(this, "Index", new Variant(pl));
}
public String getIndex() {
return Dispatch.get(this, "Index)").toString();
}
}

View File

@@ -3,54 +3,54 @@ package com.jacob.samples.ado;
import com.jacob.com.Variant;
public class test {
public static void printRS(Recordset rs) {
Fields fs = rs.getFields();
public static void printRS(Recordset rs) {
Fields fs = rs.getFields();
for (int i = 0; i < fs.getCount(); i++) {
System.out.print(fs.getItem(i).getName() + " ");
}
System.out.println("");
for (int i = 0; i < fs.getCount(); i++) {
System.out.print(fs.getItem(i).getName() + " ");
}
System.out.println("");
rs.MoveFirst();
while (!rs.getEOF()) {
for (int i = 0; i < fs.getCount(); i++) {
Field f = fs.getItem(i);
Variant v = f.getValue();
System.out.print(v + " ");
}
System.out.println("");
rs.MoveNext();
}
}
rs.MoveFirst();
while (!rs.getEOF()) {
for (int i = 0; i < fs.getCount(); i++) {
Field f = fs.getItem(i);
Variant v = f.getValue();
System.out.print(v + " ");
}
System.out.println("");
rs.MoveNext();
}
}
// open a recordset directly
public static void getRS(String con, String query) {
System.out.println("Recordset Open");
Recordset rs = new Recordset();
rs.Open(new Variant(query), new Variant(con));
printRS(rs);
}
// open a recordset directly
public static void getRS(String con, String query) {
System.out.println("Recordset Open");
Recordset rs = new Recordset();
rs.Open(new Variant(query), new Variant(con));
printRS(rs);
}
// create connection and command objects and use them
// to get a recordset
public static void getCommand(String con, String query) {
System.out.println("Command+Connection -> Recordset");
Connection c = new Connection();
c.setConnectionString(con);
c.Open();
Command comm = new Command();
comm.setActiveConnection(c);
comm.setCommandType(CommandTypeEnum.adCmdText);
comm.setCommandText(query);
Recordset rs = comm.Execute();
printRS(rs);
c.Close();
}
// create connection and command objects and use them
// to get a recordset
public static void getCommand(String con, String query) {
System.out.println("Command+Connection -> Recordset");
Connection c = new Connection();
c.setConnectionString(con);
c.Open();
Command comm = new Command();
comm.setActiveConnection(c);
comm.setCommandType(CommandTypeEnum.adCmdText);
comm.setCommandText(query);
Recordset rs = comm.Execute();
printRS(rs);
c.Close();
}
public static void main(String[] args) {
String connectStr = "DRIVER=SQL Server;SERVER=DANADLER;UID=sa;PWD=;WSID=DANADLER;DATABASE=pubs";
String queryStr = "select * from authors";
getCommand(connectStr, queryStr);
getRS(connectStr, queryStr);
}
public static void main(String[] args) {
String connectStr = "DRIVER=SQL Server;SERVER=DANADLER;UID=sa;PWD=;WSID=DANADLER;DATABASE=pubs";
String queryStr = "select * from authors";
getCommand(connectStr, queryStr);
getRS(connectStr, queryStr);
}
}

View File

@@ -26,63 +26,63 @@ import com.jacob.com.Variant;
public class JacobTestApplet extends Applet implements ActionListener {
private static final long serialVersionUID = 4492492907986849158L;
private static final long serialVersionUID = 4492492907986849158L;
TextField in;
TextField out;
Button calc;
ActiveXComponent sC = null;
TextField in;
TextField out;
Button calc;
ActiveXComponent sC = null;
/**
* startup method
*/
@Override
public void init() {
setLayout(new FlowLayout());
add(this.in = new TextField("1+1", 16));
add(this.out = new TextField("?", 16));
add(this.calc = new Button("Calculate"));
this.calc.addActionListener(this);
/**
* startup method
*/
@Override
public void init() {
setLayout(new FlowLayout());
add(this.in = new TextField("1+1", 16));
add(this.out = new TextField("?", 16));
add(this.calc = new Button("Calculate"));
this.calc.addActionListener(this);
}
}
/**
* Returns information about this applet.
* According to the java spec:
* "An applet should override this method to return a String containing information about the author, version, and copyright of the applet."
*
* @return information about the applet.
*/
@Override
public String getAppletInfo() {
return "Jacob Test Applet. Written by ttreeck, nepatec GmbH & Co. KG.\nhttp://www.nepatec.de";
}
/**
* Returns information about the parameters that are understood by this applet.
* According to the java spec:
* "An applet should override this method to return an array of Strings describing these parameters."
*
* @return array with a set of three Strings containing the name, the type, and a description.
*/
/**
* Returns information about this applet.
* According to the java spec:
* "An applet should override this method to return a String containing information about the author, version, and copyright of the applet."
*
* @return information about the applet.
*/
@Override
public String getAppletInfo() {
return "Jacob Test Applet. Written by ttreeck, nepatec GmbH & Co. KG.\nhttp://www.nepatec.de";
}
/**
* Returns information about the parameters that are understood by this applet.
* According to the java spec:
* "An applet should override this method to return an array of Strings describing these parameters."
*
* @return array with a set of three Strings containing the name, the type, and a description.
*/
@Override
public String[][] getParameterInfo(){
@Override
public String[][] getParameterInfo(){
return new String[][]{};
}
}
/**
* action method that receives button actions
*
* @param ev the event
*/
public void actionPerformed(ActionEvent ev) {
if (this.sC == null) {
String lang = "VBScript";
this.sC = new ActiveXComponent("ScriptControl");
Dispatch.put(this.sC, "Language", lang);
}
Variant v = Dispatch.call(this.sC, "Eval", this.in.getText());
this.out.setText(v.toString());
}
/**
* action method that receives button actions
*
* @param ev the event
*/
public void actionPerformed(ActionEvent ev) {
if (this.sC == null) {
String lang = "VBScript";
this.sC = new ActiveXComponent("ScriptControl");
Dispatch.put(this.sC, "Language", lang);
}
Variant v = Dispatch.call(this.sC, "Eval", this.in.getText());
this.out.setText(v.toString());
}
}

View File

@@ -9,59 +9,59 @@
STDMETHODIMP Face::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IFace1,
&IID_IFace2,
&IID_IFace3,
};
static const IID* arr[] =
{
&IID_IFace1,
&IID_IFace2,
&IID_IFace3,
};
for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}
STDMETHODIMP Face::get_Face1Name(BSTR *pVal)
{
// TODO: Add your implementation code here
*pVal = name1;
return S_OK;
// TODO: Add your implementation code here
*pVal = name1;
return S_OK;
}
STDMETHODIMP Face::put_Face1Name(BSTR newVal)
{
// TODO: Add your implementation code here
name1 = newVal;
return S_OK;
// TODO: Add your implementation code here
name1 = newVal;
return S_OK;
}
STDMETHODIMP Face::get_Face2Nam(BSTR *pVal)
{
// TODO: Add your implementation code here
*pVal = name2;
return S_OK;
// TODO: Add your implementation code here
*pVal = name2;
return S_OK;
}
STDMETHODIMP Face::put_Face2Nam(BSTR newVal)
{
// TODO: Add your implementation code here
name2 = newVal;
return S_OK;
// TODO: Add your implementation code here
name2 = newVal;
return S_OK;
}
STDMETHODIMP Face::get_Face3Name(BSTR *pVal)
{
// TODO: Add your implementation code here
*pVal = name3;
return S_OK;
// TODO: Add your implementation code here
*pVal = name3;
return S_OK;
}
STDMETHODIMP Face::put_Face3Name(BSTR newVal)
{
// TODO: Add your implementation code here
name3 = newVal;
return S_OK;
// TODO: Add your implementation code here
name3 = newVal;
return S_OK;
}

View File

@@ -15,31 +15,31 @@
// Face
class Face :
public IDispatchImpl<IFace1, &IID_IFace1, &LIBID_MULTIFACELib>,
public IDispatchImpl<IFace2, &IID_IFace2, &LIBID_MULTIFACELib>,
public IDispatchImpl<IFace3, &IID_IFace3, &LIBID_MULTIFACELib>,
public ISupportErrorInfo,
public CComObjectRoot,
public CComCoClass<Face,&CLSID_Face>
public IDispatchImpl<IFace1, &IID_IFace1, &LIBID_MULTIFACELib>,
public IDispatchImpl<IFace2, &IID_IFace2, &LIBID_MULTIFACELib>,
public IDispatchImpl<IFace3, &IID_IFace3, &LIBID_MULTIFACELib>,
public ISupportErrorInfo,
public CComObjectRoot,
public CComCoClass<Face,&CLSID_Face>
{
// IFace1
private:
CComBSTR name1;
// IFace2
CComBSTR name2;
CComBSTR name2;
// IFace3
CComBSTR name3;
CComBSTR name3;
public:
Face() {}
Face() {}
BEGIN_COM_MAP(Face)
COM_INTERFACE_ENTRY2(IDispatch, IFace1)
COM_INTERFACE_ENTRY(IFace1)
COM_INTERFACE_ENTRY(IFace2)
COM_INTERFACE_ENTRY(IFace3)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY2(IDispatch, IFace1)
COM_INTERFACE_ENTRY(IFace1)
COM_INTERFACE_ENTRY(IFace2)
COM_INTERFACE_ENTRY(IFace3)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
//DECLARE_NOT_AGGREGATABLE(Face)
// Remove the comment from the line above if you don't want your object to
@@ -47,17 +47,17 @@ END_COM_MAP()
DECLARE_REGISTRY_RESOURCEID(IDR_Face)
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
public:
STDMETHOD(get_Face3Name)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Face3Name)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Face2Nam)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Face2Nam)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Face1Name)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Face1Name)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Face3Name)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Face3Name)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Face2Nam)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Face2Nam)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Face1Name)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Face1Name)(/*[in]*/ BSTR newVal);
};
#endif // !defined(AFX_FACE_H__9BF24413_B2E0_11D4_A695_00104BFF3241__INCLUDED_)

View File

@@ -40,19 +40,19 @@ extern "C"{
#ifndef __IFace1_FWD_DEFINED__
#define __IFace1_FWD_DEFINED__
typedef interface IFace1 IFace1;
#endif /* __IFace1_FWD_DEFINED__ */
#endif /* __IFace1_FWD_DEFINED__ */
#ifndef __IFace2_FWD_DEFINED__
#define __IFace2_FWD_DEFINED__
typedef interface IFace2 IFace2;
#endif /* __IFace2_FWD_DEFINED__ */
#endif /* __IFace2_FWD_DEFINED__ */
#ifndef __IFace3_FWD_DEFINED__
#define __IFace3_FWD_DEFINED__
typedef interface IFace3 IFace3;
#endif /* __IFace3_FWD_DEFINED__ */
#endif /* __IFace3_FWD_DEFINED__ */
#ifndef __Face_FWD_DEFINED__
@@ -64,7 +64,7 @@ typedef class Face Face;
typedef struct Face Face;
#endif /* __cplusplus */
#endif /* __Face_FWD_DEFINED__ */
#endif /* __Face_FWD_DEFINED__ */
/* header files for imported files */
@@ -97,7 +97,7 @@ EXTERN_C const IID IID_IFace1;
};
#else /* C style interface */
#else /* C style interface */
typedef struct IFace1Vtbl
{
@@ -164,39 +164,39 @@ EXTERN_C const IID IID_IFace1;
#ifdef COBJMACROS
#define IFace1_QueryInterface(This,riid,ppvObject) \
#define IFace1_QueryInterface(This,riid,ppvObject) \
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
#define IFace1_AddRef(This) \
#define IFace1_AddRef(This) \
(This)->lpVtbl -> AddRef(This)
#define IFace1_Release(This) \
#define IFace1_Release(This) \
(This)->lpVtbl -> Release(This)
#define IFace1_GetTypeInfoCount(This,pctinfo) \
#define IFace1_GetTypeInfoCount(This,pctinfo) \
(This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
#define IFace1_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
#define IFace1_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
(This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
#define IFace1_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
#define IFace1_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
(This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
#define IFace1_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
#define IFace1_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
(This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
#define IFace1_get_Face1Name(This,pVal) \
#define IFace1_get_Face1Name(This,pVal) \
(This)->lpVtbl -> get_Face1Name(This,pVal)
#define IFace1_put_Face1Name(This,newVal) \
#define IFace1_put_Face1Name(This,newVal) \
(This)->lpVtbl -> put_Face1Name(This,newVal)
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* C style interface */
@@ -225,7 +225,7 @@ void __RPC_STUB IFace1_put_Face1Name_Stub(
#endif /* __IFace1_INTERFACE_DEFINED__ */
#endif /* __IFace1_INTERFACE_DEFINED__ */
#ifndef __IFace2_INTERFACE_DEFINED__
@@ -251,7 +251,7 @@ EXTERN_C const IID IID_IFace2;
};
#else /* C style interface */
#else /* C style interface */
typedef struct IFace2Vtbl
{
@@ -318,39 +318,39 @@ EXTERN_C const IID IID_IFace2;
#ifdef COBJMACROS
#define IFace2_QueryInterface(This,riid,ppvObject) \
#define IFace2_QueryInterface(This,riid,ppvObject) \
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
#define IFace2_AddRef(This) \
#define IFace2_AddRef(This) \
(This)->lpVtbl -> AddRef(This)
#define IFace2_Release(This) \
#define IFace2_Release(This) \
(This)->lpVtbl -> Release(This)
#define IFace2_GetTypeInfoCount(This,pctinfo) \
#define IFace2_GetTypeInfoCount(This,pctinfo) \
(This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
#define IFace2_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
#define IFace2_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
(This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
#define IFace2_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
#define IFace2_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
(This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
#define IFace2_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
#define IFace2_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
(This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
#define IFace2_get_Face2Nam(This,pVal) \
#define IFace2_get_Face2Nam(This,pVal) \
(This)->lpVtbl -> get_Face2Nam(This,pVal)
#define IFace2_put_Face2Nam(This,newVal) \
#define IFace2_put_Face2Nam(This,newVal) \
(This)->lpVtbl -> put_Face2Nam(This,newVal)
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* C style interface */
@@ -379,7 +379,7 @@ void __RPC_STUB IFace2_put_Face2Nam_Stub(
#endif /* __IFace2_INTERFACE_DEFINED__ */
#endif /* __IFace2_INTERFACE_DEFINED__ */
#ifndef __IFace3_INTERFACE_DEFINED__
@@ -405,7 +405,7 @@ EXTERN_C const IID IID_IFace3;
};
#else /* C style interface */
#else /* C style interface */
typedef struct IFace3Vtbl
{
@@ -472,39 +472,39 @@ EXTERN_C const IID IID_IFace3;
#ifdef COBJMACROS
#define IFace3_QueryInterface(This,riid,ppvObject) \
#define IFace3_QueryInterface(This,riid,ppvObject) \
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
#define IFace3_AddRef(This) \
#define IFace3_AddRef(This) \
(This)->lpVtbl -> AddRef(This)
#define IFace3_Release(This) \
#define IFace3_Release(This) \
(This)->lpVtbl -> Release(This)
#define IFace3_GetTypeInfoCount(This,pctinfo) \
#define IFace3_GetTypeInfoCount(This,pctinfo) \
(This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
#define IFace3_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
#define IFace3_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
(This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
#define IFace3_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
#define IFace3_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
(This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
#define IFace3_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
#define IFace3_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
(This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
#define IFace3_get_Face3Name(This,pVal) \
#define IFace3_get_Face3Name(This,pVal) \
(This)->lpVtbl -> get_Face3Name(This,pVal)
#define IFace3_put_Face3Name(This,newVal) \
#define IFace3_put_Face3Name(This,newVal) \
(This)->lpVtbl -> put_Face3Name(This,newVal)
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* C style interface */
@@ -533,7 +533,7 @@ void __RPC_STUB IFace3_put_Face3Name_Stub(
#endif /* __IFace3_INTERFACE_DEFINED__ */
#endif /* __IFace3_INTERFACE_DEFINED__ */

View File

@@ -346,117 +346,117 @@ static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
0,
{
/* Procedure get_Face3Name */
/* Procedure get_Face3Name */
/* Procedure get_Face2Nam */
/* Procedure get_Face2Nam */
/* Procedure get_Face1Name */
/* Procedure get_Face1Name */
0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
/* 6 */ NdrFcShort( 0x7 ), /* 7 */
0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 2 */ NdrFcLong( 0x0 ), /* 0 */
/* 6 */ NdrFcShort( 0x7 ), /* 7 */
#ifndef _ALPHA_
/* 8 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */
/* 8 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */
#else
NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */
NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */
#endif
/* 10 */ NdrFcShort( 0x0 ), /* 0 */
/* 12 */ NdrFcShort( 0x8 ), /* 8 */
/* 14 */ 0x5, /* Oi2 Flags: srv must size, has return, */
0x2, /* 2 */
/* 10 */ NdrFcShort( 0x0 ), /* 0 */
/* 12 */ NdrFcShort( 0x8 ), /* 8 */
/* 14 */ 0x5, /* Oi2 Flags: srv must size, has return, */
0x2, /* 2 */
/* Parameter pVal */
/* Parameter pVal */
/* Parameter pVal */
/* Parameter pVal */
/* Parameter pVal */
/* Parameter pVal */
/* 16 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
/* 16 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
#ifndef _ALPHA_
/* 18 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */
/* 18 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */
#else
NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */
NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */
#endif
/* 20 */ NdrFcShort( 0x1e ), /* Type Offset=30 */
/* 20 */ NdrFcShort( 0x1e ), /* Type Offset=30 */
/* Return value */
/* Return value */
/* Return value */
/* Return value */
/* Return value */
/* Return value */
/* 22 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 22 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
#ifndef _ALPHA_
/* 24 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */
/* 24 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */
#else
NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
#endif
/* 26 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* 26 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure put_Face3Name */
/* Procedure put_Face3Name */
/* Procedure put_Face2Nam */
/* Procedure put_Face2Nam */
/* Procedure put_Face1Name */
/* Procedure put_Face1Name */
/* 28 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 30 */ NdrFcLong( 0x0 ), /* 0 */
/* 34 */ NdrFcShort( 0x8 ), /* 8 */
/* 28 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 30 */ NdrFcLong( 0x0 ), /* 0 */
/* 34 */ NdrFcShort( 0x8 ), /* 8 */
#ifndef _ALPHA_
/* 36 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */
/* 36 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */
#else
NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */
NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */
#endif
/* 38 */ NdrFcShort( 0x0 ), /* 0 */
/* 40 */ NdrFcShort( 0x8 ), /* 8 */
/* 42 */ 0x6, /* Oi2 Flags: clt must size, has return, */
0x2, /* 2 */
/* 38 */ NdrFcShort( 0x0 ), /* 0 */
/* 40 */ NdrFcShort( 0x8 ), /* 8 */
/* 42 */ 0x6, /* Oi2 Flags: clt must size, has return, */
0x2, /* 2 */
/* Parameter newVal */
/* Parameter newVal */
/* Parameter newVal */
/* Parameter newVal */
/* Parameter newVal */
/* Parameter newVal */
/* 44 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
/* 44 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
#ifndef _ALPHA_
/* 46 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */
/* 46 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */
#else
NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */
NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */
#endif
/* 48 */ NdrFcShort( 0x2c ), /* Type Offset=44 */
/* 48 */ NdrFcShort( 0x2c ), /* Type Offset=44 */
/* Return value */
/* Return value */
/* Return value */
/* Return value */
/* Return value */
/* Return value */
/* 50 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 50 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
#ifndef _ALPHA_
/* 52 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */
/* 52 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */
#else
NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */
#endif
/* 54 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* 54 */ 0x8, /* FC_LONG */
0x0, /* 0 */
0x0
0x0
}
};
@@ -464,48 +464,48 @@ static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
{
0,
{
NdrFcShort( 0x0 ), /* 0 */
/* 2 */
0x11, 0x4, /* FC_RP [alloced_on_stack] */
/* 4 */ NdrFcShort( 0x1a ), /* Offset= 26 (30) */
/* 6 */
0x13, 0x0, /* FC_OP */
/* 8 */ NdrFcShort( 0xc ), /* Offset= 12 (20) */
/* 10 */
0x1b, /* FC_CARRAY */
0x1, /* 1 */
/* 12 */ NdrFcShort( 0x2 ), /* 2 */
/* 14 */ 0x9, /* Corr desc: FC_ULONG */
0x0, /* */
/* 16 */ NdrFcShort( 0xfffc ), /* -4 */
/* 18 */ 0x6, /* FC_SHORT */
0x5b, /* FC_END */
/* 20 */
0x17, /* FC_CSTRUCT */
0x3, /* 3 */
/* 22 */ NdrFcShort( 0x8 ), /* 8 */
/* 24 */ NdrFcShort( 0xfffffff2 ), /* Offset= -14 (10) */
/* 26 */ 0x8, /* FC_LONG */
0x8, /* FC_LONG */
/* 28 */ 0x5c, /* FC_PAD */
0x5b, /* FC_END */
/* 30 */ 0xb4, /* FC_USER_MARSHAL */
0x83, /* 131 */
/* 32 */ NdrFcShort( 0x0 ), /* 0 */
/* 34 */ NdrFcShort( 0x4 ), /* 4 */
/* 36 */ NdrFcShort( 0x0 ), /* 0 */
/* 38 */ NdrFcShort( 0xffffffe0 ), /* Offset= -32 (6) */
/* 40 */
0x12, 0x0, /* FC_UP */
/* 42 */ NdrFcShort( 0xffffffea ), /* Offset= -22 (20) */
/* 44 */ 0xb4, /* FC_USER_MARSHAL */
0x83, /* 131 */
/* 46 */ NdrFcShort( 0x0 ), /* 0 */
/* 48 */ NdrFcShort( 0x4 ), /* 4 */
/* 50 */ NdrFcShort( 0x0 ), /* 0 */
/* 52 */ NdrFcShort( 0xfffffff4 ), /* Offset= -12 (40) */
NdrFcShort( 0x0 ), /* 0 */
/* 2 */
0x11, 0x4, /* FC_RP [alloced_on_stack] */
/* 4 */ NdrFcShort( 0x1a ), /* Offset= 26 (30) */
/* 6 */
0x13, 0x0, /* FC_OP */
/* 8 */ NdrFcShort( 0xc ), /* Offset= 12 (20) */
/* 10 */
0x1b, /* FC_CARRAY */
0x1, /* 1 */
/* 12 */ NdrFcShort( 0x2 ), /* 2 */
/* 14 */ 0x9, /* Corr desc: FC_ULONG */
0x0, /* */
/* 16 */ NdrFcShort( 0xfffc ), /* -4 */
/* 18 */ 0x6, /* FC_SHORT */
0x5b, /* FC_END */
/* 20 */
0x17, /* FC_CSTRUCT */
0x3, /* 3 */
/* 22 */ NdrFcShort( 0x8 ), /* 8 */
/* 24 */ NdrFcShort( 0xfffffff2 ), /* Offset= -14 (10) */
/* 26 */ 0x8, /* FC_LONG */
0x8, /* FC_LONG */
/* 28 */ 0x5c, /* FC_PAD */
0x5b, /* FC_END */
/* 30 */ 0xb4, /* FC_USER_MARSHAL */
0x83, /* 131 */
/* 32 */ NdrFcShort( 0x0 ), /* 0 */
/* 34 */ NdrFcShort( 0x4 ), /* 4 */
/* 36 */ NdrFcShort( 0x0 ), /* 0 */
/* 38 */ NdrFcShort( 0xffffffe0 ), /* Offset= -32 (6) */
/* 40 */
0x12, 0x0, /* FC_UP */
/* 42 */ NdrFcShort( 0xffffffea ), /* Offset= -22 (20) */
/* 44 */ 0xb4, /* FC_USER_MARSHAL */
0x83, /* 131 */
/* 46 */ NdrFcShort( 0x0 ), /* 0 */
/* 48 */ NdrFcShort( 0x4 ), /* 4 */
/* 50 */ NdrFcShort( 0x0 ), /* 0 */
/* 52 */ NdrFcShort( 0xfffffff4 ), /* Offset= -12 (40) */
0x0
0x0
}
};
@@ -542,7 +542,7 @@ const IID * _MultiFace_BaseIIDList[] =
};
#define _MultiFace_CHECK_IID(n) IID_GENERIC_CHECK_IID( _MultiFace, pIID, n)
#define _MultiFace_CHECK_IID(n) IID_GENERIC_CHECK_IID( _MultiFace, pIID, n)
int __stdcall _MultiFace_IID_Lookup( const IID * pIID, int * pIndex )
{

View File

@@ -6,41 +6,41 @@ import com.jacob.com.Variant;
class MultiFaceTest {
/**
* standard main() test program
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
// this method has been deprecated as being unreliable.
// shutdown should be done through other means
// whoever wrote this example should explain what this was intended to
// do
// System.runFinalizersOnExit(true);
/**
* standard main() test program
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
// this method has been deprecated as being unreliable.
// shutdown should be done through other means
// whoever wrote this example should explain what this was intended to
// do
// System.runFinalizersOnExit(true);
ActiveXComponent mf = new ActiveXComponent("MultiFace.Face");
try {
// I am now dealing with the default interface (IFace1)
Dispatch.put(mf, "Face1Name", new Variant("Hello Face1"));
System.out.println(Dispatch.get(mf, "Face1Name"));
ActiveXComponent mf = new ActiveXComponent("MultiFace.Face");
try {
// I am now dealing with the default interface (IFace1)
Dispatch.put(mf, "Face1Name", new Variant("Hello Face1"));
System.out.println(Dispatch.get(mf, "Face1Name"));
// get to IFace2 through the IID
Dispatch f2 = mf
.QueryInterface("{9BF24410-B2E0-11D4-A695-00104BFF3241}");
// I am now dealing with IFace2
Dispatch.put(f2, "Face2Nam", new Variant("Hello Face2"));
System.out.println(Dispatch.get(f2, "Face2Nam"));
// get to IFace2 through the IID
Dispatch f2 = mf
.QueryInterface("{9BF24410-B2E0-11D4-A695-00104BFF3241}");
// I am now dealing with IFace2
Dispatch.put(f2, "Face2Nam", new Variant("Hello Face2"));
System.out.println(Dispatch.get(f2, "Face2Nam"));
// get to IFace3 through the IID
Dispatch f3 = mf
.QueryInterface("{9BF24411-B2E0-11D4-A695-00104BFF3241}");
// I am now dealing with IFace3
Dispatch.put(f3, "Face3Name", new Variant("Hello Face3"));
System.out.println(Dispatch.get(f3, "Face3Name"));
// get to IFace3 through the IID
Dispatch f3 = mf
.QueryInterface("{9BF24411-B2E0-11D4-A695-00104BFF3241}");
// I am now dealing with IFace3
Dispatch.put(f3, "Face3Name", new Variant("Hello Face3"));
System.out.println(Dispatch.get(f3, "Face3Name"));
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -14,39 +14,39 @@ import com.jacob.com.Variant;
*/
public class ExcelDispatchTest {
/**
* main run loop for test program
*
* @param args
* standard command line arguments
*/
public static void main(String[] args) {
ComThread.InitSTA();
/**
* main run loop for test program
*
* @param args
* standard command line arguments
*/
public static void main(String[] args) {
ComThread.InitSTA();
ActiveXComponent xl = new ActiveXComponent("Excel.Application");
try {
System.out.println("version=" + xl.getProperty("Version"));
System.out.println("version=" + Dispatch.get(xl, "Version"));
Dispatch.put(xl, "Visible", new Variant(true));
Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch();
Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A1" }, new int[1]).toDispatch();
Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A2" }, new int[1]).toDispatch();
Dispatch.put(a1, "Value", "123.456");
Dispatch.put(a2, "Formula", "=A1*2");
System.out.println("a1 from excel:" + Dispatch.get(a1, "Value"));
System.out.println("a2 from excel:" + Dispatch.get(a2, "Value"));
Variant f = new Variant(false);
Dispatch.call(workbook, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
xl.invoke("Quit", new Variant[] {});
ComThread.Release();
}
}
ActiveXComponent xl = new ActiveXComponent("Excel.Application");
try {
System.out.println("version=" + xl.getProperty("Version"));
System.out.println("version=" + Dispatch.get(xl, "Version"));
Dispatch.put(xl, "Visible", new Variant(true));
Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch();
Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A1" }, new int[1]).toDispatch();
Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
new Object[] { "A2" }, new int[1]).toDispatch();
Dispatch.put(a1, "Value", "123.456");
Dispatch.put(a2, "Formula", "=A1*2");
System.out.println("a1 from excel:" + Dispatch.get(a1, "Value"));
System.out.println("a2 from excel:" + Dispatch.get(a2, "Value"));
Variant f = new Variant(false);
Dispatch.call(workbook, "Close", f);
} catch (Exception e) {
e.printStackTrace();
} finally {
xl.invoke("Quit", new Variant[] {});
ComThread.Release();
}
}
}

View File

@@ -14,35 +14,35 @@ import com.jacob.com.Dispatch;
*/
public class VisioPrintTest {
/**
* Runs the print ant lets the user say ok or cancel. Note the funky Visio
* behavior if someone hits the cancel button
*
*/
public void testPrintDialog() {
ActiveXComponent oActiveX = new ActiveXComponent("Visio.Application");
Dispatch oDocuments = oActiveX.getProperty("Documents").toDispatch();
// create a blank document
Dispatch.call(oDocuments, "Add", "");
try {
Dispatch.call(oActiveX, "DoCmd", new Integer(1010)).getInt();
System.out.println("User hit the ok button.");
} catch (ComFailException e) {
System.out.println("User hit the cancel button: " + e);
} finally {
oActiveX.invoke("Quit");
}
return;
}
/**
* Runs the print ant lets the user say ok or cancel. Note the funky Visio
* behavior if someone hits the cancel button
*
*/
public void testPrintDialog() {
ActiveXComponent oActiveX = new ActiveXComponent("Visio.Application");
Dispatch oDocuments = oActiveX.getProperty("Documents").toDispatch();
// create a blank document
Dispatch.call(oDocuments, "Add", "");
try {
Dispatch.call(oActiveX, "DoCmd", new Integer(1010)).getInt();
System.out.println("User hit the ok button.");
} catch (ComFailException e) {
System.out.println("User hit the cancel button: " + e);
} finally {
oActiveX.invoke("Quit");
}
return;
}
/**
* quick main() to test this
*
* @param args
* standard command line arguments
*/
public static void main(String[] args) {
VisioPrintTest testObject = new VisioPrintTest();
testObject.testPrintDialog();
}
/**
* quick main() to test this
*
* @param args
* standard command line arguments
*/
public static void main(String[] args) {
VisioPrintTest testObject = new VisioPrintTest();
testObject.testPrintDialog();
}
}

View File

@@ -18,154 +18,154 @@ import com.jacob.com.Variant;
* are sections that could be enhanced
*/
public class WordDocumentProperties {
// Declare word object
private ActiveXComponent objWord;
// Declare word object
private ActiveXComponent objWord;
// Declare Word Properties
private Dispatch custDocprops;
// Declare Word Properties
private Dispatch custDocprops;
private Dispatch builtInDocProps;
private Dispatch builtInDocProps;
// the doucments object is important in any real app but this demo doesn't
// use it
// private Dispatch documents;
// the doucments object is important in any real app but this demo doesn't
// use it
// private Dispatch documents;
private Dispatch document;
private Dispatch document;
private Dispatch wordObject;
private Dispatch wordObject;
/**
* Empty Constructor
*
*/
public WordDocumentProperties() {
}
/**
* Empty Constructor
*
*/
public WordDocumentProperties() {
}
/**
* Opens a document
*
* @param filename
*/
public void open(String filename) {
// Instantiate objWord
objWord = new ActiveXComponent("Word.Application");
/**
* Opens a document
*
* @param filename
*/
public void open(String filename) {
// Instantiate objWord
objWord = new ActiveXComponent("Word.Application");
// Assign a local word object
wordObject = objWord.getObject();
// Assign a local word object
wordObject = objWord.getObject();
// Create a Dispatch Parameter to hide the document that is opened
Dispatch.put(wordObject, "Visible", new Variant(false));
// Create a Dispatch Parameter to hide the document that is opened
Dispatch.put(wordObject, "Visible", new Variant(false));
// Instantiate the Documents Property
Dispatch documents = objWord.getProperty("Documents").toDispatch();
// Instantiate the Documents Property
Dispatch documents = objWord.getProperty("Documents").toDispatch();
// Open a word document, Current Active Document
document = Dispatch.call(documents, "Open", filename).toDispatch();
}
// Open a word document, Current Active Document
document = Dispatch.call(documents, "Open", filename).toDispatch();
}
/**
* Creates an instance of the VBA CustomDocumentProperties property
*
*/
public void selectCustomDocumentProperitiesMode() {
// Create CustomDocumentProperties and BuiltInDocumentProperties
// properties
custDocprops = Dispatch.get(document, "CustomDocumentProperties")
.toDispatch();
}
/**
* Creates an instance of the VBA CustomDocumentProperties property
*
*/
public void selectCustomDocumentProperitiesMode() {
// Create CustomDocumentProperties and BuiltInDocumentProperties
// properties
custDocprops = Dispatch.get(document, "CustomDocumentProperties")
.toDispatch();
}
/**
* Creates an instance of the VBA BuiltInDocumentProperties property
*
*/
public void selectBuiltinPropertiesMode() {
// Create CustomDocumentProperties and BuiltInDocumentProperties
// properties
builtInDocProps = Dispatch.get(document, "BuiltInDocumentProperties")
.toDispatch();
}
/**
* Creates an instance of the VBA BuiltInDocumentProperties property
*
*/
public void selectBuiltinPropertiesMode() {
// Create CustomDocumentProperties and BuiltInDocumentProperties
// properties
builtInDocProps = Dispatch.get(document, "BuiltInDocumentProperties")
.toDispatch();
}
/**
* Closes a document
*
*/
public void close() {
// Close object
Dispatch.call(document, "Close");
}
/**
* Closes a document
*
*/
public void close() {
// Close object
Dispatch.call(document, "Close");
}
/**
* Custom Property Name is passed in
*
* @param cusPropName
* @return String - Custom property value
*/
public String getCustomProperty(String cusPropName) {
try {
cusPropName = Dispatch.call(custDocprops, "Item", cusPropName)
.toString();
} catch (ComException e) {
// Do nothing
cusPropName = null;
}
/**
* Custom Property Name is passed in
*
* @param cusPropName
* @return String - Custom property value
*/
public String getCustomProperty(String cusPropName) {
try {
cusPropName = Dispatch.call(custDocprops, "Item", cusPropName)
.toString();
} catch (ComException e) {
// Do nothing
cusPropName = null;
}
return cusPropName;
}
return cusPropName;
}
/**
* Built In Property Name is passed in
*
* @param builtInPropName
* @return String - Built in property value
*/
public String getBuiltInProperty(String builtInPropName) {
try {
builtInPropName = Dispatch.call(builtInDocProps, "Item",
builtInPropName).toString();
} catch (ComException e) {
// Do nothing
builtInPropName = null;
}
/**
* Built In Property Name is passed in
*
* @param builtInPropName
* @return String - Built in property value
*/
public String getBuiltInProperty(String builtInPropName) {
try {
builtInPropName = Dispatch.call(builtInDocProps, "Item",
builtInPropName).toString();
} catch (ComException e) {
// Do nothing
builtInPropName = null;
}
return builtInPropName;
}
return builtInPropName;
}
/**
* simple main program that gets some properties and prints them out
*
* @param args
*/
public static void main(String[] args) {
try {
// Instantiate the class
WordDocumentProperties jacTest = new WordDocumentProperties();
/**
* simple main program that gets some properties and prints them out
*
* @param args
*/
public static void main(String[] args) {
try {
// Instantiate the class
WordDocumentProperties jacTest = new WordDocumentProperties();
// Open the word doc
File doc = new File(
"samples/com/jacob/samples/office/TestDocument.doc");
jacTest.open(doc.getAbsolutePath());
// Open the word doc
File doc = new File(
"samples/com/jacob/samples/office/TestDocument.doc");
jacTest.open(doc.getAbsolutePath());
// Set Custom Properties
jacTest.selectCustomDocumentProperitiesMode();
// Set Custom Properties
jacTest.selectCustomDocumentProperitiesMode();
// Set Built In Properties
jacTest.selectBuiltinPropertiesMode();
// Set Built In Properties
jacTest.selectBuiltinPropertiesMode();
// Get custom Property Value
String custValue = jacTest.getCustomProperty("Information Source");
// Get custom Property Value
String custValue = jacTest.getCustomProperty("Information Source");
// Get built in prroperty Property Value
String builtInValue = jacTest.getBuiltInProperty("Author");
// Get built in prroperty Property Value
String builtInValue = jacTest.getBuiltInProperty("Author");
// Close Word Doc
jacTest.close();
// Close Word Doc
jacTest.close();
// Output data
System.out.println("Document Val One: " + custValue);
System.out.println("Document Author: " + builtInValue);
// Output data
System.out.println("Document Val One: " + custValue);
System.out.println("Document Author: " + builtInValue);
} catch (Exception e) {
System.out.println(e);
}
}
} catch (Exception e) {
System.out.println(e);
}
}
}

View File

@@ -14,67 +14,67 @@ import com.jacob.com.Variant;
*/
public class Outlook {
private static String pad(int i) {
StringBuffer sb = new StringBuffer();
private static String pad(int i) {
StringBuffer sb = new StringBuffer();
while (sb.length() < i) {
sb.append(' ');
}
while (sb.length() < i) {
sb.append(' ');
}
return sb.toString();
}
return sb.toString();
}
private static void recurseFolders(int iIndent, Dispatch o) {
private static void recurseFolders(int iIndent, Dispatch o) {
if (o == null) {
return;
}
Dispatch oFolders = Dispatch.get(o, "Folders").toDispatch();
// System.out.println("oFolders=" + oFolders);
if (oFolders == null) {
return;
}
if (o == null) {
return;
}
Dispatch oFolders = Dispatch.get(o, "Folders").toDispatch();
// System.out.println("oFolders=" + oFolders);
if (oFolders == null) {
return;
}
Dispatch oFolder = Dispatch.get(oFolders, "GetFirst").toDispatch();
do {
Object oFolderName = Dispatch.get(oFolder, "Name");
if (null == oFolderName) {
break;
}
Dispatch oFolder = Dispatch.get(oFolders, "GetFirst").toDispatch();
do {
Object oFolderName = Dispatch.get(oFolder, "Name");
if (null == oFolderName) {
break;
}
System.out.println(pad(iIndent) + oFolderName);
recurseFolders(iIndent + 3, oFolder);
System.out.println(pad(iIndent) + oFolderName);
recurseFolders(iIndent + 3, oFolder);
oFolder = Dispatch.get(oFolders, "GetNext").toDispatch();
} while (true);
oFolder = Dispatch.get(oFolders, "GetNext").toDispatch();
} while (true);
}
}
/**
* standard run loop
*
* @param asArgs
* command line arguments
* @throws Exception
*/
public static void main(String asArgs[]) throws Exception {
System.out.println("Outlook: IN");
/**
* standard run loop
*
* @param asArgs
* command line arguments
* @throws Exception
*/
public static void main(String asArgs[]) throws Exception {
System.out.println("Outlook: IN");
ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application");
try {
System.out.println("version=" + axOutlook.getProperty("Version"));
ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application");
try {
System.out.println("version=" + axOutlook.getProperty("Version"));
Dispatch oOutlook = axOutlook.getObject();
System.out.println("version=" + Dispatch.get(oOutlook, "Version"));
Dispatch oOutlook = axOutlook.getObject();
System.out.println("version=" + Dispatch.get(oOutlook, "Version"));
Dispatch oNameSpace = axOutlook.getProperty("Session").toDispatch();
System.out.println("oNameSpace=" + oNameSpace);
Dispatch oNameSpace = axOutlook.getProperty("Session").toDispatch();
System.out.println("oNameSpace=" + oNameSpace);
recurseFolders(0, oNameSpace);
recurseFolders(0, oNameSpace);
} finally {
axOutlook.invoke("Quit", new Variant[] {});
}
}
} finally {
axOutlook.invoke("Quit", new Variant[] {});
}
}
}

View File

@@ -21,132 +21,132 @@ import com.jacob.com.Variant;
*/
public class DiskUtils {
/** formatters aren't thread safe but the sample only has one thread */
private static DecimalFormat sizeFormatter = new DecimalFormat(
"###,###,###,###");
/** formatters aren't thread safe but the sample only has one thread */
private static DecimalFormat sizeFormatter = new DecimalFormat(
"###,###,###,###");
/** a pointer to the scripting file system object */
private ActiveXComponent fileSystemApp = null;
/** a pointer to the scripting file system object */
private ActiveXComponent fileSystemApp = null;
/** the dispatch that points at the drive this DiskUtil operates against */
private Dispatch myDrive = null;
/** the dispatch that points at the drive this DiskUtil operates against */
private Dispatch myDrive = null;
/**
* Standard constructor
*
* @param drive
* the drive to run the test against.
*/
public DiskUtils(String drive) {
setUp(drive);
}
/**
* Standard constructor
*
* @param drive
* the drive to run the test against.
*/
public DiskUtils(String drive) {
setUp(drive);
}
/**
* open the connection to the scripting object
*
* @param drive
* the drive to run the test against
*/
public void setUp(String drive) {
if (fileSystemApp == null) {
ComThread.InitSTA();
fileSystemApp = new ActiveXComponent("Scripting.FileSystemObject");
myDrive = Dispatch.call(fileSystemApp, "GetDrive", drive)
.toDispatch();
}
}
/**
* open the connection to the scripting object
*
* @param drive
* the drive to run the test against
*/
public void setUp(String drive) {
if (fileSystemApp == null) {
ComThread.InitSTA();
fileSystemApp = new ActiveXComponent("Scripting.FileSystemObject");
myDrive = Dispatch.call(fileSystemApp, "GetDrive", drive)
.toDispatch();
}
}
/**
* Do any needed cleanup
*/
public void tearDown() {
ComThread.Release();
}
/**
* Do any needed cleanup
*/
public void tearDown() {
ComThread.Release();
}
/**
* convenience method
*
* @return driver serial number
*/
public int getSerialNumber() {
return Dispatch.get(myDrive, "SerialNumber").getInt();
}
/**
* convenience method
*
* @return driver serial number
*/
public int getSerialNumber() {
return Dispatch.get(myDrive, "SerialNumber").getInt();
}
/**
* Convenience method. We go through these formatting hoops so we can make
* the size string pretty. We wouldn't have to do that if we didn't mind
* long strings with Exxx at the end or the fact that the value returned can
* vary in size based on the size of the disk.
*
* @return driver total size of the disk
*/
public String getTotalSize() {
Variant returnValue = Dispatch.get(myDrive, "TotalSize");
if (returnValue.getvt() == Variant.VariantDouble) {
return sizeFormatter.format(returnValue.getDouble());
} else if (returnValue.getvt() == Variant.VariantInt) {
return sizeFormatter.format(returnValue.getInt());
} else {
return "Don't know type: " + returnValue.getvt();
}
}
/**
* Convenience method. We go through these formatting hoops so we can make
* the size string pretty. We wouldn't have to do that if we didn't mind
* long strings with Exxx at the end or the fact that the value returned can
* vary in size based on the size of the disk.
*
* @return driver total size of the disk
*/
public String getTotalSize() {
Variant returnValue = Dispatch.get(myDrive, "TotalSize");
if (returnValue.getvt() == Variant.VariantDouble) {
return sizeFormatter.format(returnValue.getDouble());
} else if (returnValue.getvt() == Variant.VariantInt) {
return sizeFormatter.format(returnValue.getInt());
} else {
return "Don't know type: " + returnValue.getvt();
}
}
/**
* Convenience method. We wouldn't have to do that if we didn't mind long
* strings with Exxx at the end or the fact that the value returned can vary
* in size based on the size of the disk.
*
* @return driver free size of the disk
*/
public String getFreeSpace() {
Variant returnValue = Dispatch.get(myDrive, "FreeSpace");
if (returnValue.getvt() == Variant.VariantDouble) {
return sizeFormatter.format(returnValue.getDouble());
} else if (returnValue.getvt() == Variant.VariantInt) {
return sizeFormatter.format(returnValue.getInt());
} else {
return "Don't know type: " + returnValue.getvt();
}
}
/**
* Convenience method. We wouldn't have to do that if we didn't mind long
* strings with Exxx at the end or the fact that the value returned can vary
* in size based on the size of the disk.
*
* @return driver free size of the disk
*/
public String getFreeSpace() {
Variant returnValue = Dispatch.get(myDrive, "FreeSpace");
if (returnValue.getvt() == Variant.VariantDouble) {
return sizeFormatter.format(returnValue.getDouble());
} else if (returnValue.getvt() == Variant.VariantInt) {
return sizeFormatter.format(returnValue.getInt());
} else {
return "Don't know type: " + returnValue.getvt();
}
}
/**
*
* @return file system on the drive
*/
public String getFileSystemType() {
// figure ot the actual variant type
// Variant returnValue = Dispatch.get(myDrive, "FileSystem");
// System.out.println(returnValue.getvt());
return Dispatch.get(myDrive, "FileSystem").getString();
}
/**
*
* @return file system on the drive
*/
public String getFileSystemType() {
// figure ot the actual variant type
// Variant returnValue = Dispatch.get(myDrive, "FileSystem");
// System.out.println(returnValue.getvt());
return Dispatch.get(myDrive, "FileSystem").getString();
}
/**
*
* @return volume name
*/
public String getVolumeName() {
return Dispatch.get(myDrive, "VolumeName").getString();
}
/**
*
* @return volume name
*/
public String getVolumeName() {
return Dispatch.get(myDrive, "VolumeName").getString();
}
/**
* Simple main program that creates a DiskUtils object and queries for the
* C: drive
*
* @param args
* standard command line arguments
*/
public static void main(String[] args) {
// DiskUtils utilConnection = new DiskUtils("F");
DiskUtils utilConnection = new DiskUtils("C");
System.out.println("Disk serial number is: "
+ utilConnection.getSerialNumber());
System.out.println("FileSystem is: "
+ utilConnection.getFileSystemType());
System.out.println("Volume Name is: " + utilConnection.getVolumeName());
System.out.println("Disk total size is: "
+ utilConnection.getTotalSize());
System.out.println("Disk free space is: "
+ utilConnection.getFreeSpace());
utilConnection.tearDown();
}
/**
* Simple main program that creates a DiskUtils object and queries for the
* C: drive
*
* @param args
* standard command line arguments
*/
public static void main(String[] args) {
// DiskUtils utilConnection = new DiskUtils("F");
DiskUtils utilConnection = new DiskUtils("C");
System.out.println("Disk serial number is: "
+ utilConnection.getSerialNumber());
System.out.println("FileSystem is: "
+ utilConnection.getFileSystemType());
System.out.println("Volume Name is: " + utilConnection.getVolumeName());
System.out.println("Disk total size is: "
+ utilConnection.getTotalSize());
System.out.println("Disk free space is: "
+ utilConnection.getFreeSpace());
utilConnection.tearDown();
}
}

View File

@@ -17,59 +17,59 @@ import com.jacob.com.Variant;
*/
public class SystemMonitor {
/**
* example run loop method called by main()
*/
public void runMonitor() {
/**
* example run loop method called by main()
*/
public void runMonitor() {
ActiveXComponent wmi = null;
wmi = new ActiveXComponent("WbemScripting.SWbemLocator");
// no connection parameters means to connect to the local machine
Variant conRet = wmi.invoke("ConnectServer");
// the author liked the ActiveXComponent api style over the Dispatch
// style
ActiveXComponent wmiconnect = new ActiveXComponent(conRet.toDispatch());
ActiveXComponent wmi = null;
wmi = new ActiveXComponent("WbemScripting.SWbemLocator");
// no connection parameters means to connect to the local machine
Variant conRet = wmi.invoke("ConnectServer");
// the author liked the ActiveXComponent api style over the Dispatch
// style
ActiveXComponent wmiconnect = new ActiveXComponent(conRet.toDispatch());
// the WMI supports a query language.
String query = "select CategoryString, Message, TimeGenerated, User, Type "
+ "from Win32_NtLogEvent "
+ "where Logfile = 'Application' and TimeGenerated > '20070915000000.000000-***'";
Variant vCollection = wmiconnect
.invoke("ExecQuery", new Variant(query));
// the WMI supports a query language.
String query = "select CategoryString, Message, TimeGenerated, User, Type "
+ "from Win32_NtLogEvent "
+ "where Logfile = 'Application' and TimeGenerated > '20070915000000.000000-***'";
Variant vCollection = wmiconnect
.invoke("ExecQuery", new Variant(query));
EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch());
EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch());
String resultString = "";
Dispatch item = null;
String resultString = "";
Dispatch item = null;
while (enumVariant.hasMoreElements()) {
resultString = "";
item = enumVariant.nextElement().toDispatch();
String categoryString = Dispatch.call(item, "CategoryString")
.toString();
String messageString = Dispatch.call(item, "Message").toString();
String timeGenerated = Dispatch.call(item, "TimeGenerated")
.toString();
String eventUser = Dispatch.call(item, "User").toString();
String eventType = Dispatch.call(item, "Type").toString();
resultString += "TimeGenerated: " + timeGenerated + " Category: "
+ categoryString + " User: " + eventUser + " EventType: "
+ eventType + " Message:" + messageString;
System.out.println(resultString);
while (enumVariant.hasMoreElements()) {
resultString = "";
item = enumVariant.nextElement().toDispatch();
String categoryString = Dispatch.call(item, "CategoryString")
.toString();
String messageString = Dispatch.call(item, "Message").toString();
String timeGenerated = Dispatch.call(item, "TimeGenerated")
.toString();
String eventUser = Dispatch.call(item, "User").toString();
String eventType = Dispatch.call(item, "Type").toString();
resultString += "TimeGenerated: " + timeGenerated + " Category: "
+ categoryString + " User: " + eventUser + " EventType: "
+ eventType + " Message:" + messageString;
System.out.println(resultString);
}
}
}
}
/**
* sample's main program
*
* @param args
* command line arguments
*/
public static void main(String[] args) {
SystemMonitor utilConnection = new SystemMonitor();
utilConnection.runMonitor();
}
/**
* sample's main program
*
* @param args
* command line arguments
*/
public static void main(String[] args) {
SystemMonitor utilConnection = new SystemMonitor();
utilConnection.runMonitor();
}
}

View File

@@ -16,106 +16,106 @@ import com.jacob.com.Variant;
*/
public class VisioApp extends ActiveXComponent {
/**
* constructor that spins up Visio
*
* @throws VisioException
*/
public VisioApp() throws VisioException {
super("Visio.Application");
setVisible(false);
}
/**
* constructor that spins up Visio
*
* @throws VisioException
*/
public VisioApp() throws VisioException {
super("Visio.Application");
setVisible(false);
}
/**
* creates a DispatchEvents object to register o as a listener
*
* @param o
*/
public void addEventListener(VisioEventListener o) {
DispatchEvents events = new DispatchEvents(this, o);
if (events == null) {
System.out
.println("You should never get null back when creating a DispatchEvents object");
}
}
/**
* creates a DispatchEvents object to register o as a listener
*
* @param o
*/
public void addEventListener(VisioEventListener o) {
DispatchEvents events = new DispatchEvents(this, o);
if (events == null) {
System.out
.println("You should never get null back when creating a DispatchEvents object");
}
}
/**
* opens the passed in file in Visio
*
* @param f
* @throws VisioException
*/
public void open(File f) throws VisioException {
try {
ActiveXComponent documents = new ActiveXComponent(getProperty(
"Documents").toDispatch());
Variant[] args = new Variant[1];
args[0] = new Variant(f.getPath());
documents.invoke("Open", args);
} catch (Exception e) {
e.printStackTrace();
throw new VisioException(e);
}
}
/**
* opens the passed in file in Visio
*
* @param f
* @throws VisioException
*/
public void open(File f) throws VisioException {
try {
ActiveXComponent documents = new ActiveXComponent(getProperty(
"Documents").toDispatch());
Variant[] args = new Variant[1];
args[0] = new Variant(f.getPath());
documents.invoke("Open", args);
} catch (Exception e) {
e.printStackTrace();
throw new VisioException(e);
}
}
/**
* tells Visio to save the drawing
*
* @throws VisioException
*/
public void save() throws VisioException {
try {
ActiveXComponent document = new ActiveXComponent(getProperty(
"ActiveDocument").toDispatch());
document.invoke("Save");
} catch (Exception e) {
e.printStackTrace();
throw new VisioException(e);
}
}
/**
* tells Visio to save the drawing
*
* @throws VisioException
*/
public void save() throws VisioException {
try {
ActiveXComponent document = new ActiveXComponent(getProperty(
"ActiveDocument").toDispatch());
document.invoke("Save");
} catch (Exception e) {
e.printStackTrace();
throw new VisioException(e);
}
}
/**
* terminates Visio
*/
public void quit() {
System.out.println("Received quit()");
// there can't be any open documents for this to work
// you'll get a visio error if you don't close them
ActiveXComponent document = new ActiveXComponent(getProperty(
"ActiveDocument").toDispatch());
document.invoke("Close");
invoke("Quit");
}
/**
* terminates Visio
*/
public void quit() {
System.out.println("Received quit()");
// there can't be any open documents for this to work
// you'll get a visio error if you don't close them
ActiveXComponent document = new ActiveXComponent(getProperty(
"ActiveDocument").toDispatch());
document.invoke("Close");
invoke("Quit");
}
/**
* runs the Visio export command
*
* @param f
* @throws VisioException
*/
public void export(File f) throws VisioException {
try {
ActiveXComponent document = new ActiveXComponent(getProperty(
"ActivePage").toDispatch());
Variant[] args = new Variant[1];
args[0] = new Variant(f.getPath());
document.invoke("Export", args);
} catch (Exception e) {
throw new VisioException(e);
}
}
/**
* runs the Visio export command
*
* @param f
* @throws VisioException
*/
public void export(File f) throws VisioException {
try {
ActiveXComponent document = new ActiveXComponent(getProperty(
"ActivePage").toDispatch());
Variant[] args = new Variant[1];
args[0] = new Variant(f.getPath());
document.invoke("Export", args);
} catch (Exception e) {
throw new VisioException(e);
}
}
/**
* makes Visio visible so the user can watch
*
* @param b
* @throws VisioException
*/
public void setVisible(boolean b) throws VisioException {
try {
setProperty("Visible", new Variant(b));
} catch (Exception e) {
throw new VisioException(e);
}
}
/**
* makes Visio visible so the user can watch
*
* @param b
* @throws VisioException
*/
public void setVisible(boolean b) throws VisioException {
try {
setProperty("Visible", new Variant(b));
} catch (Exception e) {
throw new VisioException(e);
}
}
}

View File

@@ -22,159 +22,159 @@ import java.io.OutputStream;
*/
public class VisioAppFacade {
private VisioApp app;
private static VisioAppFacade instance;
private VisioApp app;
private static VisioAppFacade instance;
/** extension for image files */
public static final String IMAGE_EXT = ".jpg";
/** extension for visio files */
public static final String VISIO_EXT = ".vsd";
/** the buffer size when we want to read stuff in */
public static final int BUFFER_SIZE = 2048;
/** extension for image files */
public static final String IMAGE_EXT = ".jpg";
/** extension for visio files */
public static final String VISIO_EXT = ".vsd";
/** the buffer size when we want to read stuff in */
public static final int BUFFER_SIZE = 2048;
/**
* Wrapper around Visio
*
* @throws VisioException
*/
private VisioAppFacade() throws VisioException {
this.app = new VisioApp();
app.addEventListener(new VisioEventAdapter(app));
}
/**
* Wrapper around Visio
*
* @throws VisioException
*/
private VisioAppFacade() throws VisioException {
this.app = new VisioApp();
app.addEventListener(new VisioEventAdapter(app));
}
/**
* @return the singleton instance of Visio
* @throws VisioException
*/
public static VisioAppFacade getInstance() throws VisioException {
if (instance == null) {
instance = new VisioAppFacade();
}
return instance;
}
/**
* @return the singleton instance of Visio
* @throws VisioException
*/
public static VisioAppFacade getInstance() throws VisioException {
if (instance == null) {
instance = new VisioAppFacade();
}
return instance;
}
/**
* creates a preview in a temp file and returns the raw data.
*
* @param visioData
* @return raw preview data
* @throws VisioException
*/
public byte[] createPreview(byte[] visioData) throws VisioException {
byte[] preview;
File tmpFile;
try {
tmpFile = getTempVisioFile();
OutputStream out = new FileOutputStream(tmpFile);
out.write(visioData);
out.close();
} catch (IOException ioe) {
throw new VisioException(ioe);
}
preview = createPreview(tmpFile);
tmpFile.delete();
return preview;
}
/**
* creates a preview in a temp file and returns the raw data.
*
* @param visioData
* @return raw preview data
* @throws VisioException
*/
public byte[] createPreview(byte[] visioData) throws VisioException {
byte[] preview;
File tmpFile;
try {
tmpFile = getTempVisioFile();
OutputStream out = new FileOutputStream(tmpFile);
out.write(visioData);
out.close();
} catch (IOException ioe) {
throw new VisioException(ioe);
}
preview = createPreview(tmpFile);
tmpFile.delete();
return preview;
}
/**
* reads a preview from a saved file
*
* @param visioFile
* @return raw preview data
* @throws VisioException
*/
public byte[] createPreview(File visioFile) throws VisioException {
try {
File imageFile;
imageFile = getTempImageFile();
app.open(visioFile);
app.export(imageFile);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
FileInputStream fin = new FileInputStream(imageFile);
copy(fin, bout);
fin.close();
imageFile.delete();
bout.close();
return bout.toByteArray();
} catch (IOException ioe) {
throw new VisioException(ioe);
}
}
/**
* reads a preview from a saved file
*
* @param visioFile
* @return raw preview data
* @throws VisioException
*/
public byte[] createPreview(File visioFile) throws VisioException {
try {
File imageFile;
imageFile = getTempImageFile();
app.open(visioFile);
app.export(imageFile);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
FileInputStream fin = new FileInputStream(imageFile);
copy(fin, bout);
fin.close();
imageFile.delete();
bout.close();
return bout.toByteArray();
} catch (IOException ioe) {
throw new VisioException(ioe);
}
}
private void copy(InputStream in, OutputStream out) throws IOException {
byte[] buff = new byte[BUFFER_SIZE];
int read;
do {
read = in.read(buff);
if (read > 0) {
out.write(buff, 0, read);
}
} while (read > 0);
}
private void copy(InputStream in, OutputStream out) throws IOException {
byte[] buff = new byte[BUFFER_SIZE];
int read;
do {
read = in.read(buff);
if (read > 0) {
out.write(buff, 0, read);
}
} while (read > 0);
}
/**
* creates a preview from an input stream
*
* @param in
* @return byte contents of the preview stream
* @throws VisioException
*/
public byte[] createPreview(InputStream in) throws VisioException {
byte[] preview;
// byte[] buff = new byte[2048];
// int read = 0;
OutputStream out;
File tmpFile;
/**
* creates a preview from an input stream
*
* @param in
* @return byte contents of the preview stream
* @throws VisioException
*/
public byte[] createPreview(InputStream in) throws VisioException {
byte[] preview;
// byte[] buff = new byte[2048];
// int read = 0;
OutputStream out;
File tmpFile;
try {
tmpFile = getTempVisioFile();
out = new FileOutputStream(tmpFile);
copy(in, out);
out.close();
} catch (IOException ioe) {
throw new VisioException(ioe);
}
try {
tmpFile = getTempVisioFile();
out = new FileOutputStream(tmpFile);
copy(in, out);
out.close();
} catch (IOException ioe) {
throw new VisioException(ioe);
}
preview = createPreview(tmpFile);
tmpFile.delete();
return preview;
}
preview = createPreview(tmpFile);
tmpFile.delete();
return preview;
}
/**
* opens the file in Visio and makes the editor visible
*
* @param f
* the reference to the Visio file to be opened
* @throws VisioException
*/
public void editDiagram(File f) throws VisioException {
app.open(f);
app.setVisible(true);
}
/**
* opens the file in Visio and makes the editor visible
*
* @param f
* the reference to the Visio file to be opened
* @throws VisioException
*/
public void editDiagram(File f) throws VisioException {
app.open(f);
app.setVisible(true);
}
/**
* creates a temporary viso file
*
* @return created visio temporary file
* @throws IOException
*/
private File getTempVisioFile() throws IOException {
return File.createTempFile("java", VISIO_EXT);
}
/**
* creates a temporary viso file
*
* @return created visio temporary file
* @throws IOException
*/
private File getTempVisioFile() throws IOException {
return File.createTempFile("java", VISIO_EXT);
}
/**
* creates a temporary image file and returns the File object
*
* @return the created image file object
* @throws IOException
*/
private File getTempImageFile() throws IOException {
return File.createTempFile("java", IMAGE_EXT);
}
/**
* creates a temporary image file and returns the File object
*
* @return the created image file object
* @throws IOException
*/
private File getTempImageFile() throws IOException {
return File.createTempFile("java", IMAGE_EXT);
}
/** exit visio */
public void quit() {
app.quit();
instance = null;
}
/** exit visio */
public void quit() {
app.quit();
instance = null;
}
}

View File

@@ -32,166 +32,166 @@ import com.jacob.com.ComThread;
*/
public class VisioDemo extends JFrame implements ActionListener, WindowListener {
/**
* Totally dummy value to make Eclipse quit complaining
*/
private static final long serialVersionUID = 1L;
/**
* Totally dummy value to make Eclipse quit complaining
*/
private static final long serialVersionUID = 1L;
JButton chooseButton;
JButton openButton;
JPanel buttons;
JButton chooseButton;
JButton openButton;
JPanel buttons;
ImageIcon theImage;
JLabel theLabel; // the icon on the page is actually this button's icon
ImageIcon theImage;
JLabel theLabel; // the icon on the page is actually this button's icon
File selectedFile;
/** everyone should get this through getVisio() */
private VisioAppFacade visioProxy = null;
File selectedFile;
/** everyone should get this through getVisio() */
private VisioAppFacade visioProxy = null;
// put this up here so it remembers where we were on the last choose
JFileChooser chooser = null;
// put this up here so it remembers where we were on the last choose
JFileChooser chooser = null;
public class VisioFileFilter extends FileFilter {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
} else {
return (f.getName().toUpperCase().endsWith(".VSD"));
}
}
public class VisioFileFilter extends FileFilter {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
} else {
return (f.getName().toUpperCase().endsWith(".VSD"));
}
}
public String getDescription() {
return "Visio Drawings";
}
}
public String getDescription() {
return "Visio Drawings";
}
}
public VisioDemo() {
super("Visio in Swing POC");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buttons = new JPanel();
getContentPane().setLayout(new BorderLayout());
chooseButton = new JButton("Choose file to display");
openButton = new JButton("Open file chosen file in Visio");
chooseButton.addActionListener(this);
openButton.addActionListener(this);
buttons.add(chooseButton);
buttons.add(openButton);
getContentPane().add(buttons, BorderLayout.SOUTH);
theLabel = new JLabel("");
getContentPane().add(theLabel, BorderLayout.CENTER);
addWindowListener(this);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setSize(640, 480);
this.setVisible(true);
}
public VisioDemo() {
super("Visio in Swing POC");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buttons = new JPanel();
getContentPane().setLayout(new BorderLayout());
chooseButton = new JButton("Choose file to display");
openButton = new JButton("Open file chosen file in Visio");
chooseButton.addActionListener(this);
openButton.addActionListener(this);
buttons.add(chooseButton);
buttons.add(openButton);
getContentPane().add(buttons, BorderLayout.SOUTH);
theLabel = new JLabel("");
getContentPane().add(theLabel, BorderLayout.CENTER);
addWindowListener(this);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setSize(640, 480);
this.setVisible(true);
}
public static void main(String args[]) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ComThread.InitSTA();
VisioDemo poc = new VisioDemo();
ComThread.Release();
if (poc == null) {
System.out.println("poc== null? That should never happen!");
}
}
});
}
public static void main(String args[]) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ComThread.InitSTA();
VisioDemo poc = new VisioDemo();
ComThread.Release();
if (poc == null) {
System.out.println("poc== null? That should never happen!");
}
}
});
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chooseButton) {
pickFile();
} else if (e.getSource() == openButton) {
try {
openFile();
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
} else {
System.out.println("Awesome!");
}
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chooseButton) {
pickFile();
} else if (e.getSource() == openButton) {
try {
openFile();
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
} else {
System.out.println("Awesome!");
}
}
private void pickFile() {
try {
chooser = new JFileChooser();
// comment this out if you want it to always go to myDocuments
chooser
.setCurrentDirectory(new File(System
.getProperty("user.dir")));
chooser.setFileFilter(new VisioFileFilter());
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
selectedFile = chooser.getSelectedFile();
showSelectedFilePreview();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void pickFile() {
try {
chooser = new JFileChooser();
// comment this out if you want it to always go to myDocuments
chooser
.setCurrentDirectory(new File(System
.getProperty("user.dir")));
chooser.setFileFilter(new VisioFileFilter());
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
selectedFile = chooser.getSelectedFile();
showSelectedFilePreview();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* use this private method instead of initializing on boot up so that
* instance and all listeners are created in this thread (event thread)
* rather than root thread
*
* @return
*/
private VisioAppFacade getVisio() {
if (visioProxy == null) {
try {
visioProxy = VisioAppFacade.getInstance();
} catch (VisioException ve) {
System.out.println("ailed to openFile()");
ve.printStackTrace();
}
}
return visioProxy;
}
/**
* use this private method instead of initializing on boot up so that
* instance and all listeners are created in this thread (event thread)
* rather than root thread
*
* @return
*/
private VisioAppFacade getVisio() {
if (visioProxy == null) {
try {
visioProxy = VisioAppFacade.getInstance();
} catch (VisioException ve) {
System.out.println("ailed to openFile()");
ve.printStackTrace();
}
}
return visioProxy;
}
private void showSelectedFilePreview() throws VisioException {
if (selectedFile != null) {
byte[] image = getVisio().createPreview(selectedFile);
theImage = new ImageIcon(image);
theLabel.setIcon(theImage);
}
}
private void showSelectedFilePreview() throws VisioException {
if (selectedFile != null) {
byte[] image = getVisio().createPreview(selectedFile);
theImage = new ImageIcon(image);
theLabel.setIcon(theImage);
}
}
private void openFile() throws VisioException {
try {
getVisio().editDiagram(selectedFile);
showSelectedFilePreview();
} catch (VisioException ve) {
System.out.println("ailed to openFile()");
ve.printStackTrace();
}
private void openFile() throws VisioException {
try {
getVisio().editDiagram(selectedFile);
showSelectedFilePreview();
} catch (VisioException ve) {
System.out.println("ailed to openFile()");
ve.printStackTrace();
}
}
}
public void windowActivated(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
System.out.println("WINDOW CLOSED");
if (visioProxy != null) {
visioProxy.quit();
}
}
public void windowClosed(WindowEvent e) {
System.out.println("WINDOW CLOSED");
if (visioProxy != null) {
visioProxy.quit();
}
}
public void windowClosing(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
System.out.println("Fooboo");
}
public void windowIconified(WindowEvent e) {
System.out.println("Fooboo");
}
public void windowOpened(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
}

View File

@@ -13,56 +13,56 @@ import com.jacob.com.Variant;
*/
public class VisioEventAdapter implements VisioEventListener {
VisioApp app = null;
VisioApp app = null;
public VisioEventAdapter(VisioApp pApp) {
app = pApp;
System.out.println("Event listener constructed");
}
public VisioEventAdapter(VisioApp pApp) {
app = pApp;
System.out.println("Event listener constructed");
}
public void BeforeQuit(Variant[] args) {
}
public void BeforeQuit(Variant[] args) {
}
public void DocumentChanged(Variant[] args) {
System.out.println("documentChanged()");
}
public void DocumentChanged(Variant[] args) {
System.out.println("documentChanged()");
}
public void DocumentCloseCanceled(Variant[] args) {
}
public void DocumentCloseCanceled(Variant[] args) {
}
public void DocumentCreated(Variant[] args) {
}
public void DocumentCreated(Variant[] args) {
}
public void DocumentOpened(Variant[] args) {
System.out.println("DocumentOpened()");
}
public void DocumentOpened(Variant[] args) {
System.out.println("DocumentOpened()");
}
public void DocumentSaved(Variant[] args) {
}
public void DocumentSaved(Variant[] args) {
}
public void DocumentSavedAs(Variant[] args) {
}
public void DocumentSavedAs(Variant[] args) {
}
public Variant QueryCancelDocumentClose(Variant[] args) {
System.out.println("QueryCancelDocumentClose()");
return new Variant(false);
}
public Variant QueryCancelDocumentClose(Variant[] args) {
System.out.println("QueryCancelDocumentClose()");
return new Variant(false);
}
/**
* we don't actually let it quit. We block it so that we don't have to
* relaunch when we look at a new document
*/
public Variant QueryCancelQuit(Variant[] args) {
// these may throw VisioException
System.out
.println("Saving document, hiding and telling visio not to quit");
try {
app.save();
app.setVisible(false);
} catch (VisioException ve) {
System.out.println("ailed to openFile()");
ve.printStackTrace();
}
return new Variant(true);
}
/**
* we don't actually let it quit. We block it so that we don't have to
* relaunch when we look at a new document
*/
public Variant QueryCancelQuit(Variant[] args) {
// these may throw VisioException
System.out
.println("Saving document, hiding and telling visio not to quit");
try {
app.save();
app.setVisible(false);
} catch (VisioException ve) {
System.out.println("ailed to openFile()");
ve.printStackTrace();
}
return new Variant(true);
}
}

View File

@@ -15,19 +15,19 @@ import com.jacob.com.Variant;
*/
public interface VisioEventListener {
public void BeforeQuit(Variant[] args);
public void BeforeQuit(Variant[] args);
public void DocumentChanged(Variant[] args);
public void DocumentChanged(Variant[] args);
public void DocumentCloseCanceled(Variant[] args);
public void DocumentCloseCanceled(Variant[] args);
public void DocumentCreated(Variant[] args);
public void DocumentCreated(Variant[] args);
public void DocumentOpened(Variant[] args);
public void DocumentOpened(Variant[] args);
public void DocumentSaved(Variant[] args);
public void DocumentSaved(Variant[] args);
public void DocumentSavedAs(Variant[] args);
public void DocumentSavedAs(Variant[] args);
public Variant QueryCancelQuit(Variant[] args);
public Variant QueryCancelQuit(Variant[] args);
}

View File

@@ -10,16 +10,16 @@ package com.jacob.samples.visio;
* blocks everywhere
*/
public class VisioException extends Exception {
/**
* Totally dummy value to make Eclipse quit complaining
*/
private static final long serialVersionUID = 1L;
/**
* Totally dummy value to make Eclipse quit complaining
*/
private static final long serialVersionUID = 1L;
public VisioException(String msg) {
super(msg);
}
public VisioException(String msg) {
super(msg);
}
public VisioException(Throwable cause) {
super(cause);
}
public VisioException(Throwable cause) {
super(cause);
}
}