workBuffer[ctr] = 49; } else { workBuffer[ctr] = 48;
if (columnValueArray[ctr] == 49) { workBuffer[ctr] = 49; } else { workBuffer[ctr] = 48; }
  public void g2_db2_bit_or ( String inVar,                          Blob intermResult )  throws Exception  {    // Test for SQL NULLs in the input parameters and    // the structured value itself    if (isNull(1))    {        return;    }    // Access the scratchpad and decode the previous    // intermediate result stored there    byte[] scratchpad = getScratchpad();    ByteArrayInputStream scratchIn =            new ByteArrayInputStream(scratchpad);    DataInputStream dataIn =            new DataInputStream(scratchIn);    // Initialize variables    // Byte buffer for the scratchpad copy of the value to be BIT_ORed    byte[] workBuffer = new byte[32];    int ctr = 0;    // Get the scratchpad into the work buffer    dataIn.read(workBuffer, 0, 32);    // Perform a binary encoding for new result, which is    // also stored on the scratchpad    ByteArrayOutputStream scratchOut =        new ByteArrayOutputStream();    DataOutputStream dataOut =        new DataOutputStream(scratchOut);    // Convert the column value string to an array of bytes    byte[] columnValueArray = new byte[32];    columnValueArray = inVar.getBytes();    // Walk the inVar byte array, test each char.    for (ctr = 0; ctr <= 31; ctr++)    {       // Check the current column value byte.       if (columnValueArray[ctr] == 49)          // If it's 1 (ASCII 49 = numeric 1),       {          workBuffer[ctr] = 49;                  // then set the corresponding scratchpad bit to 1,       }       else       {          workBuffer[ctr] = 48;                  // else set the corresponding scratchpad bit to 0.       }    }    // Write the updated scratchpad buffer to dataOut    dataOut.write(workBuffer, 0, 32);    // Construct new scratchpad data and store it    byte[] newScratchpad = scratchOut.toByteArray();    for (ctr = 0; ctr < newScratchpad.length; ctr++)    {       scratchpad[ctr] = newScratchpad[ctr];    }    setScratchpad(scratchpad);    // Set output parameter for new intermediate result    // (VARCHAR FOR BIT DATA is mapped to "Blob" class)    intermResult = Lob.newBlob();    OutputStream intermOut = intermResult.getOutputStream();    intermOut.write(workBuffer);    set(2, intermResult);  }