From 34210e20a7285cf953b47221f48b852f247cd525 Mon Sep 17 00:00:00 2001 From: clay_shooter Date: Sun, 9 Jan 2005 04:08:00 +0000 Subject: [PATCH] javadoc --- com/jacob/com/Dispatch.java | 899 +++++++++++++++++++----------------- 1 file changed, 467 insertions(+), 432 deletions(-) diff --git a/com/jacob/com/Dispatch.java b/com/jacob/com/Dispatch.java index 554c827..bea8b56 100644 --- a/com/jacob/com/Dispatch.java +++ b/com/jacob/com/Dispatch.java @@ -37,7 +37,16 @@ import java.lang.reflect.Array; */ public class Dispatch extends JacobObject { - public int m_pDispatch; + /** + * why is this public? + * it could be protected and the Dispatch subclasses could still + * get it. + * This makes it hard to rename this thing + */ + public int m_pDispatch; + /** program Id passed in by ActiveX components in their constructor */ + private String programId = null; + public static final int LOCALE_SYSTEM_DEFAULT = 2048; public static final int Method = 1; public static final int Get = 2; @@ -111,440 +120,466 @@ public class Dispatch extends JacobObject public static final int DISPID_AMBIENT_CHARSET = -727; public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728; + // map args based on msdn doc - protected static Variant obj2variant(Object o) - { - if (o == null) - return new Variant(); - if (o instanceof Variant) - return (Variant)o; - if (o instanceof Integer) - return new Variant(((Integer)o).intValue()); - if (o instanceof String) - return new Variant((String)o); - if (o instanceof Boolean) - return new Variant(((Boolean)o).booleanValue()); - if (o instanceof Double) - return new Variant(((Double)o).doubleValue()); - if (o instanceof Float) - return new Variant(((Float)o).floatValue()); - if (o instanceof SafeArray) - return new Variant((SafeArray)o); - if (o instanceof Dispatch) { - Variant v = new Variant(); - v.putObject((Dispatch)o); - return v; - } - // automatically convert arrays using reflection - Class c1 = o.getClass(); - SafeArray sa = null; - if (c1.isArray()) - { - int len1 = Array.getLength(o); - Object first = Array.get(o, 0); - if (first.getClass().isArray()) - { - int max = 0; - for (int i = 0; i < len1; i++) - { - Object e1 = Array.get(o, i); - int len2 = Array.getLength(e1); - if (max < len2) - { - max = len2; - } + protected static Variant obj2variant(Object o) { + if (o == null) + return new Variant(); + if (o instanceof Variant) + return (Variant) o; + if (o instanceof Integer) + return new Variant(((Integer) o).intValue()); + if (o instanceof String) + return new Variant((String) o); + if (o instanceof Boolean) + return new Variant(((Boolean) o).booleanValue()); + if (o instanceof Double) + return new Variant(((Double) o).doubleValue()); + if (o instanceof Float) + return new Variant(((Float) o).floatValue()); + if (o instanceof SafeArray) + return new Variant((SafeArray) o); + if (o instanceof Dispatch) { + Variant v = new Variant(); + v.putObject((Dispatch) o); + return v; } - sa = new SafeArray(Variant.VariantVariant, len1, max); - for (int i = 0; i < len1; i++) - { - Object e1 = Array.get(o, i); - for (int j = 0; j < Array.getLength(e1); j++) - { - sa.setVariant(i, j, obj2variant(Array.get(e1, j))); - } + // automatically convert arrays using reflection + Class c1 = o.getClass(); + SafeArray sa = null; + if (c1.isArray()) { + int len1 = Array.getLength(o); + Object first = Array.get(o, 0); + if (first.getClass().isArray()) { + int max = 0; + for (int i = 0; i < len1; i++) { + Object e1 = Array.get(o, i); + int len2 = Array.getLength(e1); + if (max < len2) { + max = len2; + } + } + sa = new SafeArray(Variant.VariantVariant, len1, max); + for (int i = 0; i < len1; i++) { + Object e1 = Array.get(o, i); + for (int j = 0; j < Array.getLength(e1); j++) { + sa.setVariant(i, j, obj2variant(Array.get(e1, j))); + } + } + } else { + sa = new SafeArray(Variant.VariantVariant, len1); + for (int i = 0; i < len1; i++) { + sa.setVariant(i, obj2variant(Array.get(o, i))); + } + } + return new Variant(sa); } - } else { - sa = new SafeArray(Variant.VariantVariant, len1); - for (int i = 0; i < len1; i++) - { - sa.setVariant(i, obj2variant(Array.get(o, i))); - } - } - return new Variant(sa); + throw new ClassCastException("cannot convert to Variant"); } - throw new ClassCastException("cannot convert to Variant"); - } - // same as above, for an array - protected static Variant[] obj2variant(Object[] o) - { - Variant vArg[] = new Variant[o.length]; - for(int i=0;i