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:
@@ -10,6 +10,15 @@
|
|||||||
(Feedback wanted)
|
(Feedback wanted)
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Variants</b>
|
||||||
|
<ul>
|
||||||
|
<li>Variant now accept Java Dates in the constructor.
|
||||||
|
<li>Redundant constructors removed
|
||||||
|
<li>Experimental toJavaObject() method added that automatically
|
||||||
|
converts to appropriate java type
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b>Event Callbacks</b>
|
<b>Event Callbacks</b>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -22,7 +31,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<h2>Tracked Changes</h2>
|
<h2>Tracked Changes</h2>
|
||||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
|
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -32,6 +40,11 @@
|
|||||||
<td width="13%">1340233</td>
|
<td width="13%">1340233</td>
|
||||||
<td width="87%">Null Program Id in Dispatch Constructor does bad things to VM</td>
|
<td width="87%">Null Program Id in Dispatch Constructor does bad things to VM</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="13%">1341763</td>
|
||||||
|
<td width="87%">Removed Variant serializable interface because it is not
|
||||||
|
actually serializable on 2000/xp</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="13%"> </td>
|
<td width="13%"> </td>
|
||||||
<td width="87%"> </td>
|
<td width="87%"> </td>
|
||||||
@@ -54,6 +67,14 @@
|
|||||||
<td width="13%">1185167</td>
|
<td width="13%">1185167</td>
|
||||||
<td width="87%">Provide methods to connect to running instance.</td>
|
<td width="87%">Provide methods to connect to running instance.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="13%">959381</td>
|
||||||
|
<td width="87%">Auto variant to object conversion method method added to Variant.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="13%">1341779</td>
|
||||||
|
<td width="87%">Variant should accept java.util.Date in Variant(Object) constructor</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
@@ -82,6 +103,7 @@
|
|||||||
<b>Variants</b>
|
<b>Variants</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Automatic conversion between Windows Time and Java Date is now supported
|
<li>Automatic conversion between Windows Time and Java Date is now supported
|
||||||
|
in Variant object.
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -22,9 +22,12 @@ package com.jacob.com;
|
|||||||
/**
|
/**
|
||||||
* Standard exception thrown by com jni code when there is a problem
|
* 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
|
// 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;
|
protected int hr;
|
||||||
/** TODO: what is this field */
|
/** TODO: what is this field */
|
||||||
protected int m_helpContext;
|
protected int m_helpContext;
|
||||||
|
|||||||
@@ -397,10 +397,10 @@ public class Dispatch extends JacobObject
|
|||||||
* @param dispatchTarget
|
* @param dispatchTarget
|
||||||
* @param name
|
* @param name
|
||||||
* @param val
|
* @param val
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public static void put_Casesensitive(Dispatch dispatchTarget, String name, Object val) {
|
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 name
|
||||||
* @param values
|
* @param values
|
||||||
* @return never returns anything because
|
* @return never returns anything because
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public static Variant callN_CaseSensitive(Dispatch dispatchTarget, String name,
|
public static Variant callN_CaseSensitive(Dispatch dispatchTarget, String name,
|
||||||
Object[] values) {
|
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 dispatchTarget
|
||||||
* @param name
|
* @param name
|
||||||
* @return Variant never returned
|
* @return Variant never returned
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public static Variant get_CaseSensitive(Dispatch dispatchTarget, String name) {
|
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
|
* This is a subclass of ComException so callers can still just catch
|
||||||
* ComException.
|
* ComException.
|
||||||
*/
|
*/
|
||||||
public class ComNotImplementedException extends ComException {
|
public class NotImplementedException extends JacobException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -35,7 +35,7 @@ public class ComNotImplementedException extends ComException {
|
|||||||
/**
|
/**
|
||||||
* @param description
|
* @param description
|
||||||
*/
|
*/
|
||||||
public ComNotImplementedException(String description) {
|
public NotImplementedException(String description) {
|
||||||
super(description);
|
super(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.jacob.com;
|
package com.jacob.com;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,28 +163,28 @@ public class Variant extends JacobObject {
|
|||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @param in doesn't matter because this method does nothing
|
* @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) {
|
public void putVariantArray(Variant[] in) {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @return never returns anything
|
* @return never returns anything
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public Variant[] getVariantArray() {
|
public Variant[] getVariantArray() {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @param in doesn't matter because this method does nothing
|
* @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) {
|
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
|
* @deprecated superceded by SafeArray
|
||||||
* @return never returns anything
|
* @return never returns anything
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public Object toCharArray() {
|
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
|
* @deprecated superceded by SafeArray
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public void putCharArray(Object in) {
|
public void putCharArray(Object in) {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
public native float getFloat();
|
public native float getFloat();
|
||||||
@@ -515,18 +516,18 @@ public class Variant extends JacobObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public void putVariantArrayRef(Variant[] in) {
|
public void putVariantArrayRef(Variant[] in) {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public Variant[] getVariantArrayRef() {
|
public Variant[] getVariantArrayRef() {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
public native void changeType(short in);
|
public native void changeType(short in);
|
||||||
@@ -621,6 +622,12 @@ public class Variant extends JacobObject {
|
|||||||
putFloatRef(((Float) o).floatValue());
|
putFloatRef(((Float) o).floatValue());
|
||||||
else
|
else
|
||||||
putFloat(((Float) o).floatValue());
|
putFloat(((Float) o).floatValue());
|
||||||
|
} else if (o instanceof Date){
|
||||||
|
if (fByRef){
|
||||||
|
putDateRef((Date) o);
|
||||||
|
} else {
|
||||||
|
putDate((Date)o);
|
||||||
|
}
|
||||||
} else if (o instanceof SafeArray) {
|
} else if (o instanceof SafeArray) {
|
||||||
if (fByRef)
|
if (fByRef)
|
||||||
putSafeArrayRef((SafeArray) o);
|
putSafeArrayRef((SafeArray) o);
|
||||||
@@ -689,19 +696,19 @@ public class Variant extends JacobObject {
|
|||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @return
|
* @return
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public Variant[] toVariantArray() {
|
public Variant[] toVariantArray() {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated superceded by SafeArray
|
* @deprecated superceded by SafeArray
|
||||||
* @return
|
* @return
|
||||||
* @throws com.jacob.com.ComNotImplementedException
|
* @throws com.jacob.com.NotImplementedException
|
||||||
*/
|
*/
|
||||||
public Object toByteArray() {
|
public Object toByteArray() {
|
||||||
throw new ComNotImplementedException("Not implemented");
|
throw new NotImplementedException("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -769,4 +776,94 @@ public class Variant extends JacobObject {
|
|||||||
*/
|
*/
|
||||||
public native void SerializationReadFromBytes(byte[] ba);
|
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
|
* thrown in util.cpp
|
||||||
*/
|
*/
|
||||||
public class WrongThreadException extends RuntimeException {
|
public class WrongThreadException extends JacobException {
|
||||||
/**
|
/**
|
||||||
* identifier generated by Eclipse
|
* identifier generated by Eclipse
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +33,7 @@ public class WrongThreadException extends RuntimeException {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public WrongThreadException() {
|
public WrongThreadException() {
|
||||||
super();
|
super("No Message Provided.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ public class DateUtilitiesTest {
|
|||||||
double comTimeForNow = DateUtilities.convertDateToWindowsTime(now);
|
double comTimeForNow = DateUtilities.convertDateToWindowsTime(now);
|
||||||
Date retrievedNow = DateUtilities.convertWindowsTimeToDate(comTimeForNow);
|
Date retrievedNow = DateUtilities.convertWindowsTimeToDate(comTimeForNow);
|
||||||
if (!now.equals(retrievedNow)){
|
if (!now.equals(retrievedNow)){
|
||||||
System.out.println("Variant Date Test failed " +now+ " != " +retrievedNow );
|
System.out.println("DateUtilities Date Test failed " +now+ " != " +retrievedNow );
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Variant Date Test passed");
|
System.out.println("DateUtilities Date Test passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a magic time in the windows world
|
// this is a magic time in the windows world
|
||||||
@@ -38,6 +38,7 @@ public class DateUtilitiesTest {
|
|||||||
} else {
|
} else {
|
||||||
System.out.println("Beginning of windows time test passed");
|
System.out.println("Beginning of windows time test passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,34 @@ public class VariantDateTest {
|
|||||||
if (!now.equals(retrievedNow)){
|
if (!now.equals(retrievedNow)){
|
||||||
System.out.println("Variant Date Test failed " +now+ " != " +retrievedNow );
|
System.out.println("Variant Date Test failed " +now+ " != " +retrievedNow );
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Variant Date Test passed");
|
//System.out.println("Variant Date Test passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( int i = 0; i < 30000; i++){
|
||||||
|
Variant dateVariant = new Variant(now);
|
||||||
|
retrievedNow = dateVariant.getJavaDate();
|
||||||
|
if (!now.equals(retrievedNow)){
|
||||||
|
System.out.println("Variant Date Test (1) failed " +now+ " != " +retrievedNow );
|
||||||
|
} else {
|
||||||
|
//System.out.println("Variant Date Test (1) passed");
|
||||||
|
}
|
||||||
|
// verify auto typecasting works
|
||||||
|
retrievedNow = (Date)dateVariant.toJavaObject();
|
||||||
|
if (!now.equals(retrievedNow)){
|
||||||
|
System.out.println("Variant Date Test (2) failed " +now+ " != " +retrievedNow );
|
||||||
|
} else {
|
||||||
|
//System.out.println("Variant Date Test (2) passed "+retrievedNow);
|
||||||
|
}
|
||||||
|
|
||||||
|
Variant intVariant = new Variant(4);
|
||||||
|
Object variantReturn = intVariant.toJavaObject();
|
||||||
|
// degenerate test to make sure date isn't always returned
|
||||||
|
if (variantReturn instanceof Date ){
|
||||||
|
System.out.println("int variant returned date");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.print("Test finished. All tests passed if no errors before this line");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user