All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.com.ibm.as400.access.DBSQLDADataFormat Maven / Gradle / Ivy

The newest version!
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: DBSQLDADataFormat.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2001 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////

package com.ibm.as400.access;



/**
The DBSQLDADataFormat class is an implementation of
DBDataFormat which describes the data format used in
the SQLDA, specifically for the package cache.
**/
class DBSQLDADataFormat
implements DBDataFormat
{
    private static final String copyright = "Copyright (C) 1997-2001 International Business Machines Corporation and others.";




    // Private data.
    private static final int    REPEATED_LENGTH_    = 80;

    private byte[]              rawBytes_           = null;
    private int                 offset_             = -1;

    private int                 numberOfFields_     = -1;

    private int                 jobCCSID_;    // @D1A
    private int                 length_             = -1;
    private boolean             csRsData_           = false;    // @550A Indicates if the data associated with this format is from a stored procedure result set.



    /**
    Constructs a DBSQLDADataFormat object.  Use this when overlaying
    on a reply datastream.  The cached data will be set when overlay()
    is called.
     * @param jobCCSID 
    **/
    public DBSQLDADataFormat(int jobCCSID)    // @D1C
    {
        jobCCSID_ = jobCCSID;    // @D1A
    }



    // @D1D /**
    // @D1D Constructs a DBSQLDADataFormat object.  Use this when overlaying
    // @D1D on a request datastream.  This sets the cached data so that
    // @D1D the total length can be calculated before calling overlay().
    // @D1D **/
    // @D1D     public DBSQLDADataFormat (int numberOfFields)
    // @D1D     {
    // @D1D         numberOfFields_ = numberOfFields;
    // @D1D     }



    /**
    Positions the overlay structure.  This reads the cached data only
    when it was not previously set by the constructor.
    **/
    public void overlay (byte[] rawBytes, int offset)
    {
        rawBytes_           = rawBytes;
        offset_             = offset;

        if(numberOfFields_ == -1)
            numberOfFields_ = BinaryConverter.byteArrayToShort (rawBytes_, offset_ + 14);

        length_             = 16 + numberOfFields_ * REPEATED_LENGTH_;
    }



    public int getLength ()
    {
        return length_;
    }



    public int getConsistencyToken ()
    {
        // Not applicable.
        return -1;
    }



    public int getNumberOfFields ()
    {
        return numberOfFields_;
    }



    public int getRecordSize()
    {
        int recordSize = 0;
        int numberOfFields = getNumberOfFields ();
        for(int i = 0; i 




© 2015 - 2024 Weber Informatics LLC | Privacy Policy