Package OLE

Source Code of OLE.ForteVariant$qq_Resolver

/*
Copyright (c) 2003-2009 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package OLE;
import java.util.Date;

import com.jacob.com.Currency;
import com.jacob.com.Dispatch;
import com.jacob.com.SafeArray;
import com.jacob.com.Variant;
/**
* The Variant class represents a value whose data type is unknown.
* A client application can use a Variant object to specify a variable value whose exact data type cannot be determined when the TOOL code is compiled.
* You must use the Variant class and its subclasses to define input and output parameters to OLE methods, because OLE Automation uses these data types to define its input and output. You can use the methods defined for the Variant class only when a given Variant object is also an object of the VariantDispatch subclass.
*
*/
public class ForteVariant extends Variant {
    protected boolean Null;
    protected int Mechanism;
    public class qq_Resolver{
        public static final int cVALUE = 0;
        public static final int cMECHANISM = 1;
        public static final int cMECHANISM_VALUE = 2;
        }
    public ForteVariant() {
        super();
    }
    /**
     * Value indicating how the parameter is used.
     * Valid values are:
     * <li>ARIANT_IN  The value is passed to the OLE method.</li>
     * <li>VARIANT_INOUT  The value is passed to the OLE method and the OLE method passes a value back.</li>
     * <li>VARIANT_OUT  OLE method generates and passes back a value.</li>
     * <li>VARIANT_RESULT  The value is returned by the OLE method.</li>
     * @return
     */
    public int getMechanism() {
        return Mechanism;
    }
    /**
     * Value indicating how the parameter is used.
     * Valid values are:
     * <li>ARIANT_IN  The value is passed to the OLE method.</li>
     * <li>VARIANT_INOUT  The value is passed to the OLE method and the OLE method passes a value back.</li>
     * <li>VARIANT_OUT  OLE method generates and passes back a value.</li>
     * <li>VARIANT_RESULT  The value is returned by the OLE method.</li>
     */
    public void setMechanism(int mechanism) {
        Mechanism = mechanism;
    }
    /**
     * Value indicating whether the value has been initialized.
     */
    public boolean isNull() {
        return Null;
    }
    public void setNull(boolean null1) {
        Null = null1;
    }
    public void putBoolean(boolean arg0) {
        Null = false;
        if (useRef())
            super.putBooleanRef(arg0);
        else
            super.putBoolean(arg0);
    }
    public void putBooleanRef(boolean arg0) {
        Null = false;
        super.putBooleanRef(arg0);
    }
    public void putByte(byte arg0) {
        Null = false;
        if (useRef())
            super.putByteRef(arg0);
        else
            super.putByte(arg0);
    }
    @SuppressWarnings("deprecation")
  public void putByteArray(Object arg0) {
        Null = false;
        super.putByteArray(arg0);
    }
    public void putByteRef(byte arg0) {
        Null = false;
        super.putByteRef(arg0);
    }
    @SuppressWarnings("deprecation")
  public void putCharArray(Object arg0) {
        Null = false;
        super.putCharArray(arg0);
    }
    public void putCurrency(long arg0) {
        Null = false;
        if (useRef())
            super.putCurrencyRef(new Currency(arg0));
        else
            super.putCurrency(new Currency(arg0));
    }
    public void putCurrencyRef(long arg0) {
        Null = false;
        super.putCurrencyRef(new Currency(arg0));
    }
    public void putDate(Date arg0) {
        Null = false;
        if (useRef())
            super.putDateRef(arg0);
        else
            super.putDate(arg0);
    }
    public void putDate(double arg0) {
        Null = false;
        if (useRef())
            super.putDateRef(arg0);
        else
            super.putDate(arg0);
    }
    public void putDateRef(Date arg0) {
        Null = false;

        super.putDateRef(arg0);
    }
    public void putDateRef(double arg0) {
        Null = false;
        super.putDateRef(arg0);
    }
    public void putDispatch(Dispatch arg0) {
        Null = false;
        if (useRef())
            super.putDispatchRef(arg0);
        else
            super.putDispatch(arg0);
    }
    public void putDispatchRef(Dispatch arg0) {
        Null = false;
        super.putDispatchRef(arg0);
    }
    public void putDouble(double arg0) {
        Null = false;
        if (useRef())
            super.putDoubleRef(arg0);
        else
            super.putDouble(arg0);
    }
    public void putDoubleRef(double arg0) {
        Null = false;
        super.putDoubleRef(arg0);
    }
    public void putEmpty() {
        Null = false;
        super.putEmpty();
    }
    public void putError(int arg0) {
        Null = false;
        if (useRef())
            super.putErrorRef(arg0);
        else
            super.putError(arg0);
    }
    public void putErrorRef(int arg0) {
        Null = false;
        super.putErrorRef(arg0);
    }
    public void putFloat(float arg0) {
        Null = false;
        if (useRef())
            super.putFloatRef(arg0);
        else
            super.putFloat(arg0);
    }
    public void putFloatRef(float arg0) {
        Null = false;
        super.putFloatRef(arg0);
    }
    public void putInt(int arg0) {
        Null = false;
        if (useRef())
            super.putIntRef(arg0);
        else
            super.putInt(arg0);
    }
    public void putIntRef(int arg0) {
        Null = false;
        super.putIntRef(arg0);
    }
    public void putNothing() {
        Null = false;
        super.putNothing();
    }
    public void putNull() {
        Null = false;
        super.putNull();
    }
    @SuppressWarnings("deprecation")
  public void putObject(Object arg0) {
        Null = false;
        if (useRef())
            super.putObjectRef(arg0);
        else
            super.putObject(arg0);
    }
    @SuppressWarnings("deprecation")
  public void putObjectRef(Object arg0) {
        Null = false;
        super.putObjectRef(arg0);
    }
    public void putSafeArray(SafeArray arg0) {
        Null = false;
        if (useRef())
            super.putSafeArrayRef(arg0);
        else
            super.putSafeArray(arg0);
    }
    public void putSafeArrayRef(SafeArray arg0) {
        Null = false;
        super.putSafeArrayRef(arg0);
    }
    public void putShort(short arg0) {
        Null = false;
        if (useRef())
            super.putShortRef(arg0);
        else
            super.putShort(arg0);
    }
    public void putShortRef(short arg0) {
        Null = false;
        super.putShortRef(arg0);
    }
    public void putString(String arg0) {
        Null = false;
        if (useRef())
            super.putStringRef(arg0);
        else
            super.putString(arg0);
    }
    public void putStringRef(String arg0) {
        Null = false;
        super.putStringRef(arg0);
    }
    @SuppressWarnings("deprecation")
  public void putVariantArray(Variant[] arg0) {
        Null = false;
        if (useRef())
            super.putVariantArrayRef(arg0);
        else
            super.putVariantArray(arg0);
    }
    @SuppressWarnings("deprecation")
  public void putVariantArrayRef(Variant[] arg0) {
        Null = false;
        super.putVariantArrayRef(arg0);
    }
    protected boolean useRef(){
        return ((this.Mechanism == Constants.VARIANT_INOUT) ||
                (this.Mechanism == Constants.VARIANT_OUT));
    }

    /**
     * this constructor is used to make a typed variant from a generalized variant.
     * @param variant
     */
    @SuppressWarnings("unchecked")
  public static <R extends Variant> R toTypedVariant(Variant variant){
        switch(variant.getvt()){
        case Variant.VariantBoolean:
            return (R)new VariantBoolean(variant.getBoolean());
        case Variant.VariantDate:
            return (R)new VariantDate(new DATEClass(variant.getDate()));
        case Variant.VariantDouble:
            return (R)new VariantDouble(variant.getDouble(), qq_Resolver.cVALUE);
        case Variant.VariantFloat:
            return (R)new VariantFloat(variant.getFloat(), qq_Resolver.cVALUE);
        case Variant.VariantShort:
            return (R)new VariantI2(variant.getShort(), qq_Resolver.cVALUE);
        case Variant.VariantInt:
            return (R)new VariantInteger(variant.getInt(), qq_Resolver.cVALUE);
        case Variant.VariantString:
            return (R)new VariantString(variant.getString(), qq_Resolver.cVALUE);
        default:
            return (R)variant;
        }
    }

}
TOP

Related Classes of OLE.ForteVariant$qq_Resolver

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.