959381 auto variant to object conversion method
1341763 turned off serialization in Variant because it doesn't work 1341779 Variant constructor didn't accept java dates - now it does removal of getObject GetObjectByRef from Variant because broken or did nothing
This commit is contained in:
@@ -22,9 +22,12 @@ package com.jacob.com;
|
||||
/**
|
||||
* Standard exception thrown by com jni code when there is a problem
|
||||
*/
|
||||
public abstract class ComException extends RuntimeException {
|
||||
public abstract class ComException extends JacobException
|
||||
{
|
||||
// Fields
|
||||
/** TODO: what is this field */
|
||||
/** COM code initializes this filed with an appropriate return code
|
||||
* that was returned by the underlying com code
|
||||
**/
|
||||
protected int hr;
|
||||
/** TODO: what is this field */
|
||||
protected int m_helpContext;
|
||||
|
||||
@@ -397,10 +397,10 @@ public class Dispatch extends JacobObject
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @param val
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public static void put_Casesensitive(Dispatch dispatchTarget, String name, Object val) {
|
||||
throw new ComNotImplementedException("not implemented yet");
|
||||
throw new NotImplementedException("not implemented yet");
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
@@ -453,11 +453,11 @@ public class Dispatch extends JacobObject
|
||||
* @param name
|
||||
* @param values
|
||||
* @return never returns anything because
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public static Variant callN_CaseSensitive(Dispatch dispatchTarget, String name,
|
||||
Object[] values) {
|
||||
throw new ComNotImplementedException("not implemented yet");
|
||||
throw new NotImplementedException("not implemented yet");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1282,10 +1282,10 @@ public class Dispatch extends JacobObject
|
||||
* @param dispatchTarget
|
||||
* @param name
|
||||
* @return Variant never returned
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public static Variant get_CaseSensitive(Dispatch dispatchTarget, String name) {
|
||||
throw new ComNotImplementedException("not implemented yet");
|
||||
throw new NotImplementedException("not implemented yet");
|
||||
}
|
||||
|
||||
}
|
||||
49
src/com/jacob/com/JacobException.java
Normal file
49
src/com/jacob/com/JacobException.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2004 Sourceforge JACOB Project.
|
||||
* All rights reserved. Originator: Dan Adler (http://danadler.com).
|
||||
* Get more information about JACOB at http://sourceforge.net/projects/jacob-project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
/**
|
||||
* The parent class of all Jacob exceptions.
|
||||
* They all used to be based off of RuntimeException or ComException
|
||||
* but it was decided to base them all off of one owned by this project.
|
||||
*/
|
||||
public class JacobException extends RuntimeException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1637125318746002715L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* Calls super with a "No Message Provided" string
|
||||
*/
|
||||
public JacobException(){
|
||||
super("No Message Provided");
|
||||
}
|
||||
|
||||
/**
|
||||
* standard constructor
|
||||
* @param message
|
||||
*/
|
||||
public JacobException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ package com.jacob.com;
|
||||
* This is a subclass of ComException so callers can still just catch
|
||||
* ComException.
|
||||
*/
|
||||
public class ComNotImplementedException extends ComException {
|
||||
public class NotImplementedException extends JacobException {
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -35,7 +35,7 @@ public class ComNotImplementedException extends ComException {
|
||||
/**
|
||||
* @param description
|
||||
*/
|
||||
public ComNotImplementedException(String description) {
|
||||
public NotImplementedException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.jacob.com;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -162,28 +163,28 @@ public class Variant extends JacobObject {
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @param in doesn't matter because this method does nothing
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public void putVariantArray(Variant[] in) {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @return never returns anything
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public Variant[] getVariantArray() {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @param in doesn't matter because this method does nothing
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public void putByteArray(Object in) {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,10 +292,10 @@ public class Variant extends JacobObject {
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @return never returns anything
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public Object toCharArray() {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,10 +496,10 @@ public class Variant extends JacobObject {
|
||||
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public void putCharArray(Object in) {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
public native float getFloat();
|
||||
@@ -515,18 +516,18 @@ public class Variant extends JacobObject {
|
||||
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public void putVariantArrayRef(Variant[] in) {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public Variant[] getVariantArrayRef() {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
public native void changeType(short in);
|
||||
@@ -621,6 +622,12 @@ public class Variant extends JacobObject {
|
||||
putFloatRef(((Float) o).floatValue());
|
||||
else
|
||||
putFloat(((Float) o).floatValue());
|
||||
} else if (o instanceof Date){
|
||||
if (fByRef){
|
||||
putDateRef((Date) o);
|
||||
} else {
|
||||
putDate((Date)o);
|
||||
}
|
||||
} else if (o instanceof SafeArray) {
|
||||
if (fByRef)
|
||||
putSafeArrayRef((SafeArray) o);
|
||||
@@ -689,19 +696,19 @@ public class Variant extends JacobObject {
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @return
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public Variant[] toVariantArray() {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated superceded by SafeArray
|
||||
* @return
|
||||
* @throws com.jacob.com.ComNotImplementedException
|
||||
* @throws com.jacob.com.NotImplementedException
|
||||
*/
|
||||
public Object toByteArray() {
|
||||
throw new ComNotImplementedException("Not implemented");
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -769,4 +776,94 @@ public class Variant extends JacobObject {
|
||||
*/
|
||||
public native void SerializationReadFromBytes(byte[] ba);
|
||||
|
||||
/*=====================================================================
|
||||
*
|
||||
*
|
||||
*=====================================================================*/
|
||||
/**
|
||||
* Convert a JACOB Variant value to a Java object (type conversions).
|
||||
* provided in Sourceforge feature request 959381
|
||||
*
|
||||
* @param variant Variant with value to get and convert.
|
||||
* @return Corresponding Java type object.
|
||||
* @throws Exception if conversion failed.
|
||||
*/
|
||||
protected Object toJavaObject() throws JacobException {
|
||||
Object result = null;
|
||||
|
||||
short type = this.getvt(); //variant type
|
||||
|
||||
if (type >= Variant.VariantArray) { //array returned?
|
||||
SafeArray array = null;
|
||||
type = (short) (type - Variant.VariantArray);
|
||||
array = this.toSafeArray(false);
|
||||
//result = toJava(array);
|
||||
result = array;
|
||||
} else { //non-array object returned
|
||||
switch (type) {
|
||||
case Variant.VariantEmpty : //0
|
||||
case Variant.VariantNull : //1
|
||||
break;
|
||||
case Variant.VariantShort : //2
|
||||
result = new Short(this.getShort());
|
||||
break;
|
||||
case Variant.VariantInt : //3
|
||||
result = new Integer(this.getInt());
|
||||
break;
|
||||
case Variant.VariantFloat : //4
|
||||
result = new Float(this.getFloat());
|
||||
break;
|
||||
case Variant.VariantDouble : //5
|
||||
result = new Double(this.getDouble());
|
||||
break;
|
||||
case Variant.VariantCurrency : //6
|
||||
result = new Long(this.getCurrency());
|
||||
break;
|
||||
case Variant.VariantDate : //7
|
||||
result = this.getJavaDate();
|
||||
break;
|
||||
case Variant.VariantString : //8
|
||||
result = this.getString();
|
||||
break;
|
||||
case Variant.VariantDispatch : //9
|
||||
result = this.getDispatchRef();
|
||||
break;
|
||||
case Variant.VariantError : //10
|
||||
result = new NotImplementedException("Not implemented: VariantError");
|
||||
break;
|
||||
case Variant.VariantBoolean : //11
|
||||
result = new Boolean(this.getBoolean
|
||||
());
|
||||
break;
|
||||
case Variant.VariantVariant : //12
|
||||
result = new NotImplementedException("Not implemented: VariantVariant");
|
||||
break;
|
||||
case Variant.VariantObject : //13
|
||||
result = new NotImplementedException("Not implemented: VariantObject");
|
||||
break;
|
||||
case Variant.VariantByte : //17
|
||||
result = new NotImplementedException("Not implemented: VariantByte");
|
||||
break;
|
||||
case Variant.VariantTypeMask : //4095
|
||||
result = new NotImplementedException("Not implemented: VariantTypeMask");
|
||||
break;
|
||||
case Variant.VariantArray : //8192
|
||||
result = new NotImplementedException("Not implemented: VariantArray");
|
||||
break;
|
||||
case Variant.VariantByref : //16384
|
||||
result = new NotImplementedException("Not implemented: VariantByref");
|
||||
break;
|
||||
default :
|
||||
result = new NotImplementedException("Unknown return type: " + type);
|
||||
result = this;
|
||||
break;
|
||||
}//switch (type)
|
||||
|
||||
if (result instanceof JacobException) {
|
||||
throw (JacobException) result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}//toJava()
|
||||
}
|
||||
@@ -22,7 +22,7 @@ package com.jacob.com;
|
||||
/**
|
||||
* thrown in util.cpp
|
||||
*/
|
||||
public class WrongThreadException extends RuntimeException {
|
||||
public class WrongThreadException extends JacobException {
|
||||
/**
|
||||
* identifier generated by Eclipse
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ public class WrongThreadException extends RuntimeException {
|
||||
*
|
||||
*/
|
||||
public WrongThreadException() {
|
||||
super();
|
||||
super("No Message Provided.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user