From derby-commits-return-638-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Mon May 02 07:27:10 2005 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 66925 invoked from network); 2 May 2005 07:27:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 May 2005 07:27:08 -0000 Received: (qmail 59917 invoked by uid 500); 2 May 2005 07:28:13 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 59793 invoked by uid 500); 2 May 2005 07:28:11 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 59719 invoked by uid 500); 2 May 2005 07:28:10 -0000 Delivered-To: apmail-incubator-derby-cvs@incubator.apache.org Received: (qmail 59697 invoked by uid 99); 2 May 2005 07:28:10 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 02 May 2005 00:28:07 -0700 Received: (qmail 31612 invoked by uid 65534); 2 May 2005 06:26:41 -0000 Message-ID: <20050502062641.31611.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165585 [23/42] - in /incubator/derby/code/trunk/java/client/org/apache/derby: client/ client/am/ client/net/ client/resources/ jdbc/ Date: Mon, 02 May 2005 06:26:03 -0000 To: derby-cvs@incubator.apache.org From: jboynes@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am= /StatementCallbackInterface.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/StatementCallbackInterface.java?rev=3D165585&r1= =3D165584&r2=3D165585&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/State= mentCallbackInterface.java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/State= mentCallbackInterface.java Sun May 1 23:25:59 2005 @@ -20,40 +20,43 @@ =20 package org.apache.derby.client.am; =20 -import org.apache.derby.client.am.Section; + =20 // Methods implemented by the common Statement class to handle // certain events that may originate from the material or common layers. // // Reply implementations may update statement state via this interface. // -public interface StatementCallbackInterface -{ - // A query has been opened on the server. - public void completeOpenQuery (Sqlca sqlca, ResultSet resultSet) throws = DisconnectException; - public void completeExecuteCallOpenQuery (Sqlca sqlca, ResultSet resultS= et, ColumnMetaData resultSetMetaData, Section generatedSection); =20 - // Chains a warning onto the statement. - public void accumulateWarning (SqlWarning e); +public interface StatementCallbackInterface { + // A query has been opened on the server. + public void completeOpenQuery(Sqlca sqlca, ResultSet resultSet) throws= DisconnectException; + + public void completeExecuteCallOpenQuery(Sqlca sqlca, ResultSet result= Set, ColumnMetaData resultSetMetaData, Section generatedSection); + + // Chains a warning onto the statement. + public void accumulateWarning(SqlWarning e); + + public void completePrepare(Sqlca sqlca); + + public void completePrepareDescribeOutput(ColumnMetaData columnMetaDat= a, Sqlca sqlca); =20 - public void completePrepare (Sqlca sqlca); + public void completeExecuteImmediate(Sqlca sqlca); =20 - public void completePrepareDescribeOutput (ColumnMetaData columnMetaData= , Sqlca sqlca); + public void completeExecuteSetStatement(Sqlca sqlca); =20 - public void completeExecuteImmediate (Sqlca sqlca); =20 - public void completeExecuteSetStatement (Sqlca sqlca); + public void completeExecute(Sqlca sqlca); =20 + public void completeExecuteCall(Sqlca sqlca, Cursor params, ResultSet[= ] resultSets); =20 - public void completeExecute (Sqlca sqlca); - public void completeExecuteCall (Sqlca sqlca, Cursor params, ResultSet[]= resultSets); - public void completeExecuteCall (Sqlca sqlca, Cursor params); + public void completeExecuteCall(Sqlca sqlca, Cursor params); =20 - public int completeSqlca (Sqlca sqlca); + public int completeSqlca(Sqlca sqlca); =20 - public ConnectionCallbackInterface getConnectionCallbackInterface (); + public ConnectionCallbackInterface getConnectionCallbackInterface(); =20 - public ColumnMetaData getGuessedResultSetMetaData (); + public ColumnMetaData getGuessedResultSetMetaData(); =20 =20 } Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am= /Types.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/Types.java?rev=3D165585&r1=3D165584&r2=3D165585&v= iew=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Types= .java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Types= .java Sun May 1 23:25:59 2005 @@ -21,147 +21,153 @@ =20 // This enumeration of types represents the typing scheme used by our jdbc= driver. // Once this is finished, we need to review our switches to make sure they= are exhaustive -public class Types -{ - // -------------------------------- Driver types -----------------------= -------------------------- - - // Not currently supported as a DERBY column type. Mapped to SMALLINT. - // public final static int BIT =3D java.sql.Types.BIT; = // -7; - - // Not currently supported as a DERBY column type. Mapped to SMALLINT. - //public final static int TINYINT =3D java.sql.Types.TINYINT; // = -6; - - public final static int SMALLINT =3D java.sql.Types.SMALLINT; // 5; - - public final static int INTEGER =3D java.sql.Types.INTEGER; // 4; - - public final static int BIGINT =3D java.sql.Types.BIGINT; // -5; - - // We type using DOUBLE - //public final static int FLOAT =3D java.sql.Types.FLOAT; // 6; - - public final static int REAL =3D java.sql.Types.REAL; // 7; - - public final static int DOUBLE =3D java.sql.Types.DOUBLE; // 8; - - // We type using DECIMAL - //public final static int NUMERIC =3D java.sql.Types.NUMERIC; // = 2; - - public final static int DECIMAL =3D java.sql.Types.DECIMAL; // 3; - - public final static int CHAR =3D java.sql.Types.CHAR; // 1; - - public final static int VARCHAR =3D java.sql.Types.VARCHAR; // 12; - - public final static int LONGVARCHAR =3D java.sql.Types.LONGVARCHAR; /= / -1; - - public final static int DATE =3D java.sql.Types.DATE; // 91; - - public final static int TIME =3D java.sql.Types.TIME; // 92; - - public final static int TIMESTAMP =3D java.sql.Types.TIMESTAMP; // = 93; - - public final static int BINARY =3D java.sql.Types.BINARY; // -2; - - public final static int VARBINARY =3D java.sql.Types.VARBINARY; // = -3; - - public final static int LONGVARBINARY =3D java.sql.Types.LONGVARBINARY; = // -4; - - public final static int BLOB =3D java.sql.Types.BLOB; = // 2004; - - public final static int CLOB =3D java.sql.Types.CLOB; = // 2005; - - // hide the default constructor - private Types() {} - - // -------------------------------- DERBY types ------------------------= ---------------------------- - - public final static int DERBY_SQLTYPE_DATE =3D 384; // DATE - public final static int DERBY_SQLTYPE_NDATE =3D 385; - public final static int DERBY_SQLTYPE_TIME =3D 388; // TIME - public final static int DERBY_SQLTYPE_NTIME =3D 389; - public final static int DERBY_SQLTYPE_TIMESTAMP =3D 392; // TIMESTAMP - public final static int DERBY_SQLTYPE_NTIMESTAMP =3D 393; - - public final static int DERBY_SQLTYPE_BLOB =3D 404; // BLOB - public final static int DERBY_SQLTYPE_NBLOB =3D 405; - public final static int DERBY_SQLTYPE_CLOB =3D 408; // CLOB - public final static int DERBY_SQLTYPE_NCLOB =3D 409; - - public final static int DERBY_SQLTYPE_VARCHAR =3D 448; // VARCHAR(i)= - varying length string - public final static int DERBY_SQLTYPE_NVARCHAR =3D 449; - public final static int DERBY_SQLTYPE_CHAR =3D 452; // CHAR(i) - = fixed length - public final static int DERBY_SQLTYPE_NCHAR =3D 453; - public final static int DERBY_SQLTYPE_LONG =3D 456; // LONG VARCH= AR - varying length string - public final static int DERBY_SQLTYPE_NLONG =3D 457; - public final static int DERBY_SQLTYPE_CSTR =3D 460; // SBCS - nul= l terminated - public final static int DERBY_SQLTYPE_NCSTR =3D 461; - - public final static int DERBY_SQLTYPE_FLOAT =3D 480; // FLOAT - 4 = or 8 byte floating point - public final static int DERBY_SQLTYPE_NFLOAT =3D 481; - public final static int DERBY_SQLTYPE_DECIMAL =3D 484; // DECIMAL (m= ,n) - public final static int DERBY_SQLTYPE_NDECIMAL =3D 485; - public final static int DERBY_SQLTYPE_BIGINT =3D 492; // BIGINT - 8= -byte signed integer - public final static int DERBY_SQLTYPE_NBIGINT =3D 493; - public final static int DERBY_SQLTYPE_INTEGER =3D 496; // INTEGER - public final static int DERBY_SQLTYPE_NINTEGER =3D 497; - public final static int DERBY_SQLTYPE_SMALL =3D 500; // SMALLINT -= 2-byte signed integer = */ - public final static int DERBY_SQLTYPE_NSMALL =3D 501; - - public final static int DERBY_SQLTYPE_NUMERIC =3D 504; // NUMERIC ->= DECIMAL (m,n) - public final static int DERBY_SQLTYPE_NNUMERIC =3D 505; - - static public int mapDERBYTypeToDriverType (boolean isDescribed, int sql= Type, long length, int ccsid) - { - switch (Utils.getNonNullableSqlType (sqlType)) { // mask the isNullabl= e bit - case DERBY_SQLTYPE_SMALL: - return SMALLINT; - case DERBY_SQLTYPE_INTEGER: - return INTEGER; - case DERBY_SQLTYPE_BIGINT: - return BIGINT; - case DERBY_SQLTYPE_FLOAT: - if (length =3D=3D 16) // can map to either NUMERIC = or DECIMAL - return DECIMAL; - else if (length =3D=3D 8) // can map to either DOUBLE o= r FLOAT - return DOUBLE; - else if (length =3D=3D 4) - return REAL; - else - return 0; - case DERBY_SQLTYPE_DECIMAL: // can map to either NUMERIC or= DECIMAL - case DERBY_SQLTYPE_NUMERIC: // can map to either NUMERIC or= DECIMAL - return DECIMAL; - case DERBY_SQLTYPE_CHAR: // mixed and single byte - if (isDescribed && (ccsid =3D=3D 0xffff || ccsid =3D=3D 0)) - return BINARY; - else - return CHAR; - case DERBY_SQLTYPE_CSTR: // null terminated SBCS/Mixed - return CHAR; - // use ccsid to distinguish between BINARY and CHAR, VARBINARY and VAR= CHAR, LONG...=20 - case DERBY_SQLTYPE_VARCHAR: // variable character SBCS/Mixed - if (isDescribed && (ccsid =3D=3D 0xffff || ccsid =3D=3D 0)) - return VARBINARY; - else - return VARCHAR; - case DERBY_SQLTYPE_LONG: // long varchar SBCS/Mixed - if (isDescribed && (ccsid =3D=3D 0xffff || ccsid =3D=3D 0)) - return LONGVARBINARY; - else - return LONGVARCHAR; - case DERBY_SQLTYPE_DATE: - return DATE; - case DERBY_SQLTYPE_TIME: - return TIME; - case DERBY_SQLTYPE_TIMESTAMP: - return TIMESTAMP; - case DERBY_SQLTYPE_CLOB: // large object character SBCS/Mixed - return Types.CLOB; - case DERBY_SQLTYPE_BLOB: // large object bytes - return java.sql.Types.BLOB; - default: - return 0; + +public class Types { + // -------------------------------- Driver types ---------------------= ---------------------------- + + // Not currently supported as a DERBY column type. Mapped to SMALLINT. + // public final static int BIT =3D java.sql.Types.BIT; = // -7; + + // Not currently supported as a DERBY column type. Mapped to SMALLINT. + //public final static int TINYINT =3D java.sql.Types.TINYINT; /= / -6; + + public final static int SMALLINT =3D java.sql.Types.SMALLINT; // = 5; + + public final static int INTEGER =3D java.sql.Types.INTEGER; // 4; + + public final static int BIGINT =3D java.sql.Types.BIGINT; // -5; + + // We type using DOUBLE + //public final static int FLOAT =3D java.sql.Types.FLOAT; // = 6; + + public final static int REAL =3D java.sql.Types.REAL; // 7; + + public final static int DOUBLE =3D java.sql.Types.DOUBLE; // 8; + + // We type using DECIMAL + //public final static int NUMERIC =3D java.sql.Types.NUMERIC; /= / 2; + + public final static int DECIMAL =3D java.sql.Types.DECIMAL; // 3; + + public final static int CHAR =3D java.sql.Types.CHAR; // 1; + + public final static int VARCHAR =3D java.sql.Types.VARCHAR; // 1= 2; + + public final static int LONGVARCHAR =3D java.sql.Types.LONGVARCHAR; = // -1; + + public final static int DATE =3D java.sql.Types.DATE; // 91; + + public final static int TIME =3D java.sql.Types.TIME; // 92; + + public final static int TIMESTAMP =3D java.sql.Types.TIMESTAMP; //= 93; + + public final static int BINARY =3D java.sql.Types.BINARY; // -2; + + public final static int VARBINARY =3D java.sql.Types.VARBINARY; //= -3; + + public final static int LONGVARBINARY =3D java.sql.Types.LONGVARBINARY= ; // -4; + + public final static int BLOB =3D java.sql.Types.BLOB; // 2004; + + public final static int CLOB =3D java.sql.Types.CLOB; // 2005; + + // hide the default constructor + private Types() { + } + + // -------------------------------- DERBY types ----------------------= ------------------------------ + + public final static int DERBY_SQLTYPE_DATE =3D 384; // DATE + public final static int DERBY_SQLTYPE_NDATE =3D 385; + public final static int DERBY_SQLTYPE_TIME =3D 388; // TIME + public final static int DERBY_SQLTYPE_NTIME =3D 389; + public final static int DERBY_SQLTYPE_TIMESTAMP =3D 392; // TIMESTAMP + public final static int DERBY_SQLTYPE_NTIMESTAMP =3D 393; + + public final static int DERBY_SQLTYPE_BLOB =3D 404; // BLOB + public final static int DERBY_SQLTYPE_NBLOB =3D 405; + public final static int DERBY_SQLTYPE_CLOB =3D 408; // CLOB + public final static int DERBY_SQLTYPE_NCLOB =3D 409; + + public final static int DERBY_SQLTYPE_VARCHAR =3D 448; // VARCHAR(= i) - varying length string + public final static int DERBY_SQLTYPE_NVARCHAR =3D 449; + public final static int DERBY_SQLTYPE_CHAR =3D 452; // CHAR(i) = - fixed length + public final static int DERBY_SQLTYPE_NCHAR =3D 453; + public final static int DERBY_SQLTYPE_LONG =3D 456; // LONG VAR= CHAR - varying length string + public final static int DERBY_SQLTYPE_NLONG =3D 457; + public final static int DERBY_SQLTYPE_CSTR =3D 460; // SBCS - n= ull terminated + public final static int DERBY_SQLTYPE_NCSTR =3D 461; + + public final static int DERBY_SQLTYPE_FLOAT =3D 480; // FLOAT - = 4 or 8 byte floating point + public final static int DERBY_SQLTYPE_NFLOAT =3D 481; + public final static int DERBY_SQLTYPE_DECIMAL =3D 484; // DECIMAL = (m,n) + public final static int DERBY_SQLTYPE_NDECIMAL =3D 485; + public final static int DERBY_SQLTYPE_BIGINT =3D 492; // BIGINT -= 8-byte signed integer + public final static int DERBY_SQLTYPE_NBIGINT =3D 493; + public final static int DERBY_SQLTYPE_INTEGER =3D 496; // INTEGER + public final static int DERBY_SQLTYPE_NINTEGER =3D 497; + public final static int DERBY_SQLTYPE_SMALL =3D 500; // SMALLINT= - 2-byte signed integer = */ + public final static int DERBY_SQLTYPE_NSMALL =3D 501; + + public final static int DERBY_SQLTYPE_NUMERIC =3D 504; // NUMERIC = -> DECIMAL (m,n) + public final static int DERBY_SQLTYPE_NNUMERIC =3D 505; + + static public int mapDERBYTypeToDriverType(boolean isDescribed, int sq= lType, long length, int ccsid) { + switch (Utils.getNonNullableSqlType(sqlType)) { // mask the isNull= able bit + case DERBY_SQLTYPE_SMALL: + return SMALLINT; + case DERBY_SQLTYPE_INTEGER: + return INTEGER; + case DERBY_SQLTYPE_BIGINT: + return BIGINT; + case DERBY_SQLTYPE_FLOAT: + if (length =3D=3D 16) // can map to either NU= MERIC or DECIMAL + { + return DECIMAL; + } else if (length =3D=3D 8) // can map to either = DOUBLE or FLOAT + { + return DOUBLE; + } else if (length =3D=3D 4) { + return REAL; + } else { + return 0; + } + case DERBY_SQLTYPE_DECIMAL: // can map to either NUMERI= C or DECIMAL + case DERBY_SQLTYPE_NUMERIC: // can map to either NUMERI= C or DECIMAL + return DECIMAL; + case DERBY_SQLTYPE_CHAR: // mixed and single byte + if (isDescribed && (ccsid =3D=3D 0xffff || ccsid =3D=3D 0)) { + return BINARY; + } else { + return CHAR; + } + case DERBY_SQLTYPE_CSTR: // null terminated SBCS/Mixed + return CHAR; + // use ccsid to distinguish between BINARY and CHAR, VARBINARY= and VARCHAR, LONG... + case DERBY_SQLTYPE_VARCHAR: // variable character SBCS/Mixed + if (isDescribed && (ccsid =3D=3D 0xffff || ccsid =3D=3D 0)) { + return VARBINARY; + } else { + return VARCHAR; + } + case DERBY_SQLTYPE_LONG: // long varchar SBCS/Mixed + if (isDescribed && (ccsid =3D=3D 0xffff || ccsid =3D=3D 0)) { + return LONGVARBINARY; + } else { + return LONGVARCHAR; + } + case DERBY_SQLTYPE_DATE: + return DATE; + case DERBY_SQLTYPE_TIME: + return TIME; + case DERBY_SQLTYPE_TIMESTAMP: + return TIMESTAMP; + case DERBY_SQLTYPE_CLOB: // large object character SBCS/Mixed + return Types.CLOB; + case DERBY_SQLTYPE_BLOB: // large object bytes + return java.sql.Types.BLOB; + default: + return 0; + } } - } } Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am= /UnitOfWorkListener.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/UnitOfWorkListener.java?rev=3D165585&r1=3D165584&= r2=3D165585&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/UnitO= fWorkListener.java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/UnitO= fWorkListener.java Sun May 1 23:25:59 2005 @@ -20,11 +20,10 @@ =20 package org.apache.derby.client.am; =20 -public interface UnitOfWorkListener -{ - public void listenToUnitOfWork (); +public interface UnitOfWorkListener { + public void listenToUnitOfWork(); =20 - public void completeLocalCommit (java.util.Iterator listenerIterator); + public void completeLocalCommit(java.util.Iterator listenerIterator); =20 - public void completeLocalRollback (java.util.Iterator listenerIterator); + public void completeLocalRollback(java.util.Iterator listenerIterator); } Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am= /Utils.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/Utils.java?rev=3D165585&r1=3D165584&r2=3D165585&v= iew=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Utils= .java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Utils= .java Sun May 1 23:25:59 2005 @@ -22,289 +22,294 @@ =20 // Self-contained utilities. // Don't reference any other driver classes, except Configuration, from wi= thin this class. -public final class Utils -{ =20 - static String getStringFromBytes (byte[] bytes) - { - if (bytes =3D=3D null) return "{}"; - StringBuffer stringBuffer =3D new StringBuffer (bytes.length*6 + 4); - stringBuffer.append ("{ "); - for (int i=3D0; i < bytes.length; i++) { - stringBuffer.append ("0x"); - stringBuffer.append (Integer.toHexString (bytes[i] & 0xff)); - if (i !=3D bytes.length - 1) stringBuffer.append (", "); - } - stringBuffer.append (" }"); - return stringBuffer.toString(); - } - - static String getStringFromInts (int[] ints) - { - if (ints =3D=3D null) return "{}"; - StringBuffer stringBuffer =3D new StringBuffer (); - stringBuffer.append ("{ "); - for (int i=3D0; i < ints.length; i++) { - stringBuffer.append (String.valueOf (ints[i])); - if (i !=3D ints.length - 1) stringBuffer.append (", "); - } - stringBuffer.append (" }"); - return stringBuffer.toString(); - } - - static String getStringFromStrings (String[] strings) - { - if (strings =3D=3D null) return "{}"; - StringBuffer stringBuffer =3D new StringBuffer (); - stringBuffer.append ("{ "); - for (int i=3D0; i < strings.length; i++) { - stringBuffer.append (strings[i]); - if (i !=3D strings.length - 1) stringBuffer.append (", "); - } - stringBuffer.append (" }"); - return stringBuffer.toString(); - } - - static public int computeBigDecimalPrecision (java.math.BigDecimal decim= al) - { - byte[] bBytes =3D decimal.unscaledValue().abs().toByteArray(); - - if (byteArrayCmp (bBytes, tenRadixArr[tenRadixArr.length-1]) >=3D 0) - throw new java.lang.IllegalArgumentException ("Precision exceeds 31 = digits!"); - - int lo=3D0, hi=3DtenRadixArr.length-1, mi=3D(hi+lo)/2; - do { - int compare =3D byteArrayCmp (bBytes, tenRadixArr[mi]); - if (compare =3D=3D 1) - lo =3D mi; - else if (compare =3D=3D -1) - hi =3D mi; - else - break; - - mi =3D (hi+lo)/2; - } - while (mi !=3D lo); - - return (mi+1); - } - - // Used only by computeBigDecimalPrecision() - private static int byteArrayCmp (byte[] arg1, byte[] arg2) - { - int arg1Offset =3D 0; - int arg2Offset =3D 0; - int length; - if (arg1.length > arg2.length) { - int diff =3D arg1.length-arg2.length; - for (; arg1Offset b2) - return 1; - else if (b1 < b2) - return -1; - } - return 0; - } - - // Used only by computeBigDecimalPrecision() - // byte array of 1, 10, 100, 1000, 10000, ..., 10^31 for - // fast computing the length a BigDecimal. - private static byte[][] tenRadixArr =3D { - { (byte)0x01 }, // 10^0 - { (byte)0x0A }, // 10^1 - { (byte)0x64 }, // 10^2 - { (byte)0x03, (byte)0xe8 }, // 10^3 - { (byte)0x27, (byte)0x10 }, // 10^4 - { (byte)0x01, (byte)0x86, (byte)0xa0 }, // 10^5 - { (byte)0x0f, (byte)0x42, (byte)0x40 }, // 10^6 - { (byte)0x98, (byte)0x96, (byte)0x80 }, // 10^7 - { (byte)0x05, (byte)0xf5, (byte)0xe1, (byte)0x00 }, // 10^8 - { (byte)0x3b, (byte)0x9a, (byte)0xca, (byte)0x00 }, // 10^9 - { (byte)0x02, (byte)0x54, (byte)0x0b, (byte)0xe4, (byte)0x00 }, // 10^= 10 - { (byte)0x17, (byte)0x48, (byte)0x76, (byte)0xe8, (byte)0x00 }, // 10^= 11 - { (byte)0xe8, (byte)0xd4, (byte)0xa5, (byte)0x10, (byte)0x00 }, // 10^= 12 - { (byte)0x09, (byte)0x18, (byte)0x4e, (byte)0x72, (byte)0xa0, (byte)0x= 00 }, // 10^13 - { (byte)0x5a, (byte)0xf3, (byte)0x10, (byte)0x7a, (byte)0x40, (byte)0x= 00 }, // 10^14 - { (byte)0x03, (byte)0x8d, (byte)0x7e, (byte)0xa4, (byte)0xc6, (byte)0x= 80, (byte)0x00 }, // 10^15 - { (byte)0x23, (byte)0x86, (byte)0xf2, (byte)0x6f, (byte)0xc1, (byte)0x= 00, (byte)0x00 }, // 10^16 - { (byte)0x01, (byte)0x63, (byte)0x45, (byte)0x78, (byte)0x5d, (byte)0x= 8a, (byte)0x00, (byte)0x00 }, // 10^17 - { (byte)0x0d, (byte)0xe0, (byte)0xb6, (byte)0xb3, (byte)0xa7, (byte)0x= 64, (byte)0x00, (byte)0x00 }, // 10^18 - { (byte)0x8a, (byte)0xc7, (byte)0x23, (byte)0x04, (byte)0x89, (byte)0x= e8, (byte)0x00, (byte)0x00 }, // 10^19 - { (byte)0x05, (byte)0x6b, (byte)0xc7, (byte)0x5e, (byte)0x2d, (byte)0x= 63, (byte)0x10, (byte)0x00, (byte)0x00 }, // 10^20 - { (byte)0x36, (byte)0x35, (byte)0xc9, (byte)0xad, (byte)0xc5, (byte)0x= de, (byte)0xa0, (byte)0x00, (byte)0x00 }, // 10^21 - { (byte)0x02, (byte)0x1e, (byte)0x19, (byte)0xe0, (byte)0xc9, (byte)0x= ba, (byte)0xb2, (byte)0x40, (byte)0x00, (byte)0x00 }, // 10^22 - { (byte)0x15, (byte)0x2d, (byte)0x02, (byte)0xc7, (byte)0xe1, (byte)0x= 4a, (byte)0xf6, (byte)0x80, (byte)0x00, (byte)0x00 }, // 10^23 - { (byte)0xd3, (byte)0xc2, (byte)0x1b, (byte)0xce, (byte)0xcc, (byte)0x= ed, (byte)0xa1, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^24 - { (byte)0x08, (byte)0x45, (byte)0x95, (byte)0x16, (byte)0x14, (byte)0x= 01, (byte)0x48, (byte)0x4a, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^25 - { (byte)0x52, (byte)0xb7, (byte)0xd2, (byte)0xdc, (byte)0xc8, (byte)0x= 0c, (byte)0xd2, (byte)0xe4, (byte)0x00, (byte)0x00, (byte)0x00 }, // 10^26 - { (byte)0x03, (byte)0x3b, (byte)0x2e, (byte)0x3c, (byte)0x9f, (byte)0x= d0, (byte)0x80, (byte)0x3c, (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x00 = }, // 10^27 - { (byte)0x20, (byte)0x4f, (byte)0xce, (byte)0x5e, (byte)0x3e, (byte)0x= 25, (byte)0x02, (byte)0x61, (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x00 = }, // 10^28 - { (byte)0x01, (byte)0x43, (byte)0x1e, (byte)0x0f, (byte)0xae, (byte)0x= 6d, (byte)0x72, (byte)0x17, (byte)0xca, (byte)0xa0, (byte)0x00, (byte)0x00,= (byte)0x00 }, // 10^29 - { (byte)0x0c, (byte)0x9f, (byte)0x2c, (byte)0x9c, (byte)0xd0, (byte)0x= 46, (byte)0x74, (byte)0xed, (byte)0xea, (byte)0x40, (byte)0x00, (byte)0x00,= (byte)0x00 }, // 10^30 - { (byte)0x7e, (byte)0x37, (byte)0xbe, (byte)0x20, (byte)0x22, (byte)0x= c0, (byte)0x91, (byte)0x4b, (byte)0x26, (byte)0x80, (byte)0x00, (byte)0x00,= (byte)0x00 } // 10^31 - }; - - // If the input string is short, pad it with blanks. - // If the input string is long, truncate it. - static public String padOrTruncate (String s, int fixedLength) - { - if (s.length() >=3D fixedLength) // we need to truncate - return s.substring (0, fixedLength); - else { // we need to pad - StringBuffer buffer =3D new StringBuffer (s); - for (int i =3D 0; i < fixedLength - s.length(); i++) - buffer.append (" "); - return buffer.toString(); - } - } - - static public void checkForNegativePositiveSqlcard (Sqlca sqlca, Stateme= nt statement) throws SqlException - { - if (sqlca !=3D null) { - int sqlcode =3D sqlca.getSqlCode (); - if (sqlcode < 0) { - throw new SqlException (statement.agent_.logWriter_, sqlca); - } - else { - if (sqlcode > 0) - statement.accumulateWarning (new SqlWarning (statement.agent_.lo= gWriter_, sqlca)); - } - } - } - - static public void checkForNegativePositiveSqlcard (Sqlca sqlca, ResultS= et resultSet) throws SqlException - { - if (sqlca !=3D null) { - int sqlcode =3D sqlca.getSqlCode (); - if (sqlcode < 0) { - throw new SqlException (resultSet.agent_.logWriter_, sqlca); - } - else { - if (sqlcode > 0) - resultSet.accumulateWarning (new SqlWarning (resultSet.agent_.lo= gWriter_, sqlca)); - } - } - } - - static public int getSqlcodeFromSqlca (Sqlca sqlca) - { - if (sqlca =3D=3D null) - return 0; - return sqlca.getSqlCode(); - } - - static public int getUpdateCountFromSqlcard (Sqlca sqlca) - { - if (sqlca =3D=3D null) - return 0; - else - return sqlca.getUpdateCount(); - } - - public static int min (int i, int j) - { - return (i < j) ? i : j; - } - - public static int max (int i, int j) - { - return (i < j) ? j : i; - } - - // latestException is assumed to be non-null, accumulatedExceptions can = be null - public static SqlException accumulateSQLException (SqlException latestEx= ception, - SqlException accumula= tedExceptions) - { - if (accumulatedExceptions =3D=3D null) - return latestException; - else { - accumulatedExceptions.setNextException (latestException); - return accumulatedExceptions; - } - } - - // latestException is assumed to be non-null, accumulatedExceptions can = be null - public static SqlWarning accumulateSQLWarning (SqlWarning latestExceptio= n, - SqlWarning accumulatedE= xceptions) - { - latestException.setNextException (accumulatedExceptions); - return latestException; - } - - // just a thought... - static String getSQLTypeName (int sqlType) - { - switch (sqlType) { - case java.sql.Types.BIGINT: - return "BIGINT"; - case java.sql.Types.BINARY: - return "BINARY"; - case java.sql.Types.BIT: - return "BIT"; - case java.sql.Types.CHAR: - return "CHAR"; - case java.sql.Types.DATE: - return "DATE"; - case java.sql.Types.DECIMAL: - return "DECIMAL"; - case java.sql.Types.DOUBLE: - return "DOUBLE"; - case java.sql.Types.REAL: - return "REAL"; - case java.sql.Types.INTEGER: - return "INTEGER"; - case java.sql.Types.LONGVARBINARY: - return "LONGVARBINARY"; - case java.sql.Types.LONGVARCHAR: - return "LONGVARCHAR"; - case java.sql.Types.NULL: - return "NULL"; - case java.sql.Types.NUMERIC: - return "NUMERIC"; - case java.sql.Types.OTHER: - return "OTHER"; - case java.sql.Types.FLOAT: - return "FLOAT"; - case java.sql.Types.SMALLINT: - return "SMALLINT"; - case java.sql.Types.TIME: - return "TIME"; - case java.sql.Types.TIMESTAMP: - return "TIMESTAMP"; - case java.sql.Types.TINYINT: - return "TINYINT"; - case java.sql.Types.VARBINARY: - return "VARBINARY"; - case java.sql.Types.VARCHAR: - return "VARCHAR"; - default: - return null; - } - } - - public static boolean isSqlTypeNullable (int sqlType) - { - return (sqlType | 0x01) =3D=3D sqlType; - } - - public static int getNonNullableSqlType (int sqlType) - { - return sqlType & ~1; - } +public final class Utils { + + static String getStringFromBytes(byte[] bytes) { + if (bytes =3D=3D null) { + return "{}"; + } + StringBuffer stringBuffer =3D new StringBuffer(bytes.length * 6 + = 4); + stringBuffer.append("{ "); + for (int i =3D 0; i < bytes.length; i++) { + stringBuffer.append("0x"); + stringBuffer.append(Integer.toHexString(bytes[i] & 0xff)); + if (i !=3D bytes.length - 1) { + stringBuffer.append(", "); + } + } + stringBuffer.append(" }"); + return stringBuffer.toString(); + } + + static String getStringFromInts(int[] ints) { + if (ints =3D=3D null) { + return "{}"; + } + StringBuffer stringBuffer =3D new StringBuffer(); + stringBuffer.append("{ "); + for (int i =3D 0; i < ints.length; i++) { + stringBuffer.append(String.valueOf(ints[i])); + if (i !=3D ints.length - 1) { + stringBuffer.append(", "); + } + } + stringBuffer.append(" }"); + return stringBuffer.toString(); + } + + static String getStringFromStrings(String[] strings) { + if (strings =3D=3D null) { + return "{}"; + } + StringBuffer stringBuffer =3D new StringBuffer(); + stringBuffer.append("{ "); + for (int i =3D 0; i < strings.length; i++) { + stringBuffer.append(strings[i]); + if (i !=3D strings.length - 1) { + stringBuffer.append(", "); + } + } + stringBuffer.append(" }"); + return stringBuffer.toString(); + } + + static public int computeBigDecimalPrecision(java.math.BigDecimal deci= mal) { + byte[] bBytes =3D decimal.unscaledValue().abs().toByteArray(); + + if (byteArrayCmp(bBytes, tenRadixArr[tenRadixArr.length - 1]) >=3D= 0) { + throw new java.lang.IllegalArgumentException("Precision exceed= s 31 digits!"); + } + + int lo =3D 0, hi =3D tenRadixArr.length - 1, mi =3D (hi + lo) / 2; + do { + int compare =3D byteArrayCmp(bBytes, tenRadixArr[mi]); + if (compare =3D=3D 1) { + lo =3D mi; + } else if (compare =3D=3D -1) { + hi =3D mi; + } else { + break; + } + + mi =3D (hi + lo) / 2; + } while (mi !=3D lo); + + return (mi + 1); + } + + // Used only by computeBigDecimalPrecision() + private static int byteArrayCmp(byte[] arg1, byte[] arg2) { + int arg1Offset =3D 0; + int arg2Offset =3D 0; + int length; + if (arg1.length > arg2.length) { + int diff =3D arg1.length - arg2.length; + for (; arg1Offset < diff; arg1Offset++) { + if (arg1[arg1Offset] !=3D 0) { + return 1; + } + } + length =3D arg2.length; + } else if (arg1.length < arg2.length) { + int diff =3D arg2.length - arg1.length; + for (; arg2Offset < diff; arg2Offset++) { + if (arg2[arg2Offset] !=3D 0) { + return -1; + } + } + length =3D arg1.length; + } else { + length =3D arg1.length; + } + + for (int i =3D 0; i < length; i++) { + int b1 =3D arg1[arg1Offset + i] & 0xFF; + int b2 =3D arg2[arg2Offset + i] & 0xFF; + if (b1 > b2) { + return 1; + } else if (b1 < b2) { + return -1; + } + } + return 0; + } + + // Used only by computeBigDecimalPrecision() + // byte array of 1, 10, 100, 1000, 10000, ..., 10^31 for + // fast computing the length a BigDecimal. + private static byte[][] tenRadixArr =3D { + {(byte) 0x01}, // 10^0 + {(byte) 0x0A}, // 10^1 + {(byte) 0x64}, // 10^2 + {(byte) 0x03, (byte) 0xe8}, // 10^3 + {(byte) 0x27, (byte) 0x10}, // 10^4 + {(byte) 0x01, (byte) 0x86, (byte) 0xa0}, // 10^5 + {(byte) 0x0f, (byte) 0x42, (byte) 0x40}, // 10^6 + {(byte) 0x98, (byte) 0x96, (byte) 0x80}, // 10^7 + {(byte) 0x05, (byte) 0xf5, (byte) 0xe1, (byte) 0x00}, // 10^8 + {(byte) 0x3b, (byte) 0x9a, (byte) 0xca, (byte) 0x00}, // 10^9 + {(byte) 0x02, (byte) 0x54, (byte) 0x0b, (byte) 0xe4, (byte) 0x00},= // 10^10 + {(byte) 0x17, (byte) 0x48, (byte) 0x76, (byte) 0xe8, (byte) 0x00},= // 10^11 + {(byte) 0xe8, (byte) 0xd4, (byte) 0xa5, (byte) 0x10, (byte) 0x00},= // 10^12 + {(byte) 0x09, (byte) 0x18, (byte) 0x4e, (byte) 0x72, (byte) 0xa0, = (byte) 0x00}, // 10^13 + {(byte) 0x5a, (byte) 0xf3, (byte) 0x10, (byte) 0x7a, (byte) 0x40, = (byte) 0x00}, // 10^14 + {(byte) 0x03, (byte) 0x8d, (byte) 0x7e, (byte) 0xa4, (byte) 0xc6, = (byte) 0x80, (byte) 0x00}, // 10^15 + {(byte) 0x23, (byte) 0x86, (byte) 0xf2, (byte) 0x6f, (byte) 0xc1, = (byte) 0x00, (byte) 0x00}, // 10^16 + {(byte) 0x01, (byte) 0x63, (byte) 0x45, (byte) 0x78, (byte) 0x5d, = (byte) 0x8a, (byte) 0x00, (byte) 0x00}, // 10^17 + {(byte) 0x0d, (byte) 0xe0, (byte) 0xb6, (byte) 0xb3, (byte) 0xa7, = (byte) 0x64, (byte) 0x00, (byte) 0x00}, // 10^18 + {(byte) 0x8a, (byte) 0xc7, (byte) 0x23, (byte) 0x04, (byte) 0x89, = (byte) 0xe8, (byte) 0x00, (byte) 0x00}, // 10^19 + {(byte) 0x05, (byte) 0x6b, (byte) 0xc7, (byte) 0x5e, (byte) 0x2d, = (byte) 0x63, (byte) 0x10, (byte) 0x00, (byte) 0x00}, // 10^20 + {(byte) 0x36, (byte) 0x35, (byte) 0xc9, (byte) 0xad, (byte) 0xc5, = (byte) 0xde, (byte) 0xa0, (byte) 0x00, (byte) 0x00}, // 10^21 + {(byte) 0x02, (byte) 0x1e, (byte) 0x19, (byte) 0xe0, (byte) 0xc9, = (byte) 0xba, (byte) 0xb2, (byte) 0x40, (byte) 0x00, (byte) 0x00}, // 10^22 + {(byte) 0x15, (byte) 0x2d, (byte) 0x02, (byte) 0xc7, (byte) 0xe1, = (byte) 0x4a, (byte) 0xf6, (byte) 0x80, (byte) 0x00, (byte) 0x00}, // 10^23 + {(byte) 0xd3, (byte) 0xc2, (byte) 0x1b, (byte) 0xce, (byte) 0xcc, = (byte) 0xed, (byte) 0xa1, (byte) 0x00, (byte) 0x00, (byte) 0x00}, // 10^24 + {(byte) 0x08, (byte) 0x45, (byte) 0x95, (byte) 0x16, (byte) 0x14, = (byte) 0x01, (byte) 0x48, (byte) 0x4a, (byte) 0x00, (byte) 0x00, (byte) 0x0= 0}, // 10^25 + {(byte) 0x52, (byte) 0xb7, (byte) 0xd2, (byte) 0xdc, (byte) 0xc8, = (byte) 0x0c, (byte) 0xd2, (byte) 0xe4, (byte) 0x00, (byte) 0x00, (byte) 0x0= 0}, // 10^26 + {(byte) 0x03, (byte) 0x3b, (byte) 0x2e, (byte) 0x3c, (byte) 0x9f, = (byte) 0xd0, (byte) 0x80, (byte) 0x3c, (byte) 0xe8, (byte) 0x00, (byte) 0x0= 0, (byte) 0x00}, // 10^27 + {(byte) 0x20, (byte) 0x4f, (byte) 0xce, (byte) 0x5e, (byte) 0x3e, = (byte) 0x25, (byte) 0x02, (byte) 0x61, (byte) 0x10, (byte) 0x00, (byte) 0x0= 0, (byte) 0x00}, // 10^28 + {(byte) 0x01, (byte) 0x43, (byte) 0x1e, (byte) 0x0f, (byte) 0xae, = (byte) 0x6d, (byte) 0x72, (byte) 0x17, (byte) 0xca, (byte) 0xa0, (byte) 0x0= 0, (byte) 0x00, (byte) 0x00}, // 10^29 + {(byte) 0x0c, (byte) 0x9f, (byte) 0x2c, (byte) 0x9c, (byte) 0xd0, = (byte) 0x46, (byte) 0x74, (byte) 0xed, (byte) 0xea, (byte) 0x40, (byte) 0x0= 0, (byte) 0x00, (byte) 0x00}, // 10^30 + {(byte) 0x7e, (byte) 0x37, (byte) 0xbe, (byte) 0x20, (byte) 0x22, = (byte) 0xc0, (byte) 0x91, (byte) 0x4b, (byte) 0x26, (byte) 0x80, (byte) 0x0= 0, (byte) 0x00, (byte) 0x00} // 10^31 + }; + + // If the input string is short, pad it with blanks. + // If the input string is long, truncate it. + static public String padOrTruncate(String s, int fixedLength) { + if (s.length() >=3D fixedLength) // we need to truncate + { + return s.substring(0, fixedLength); + } else { // we need to pad + StringBuffer buffer =3D new StringBuffer(s); + for (int i =3D 0; i < fixedLength - s.length(); i++) { + buffer.append(" "); + } + return buffer.toString(); + } + } + + static public void checkForNegativePositiveSqlcard(Sqlca sqlca, Statem= ent statement) throws SqlException { + if (sqlca !=3D null) { + int sqlcode =3D sqlca.getSqlCode(); + if (sqlcode < 0) { + throw new SqlException(statement.agent_.logWriter_, sqlca); + } else { + if (sqlcode > 0) { + statement.accumulateWarning(new SqlWarning(statement.a= gent_.logWriter_, sqlca)); + } + } + } + } + + static public void checkForNegativePositiveSqlcard(Sqlca sqlca, Result= Set resultSet) throws SqlException { + if (sqlca !=3D null) { + int sqlcode =3D sqlca.getSqlCode(); + if (sqlcode < 0) { + throw new SqlException(resultSet.agent_.logWriter_, sqlca); + } else { + if (sqlcode > 0) { + resultSet.accumulateWarning(new SqlWarning(resultSet.a= gent_.logWriter_, sqlca)); + } + } + } + } + + static public int getSqlcodeFromSqlca(Sqlca sqlca) { + if (sqlca =3D=3D null) { + return 0; + } + return sqlca.getSqlCode(); + } + + static public int getUpdateCountFromSqlcard(Sqlca sqlca) { + if (sqlca =3D=3D null) { + return 0; + } else { + return sqlca.getUpdateCount(); + } + } + + public static int min(int i, int j) { + return (i < j) ? i : j; + } + + public static int max(int i, int j) { + return (i < j) ? j : i; + } + + // latestException is assumed to be non-null, accumulatedExceptions ca= n be null + public static SqlException accumulateSQLException(SqlException latestE= xception, + SqlException accumul= atedExceptions) { + if (accumulatedExceptions =3D=3D null) { + return latestException; + } else { + accumulatedExceptions.setNextException(latestException); + return accumulatedExceptions; + } + } + + // latestException is assumed to be non-null, accumulatedExceptions ca= n be null + public static SqlWarning accumulateSQLWarning(SqlWarning latestExcepti= on, + SqlWarning accumulatedEx= ceptions) { + latestException.setNextException(accumulatedExceptions); + return latestException; + } + + // just a thought... + static String getSQLTypeName(int sqlType) { + switch (sqlType) { + case java.sql.Types.BIGINT: + return "BIGINT"; + case java.sql.Types.BINARY: + return "BINARY"; + case java.sql.Types.BIT: + return "BIT"; + case java.sql.Types.CHAR: + return "CHAR"; + case java.sql.Types.DATE: + return "DATE"; + case java.sql.Types.DECIMAL: + return "DECIMAL"; + case java.sql.Types.DOUBLE: + return "DOUBLE"; + case java.sql.Types.REAL: + return "REAL"; + case java.sql.Types.INTEGER: + return "INTEGER"; + case java.sql.Types.LONGVARBINARY: + return "LONGVARBINARY"; + case java.sql.Types.LONGVARCHAR: + return "LONGVARCHAR"; + case java.sql.Types.NULL: + return "NULL"; + case java.sql.Types.NUMERIC: + return "NUMERIC"; + case java.sql.Types.OTHER: + return "OTHER"; + case java.sql.Types.FLOAT: + return "FLOAT"; + case java.sql.Types.SMALLINT: + return "SMALLINT"; + case java.sql.Types.TIME: + return "TIME"; + case java.sql.Types.TIMESTAMP: + return "TIMESTAMP"; + case java.sql.Types.TINYINT: + return "TINYINT"; + case java.sql.Types.VARBINARY: + return "VARBINARY"; + case java.sql.Types.VARCHAR: + return "VARCHAR"; + default: + return null; + } + } + + public static boolean isSqlTypeNullable(int sqlType) { + return (sqlType | 0x01) =3D=3D sqlType; + } + + public static int getNonNullableSqlType(int sqlType) { + return sqlType & ~1; + } } Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am= /Version.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/Version.java?rev=3D165585&r1=3D165584&r2=3D165585= &view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Versi= on.java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/Versi= on.java Sun May 1 23:25:59 2005 @@ -19,160 +19,151 @@ */ =20 package org.apache.derby.client.am; -import org.apache.derby.iapi.services.info.ProductVersionHolder; =20 -public abstract class Version -{ - // Same as java.sql.DatabaseMetaData.getDriverName() - public static String getDriverName () - { return Configuration.dncDriverName; } - - // for DatabaseMetaData.getDriverVersion() - public static String getDriverVersion() - { - return Configuration.dncProductVersionHolder__.getVersionBuildString(fals= e); - } - - - // Same as java.sql.Driver.getMajorVersion(), getMinorVersion() - public static int getMajorVersion() - { - return Configuration.getProductVersionHolder().getMajorVersion(); - } - - public static int getMinorVersion() - { - return Configuration.getProductVersionHolder().getMinorVersion(); - } - - public static int getBuildNumber() - { - return Configuration.getProductVersionHolder().getBuildNumberAsInt(); - } - - public static int getProtocolMaintVersion() - { - return Configuration.getProductVersionHolder().getDrdaMaintVersion(); - } - =20 - public static boolean isAlpha() - { - return Configuration.getProductVersionHolder().isAlpha(); - } - - public static boolean isBeta() - { - return Configuration.getProductVersionHolder().isBeta(); - } - - // Not an external, just a helper method - private static String getDriverNameAndVersion () - { - return Configuration.dncDriverName + " " +=20 - Configuration.dncProductVersionHolder__.getVersionBuildString(true); - } - - // -------------------------- configuration print stream ---------------= ------ - - public static void writeDriverConfiguration (java.io.PrintWriter printWr= iter) - { - String header =3D "[derby] "; - synchronized (printWriter) { - printWriter.println (header + "BEGIN TRACE_DRIVER_CONFIGURATION"); - printWriter.println (header + "Driver: " + getDriverNameAndVersion (= )); - - printWriter.print (header + "Compatible JRE versions: { "); - for (int i=3D0; i < Configuration.dncCompatibleJREVersions.length; i= ++) { - printWriter.print (Configuration.dncCompatibleJREVersions[i]); - if (i !=3D Configuration.dncCompatibleJREVersions.length - 1) - printWriter.print (", "); - } - printWriter.println (" }"); - - printWriter.println (header + "Range checking enabled: " + Configura= tion.rangeCheckCrossConverters); - printWriter.println (header + "Bug check level: 0x" + Integer.toHexS= tring (Configuration.bugCheckLevel)); - printWriter.println (header + "Default fetch size: " + Configuration= .defaultFetchSize); - printWriter.println (header + "Default isolation: " + Configuration.= defaultIsolation); - - java.lang.SecurityManager security =3D java.lang.System.getSecurityM= anager (); - if (security =3D=3D null) - printWriter.println (header + "No security manager detected."); - else - printWriter.println (header + "Security manager detected."); - - detectLocalHost (java.lang.System.getSecurityManager (), printWriter= ); - - printSystemProperty (security, "JDBC 1 system property jdbc.drivers = =3D ", "jdbc.drivers", printWriter); - - printSystemProperty (security, "Java Runtime Environment version ", = "java.version", printWriter); - printSystemProperty (security, "Java Runtime Environment vendor =3D = ", "java.vendor", printWriter); - printSystemProperty (security, "Java vendor URL =3D ", "java.vendor.= url", printWriter); - printSystemProperty (security, "Java installation directory =3D ", "= java.home", printWriter); - printSystemProperty (security, "Java Virtual Machine specification v= ersion =3D ", "java.vm.specification.version", printWriter); - printSystemProperty (security, "Java Virtual Machine specification v= endor =3D ", "java.vm.specification.vendor", printWriter); - printSystemProperty (security, "Java Virtual Machine specification n= ame =3D ", "java.vm.specification.name", printWriter); - printSystemProperty (security, "Java Virtual Machine implementation = version =3D ", "java.vm.version", printWriter); - printSystemProperty (security, "Java Virtual Machine implementation = vendor =3D ", "java.vm.vendor", printWriter); - printSystemProperty (security, "Java Virtual Machine implementation = name =3D ", "java.vm.name", printWriter); - printSystemProperty (security, "Java Runtime Environment specificati= on version =3D ", "java.specification.version", printWriter); - printSystemProperty (security, "Java Runtime Environment specificati= on vendor =3D ", "java.specification.vendor", printWriter); - printSystemProperty (security, "Java Runtime Environment specificati= on name =3D ", "java.specification.name", printWriter); - printSystemProperty (security, "Java class format version number =3D= ", "java.class.version", printWriter); - printSystemProperty (security, "Java class path =3D ", "java.class.p= ath", printWriter); - printSystemProperty (security, "Java native library path =3D ", "jav= a=2Elibrary.path", printWriter); - printSystemProperty (security, "Path of extension directory or direc= tories =3D ", "java.ext.dirs", printWriter); - printSystemProperty (security, "Operating system name =3D ", "os.nam= e", printWriter); - printSystemProperty (security, "Operating system architecture =3D ",= "os.arch", printWriter); - printSystemProperty (security, "Operating system version =3D ", "os.= version", printWriter); - printSystemProperty (security, "File separator (\"/\" on UNIX) =3D "= , "file.separator", printWriter); - printSystemProperty (security, "Path separator (\":\" on UNIX) =3D "= , "path.separator", printWriter); - printSystemProperty (security, "User's account name =3D ", "user.nam= e", printWriter); - printSystemProperty (security, "User's home directory =3D ", "user.h= ome", printWriter); - printSystemProperty (security, "User's current working directory =3D= ", "user.dir", printWriter); - printWriter.println (header + "END TRACE_DRIVER_CONFIGURATION"); - printWriter.flush(); - } - } - - private static void printSystemProperty (java.lang.SecurityManager secur= ity, - String prefix, - String property, - java.io.PrintWriter printWriter) - { - String header =3D "[derby] "; - synchronized (printWriter) { - try { - if (security !=3D null) - security.checkPropertyAccess (property); - String result =3D System.getProperty (property); - printWriter.println (header + prefix + result); - printWriter.flush(); - } - catch (SecurityException e) { - printWriter.println (header + "Security manager does not permit ac= cess to system property " + property); - printWriter.flush(); - } - } - } - - // printWriter synchronized by caller - private static void detectLocalHost (java.lang.SecurityManager security,= java.io.PrintWriter printWriter) - { - String header =3D "[derby] "; - // getLocalHost() will hang the HotJava 1.0 browser with a high securi= ty manager. - if (security =3D=3D null) { - try { - printWriter.print (header + "Detected local client host: "); - printWriter.println (java.net.InetAddress.getLocalHost().toString = ()); - printWriter.flush(); - } - catch (java.net.UnknownHostException e) { - printWriter.print (header + "Detected an improper TCP/IP client co= nfiguration."); - printWriter.print (header + "Unable to determine the IP address of= your local host: "); - printWriter.print (e.getMessage ()); - printWriter.println (header + "Make sure your client machine has a= properly configured IP address."); - printWriter.flush(); - } + + +public abstract class Version { + // Same as java.sql.DatabaseMetaData.getDriverName() + public static String getDriverName() { + return Configuration.dncDriverName; + } + + // for DatabaseMetaData.getDriverVersion() + public static String getDriverVersion() { + return Configuration.dncProductVersionHolder__.getVersionBuildStri= ng(false); + } + + + // Same as java.sql.Driver.getMajorVersion(), getMinorVersion() + public static int getMajorVersion() { + return Configuration.getProductVersionHolder().getMajorVersion(); + } + + public static int getMinorVersion() { + return Configuration.getProductVersionHolder().getMinorVersion(); + } + + public static int getBuildNumber() { + return Configuration.getProductVersionHolder().getBuildNumberAsInt= (); + } + + public static int getProtocolMaintVersion() { + return Configuration.getProductVersionHolder().getDrdaMaintVersion= (); + } + + public static boolean isAlpha() { + return Configuration.getProductVersionHolder().isAlpha(); + } + + public static boolean isBeta() { + return Configuration.getProductVersionHolder().isBeta(); + } + + // Not an external, just a helper method + private static String getDriverNameAndVersion() { + return Configuration.dncDriverName + " " + + Configuration.dncProductVersionHolder__.getVersionBuildStr= ing(true); + } + + // -------------------------- configuration print stream -------------= -------- + + public static void writeDriverConfiguration(java.io.PrintWriter printW= riter) { + String header =3D "[derby] "; + synchronized (printWriter) { + printWriter.println(header + "BEGIN TRACE_DRIVER_CONFIGURATION= "); + printWriter.println(header + "Driver: " + getDriverNameAndVers= ion()); + + printWriter.print(header + "Compatible JRE versions: { "); + for (int i =3D 0; i < Configuration.dncCompatibleJREVersions.l= ength; i++) { + printWriter.print(Configuration.dncCompatibleJREVersions[i= ]); + if (i !=3D Configuration.dncCompatibleJREVersions.length -= 1) { + printWriter.print(", "); + } + } + printWriter.println(" }"); + + printWriter.println(header + "Range checking enabled: " + Conf= iguration.rangeCheckCrossConverters); + printWriter.println(header + "Bug check level: 0x" + Integer.t= oHexString(Configuration.bugCheckLevel)); + printWriter.println(header + "Default fetch size: " + Configur= ation.defaultFetchSize); + printWriter.println(header + "Default isolation: " + Configura= tion.defaultIsolation); + + java.lang.SecurityManager security =3D java.lang.System.getSec= urityManager(); + if (security =3D=3D null) { + printWriter.println(header + "No security manager detected= ."); + } else { + printWriter.println(header + "Security manager detected."); + } + + detectLocalHost(java.lang.System.getSecurityManager(), printWr= iter); + + printSystemProperty(security, "JDBC 1 system property jdbc.dri= vers =3D ", "jdbc.drivers", printWriter); + + printSystemProperty(security, "Java Runtime Environment versio= n ", "java.version", printWriter); + printSystemProperty(security, "Java Runtime Environment vendor= =3D ", "java.vendor", printWriter); + printSystemProperty(security, "Java vendor URL =3D ", "java.ve= ndor.url", printWriter); + printSystemProperty(security, "Java installation directory =3D= ", "java.home", printWriter); + printSystemProperty(security, "Java Virtual Machine specificat= ion version =3D ", "java.vm.specification.version", printWriter); + printSystemProperty(security, "Java Virtual Machine specificat= ion vendor =3D ", "java.vm.specification.vendor", printWriter); + printSystemProperty(security, "Java Virtual Machine specificat= ion name =3D ", "java.vm.specification.name", printWriter); + printSystemProperty(security, "Java Virtual Machine implementa= tion version =3D ", "java.vm.version", printWriter); + printSystemProperty(security, "Java Virtual Machine implementa= tion vendor =3D ", "java.vm.vendor", printWriter); + printSystemProperty(security, "Java Virtual Machine implementa= tion name =3D ", "java.vm.name", printWriter); + printSystemProperty(security, "Java Runtime Environment specif= ication version =3D ", "java.specification.version", printWriter); + printSystemProperty(security, "Java Runtime Environment specif= ication vendor =3D ", "java.specification.vendor", printWriter); + printSystemProperty(security, "Java Runtime Environment specif= ication name =3D ", "java.specification.name", printWriter); + printSystemProperty(security, "Java class format version numbe= r =3D ", "java.class.version", printWriter); + printSystemProperty(security, "Java class path =3D ", "java.cl= ass.path", printWriter); + printSystemProperty(security, "Java native library path =3D ",= "java.library.path", printWriter); + printSystemProperty(security, "Path of extension directory or = directories =3D ", "java.ext.dirs", printWriter); + printSystemProperty(security, "Operating system name =3D ", "o= s=2Ename", printWriter); + printSystemProperty(security, "Operating system architecture = =3D ", "os.arch", printWriter); + printSystemProperty(security, "Operating system version =3D ",= "os.version", printWriter); + printSystemProperty(security, "File separator (\"/\" on UNIX) = =3D ", "file.separator", printWriter); + printSystemProperty(security, "Path separator (\":\" on UNIX) = =3D ", "path.separator", printWriter); + printSystemProperty(security, "User's account name =3D ", "use= r=2Ename", printWriter); + printSystemProperty(security, "User's home directory =3D ", "u= ser.home", printWriter); + printSystemProperty(security, "User's current working director= y =3D ", "user.dir", printWriter); + printWriter.println(header + "END TRACE_DRIVER_CONFIGURATION"); + printWriter.flush(); + } + } + + private static void printSystemProperty(java.lang.SecurityManager secu= rity, + String prefix, + String property, + java.io.PrintWriter printWrite= r) { + String header =3D "[derby] "; + synchronized (printWriter) { + try { + if (security !=3D null) { + security.checkPropertyAccess(property); + } + String result =3D System.getProperty(property); + printWriter.println(header + prefix + result); + printWriter.flush(); + } catch (SecurityException e) { + printWriter.println(header + "Security manager does not pe= rmit access to system property " + property); + printWriter.flush(); + } + } + } + + // printWriter synchronized by caller + private static void detectLocalHost(java.lang.SecurityManager security= , java.io.PrintWriter printWriter) { + String header =3D "[derby] "; + // getLocalHost() will hang the HotJava 1.0 browser with a high se= curity manager. + if (security =3D=3D null) { + try { + printWriter.print(header + "Detected local client host: "); + printWriter.println(java.net.InetAddress.getLocalHost().to= String()); + printWriter.flush(); + } catch (java.net.UnknownHostException e) { + printWriter.print(header + "Detected an improper TCP/IP cl= ient configuration."); + printWriter.print(header + "Unable to determine the IP add= ress of your local host: "); + printWriter.print(e.getMessage()); + printWriter.println(header + "Make sure your client machin= e has a properly configured IP address."); + printWriter.flush(); + } + } } - } } Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/am= /XaException.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/am/XaException.java?rev=3D165585&r1=3D165584&r2=3D16= 5585&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/am/XaExc= eption.java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/am/XaExc= eption.java Sun May 1 23:25:59 2005 @@ -21,95 +21,93 @@ package org.apache.derby.client.am; =20 =20 -public class XaException extends javax.transaction.xa.XAException implemen= ts Diagnosable -{ - java.lang.Throwable throwable_ =3D null; - - //-----------------constructors-----------------------------------------= ------ - - public XaException (LogWriter logWriter) - { - super (); - if (logWriter !=3D null) logWriter.traceDiagnosable (this); - } - - public XaException (LogWriter logWriter, java.lang.Throwable throwable) - { - super (); - throwable_ =3D throwable; - if( ((org.apache.derby.client.am.Configuration.jreLevelMajor =3D=3D 1)= && - (org.apache.derby.client.am.Configuration.jreLevelMinor >=3D 4)) = || - (org.apache.derby.client.am.Configuration.jreLevelMajor > 1) ) - { // jre 1.4 or above, init the cause - initCause( throwable ); - } - if (logWriter !=3D null) logWriter.traceDiagnosable (this); - } - - public XaException (LogWriter logWriter, int errcode) - { - super (); - errorCode =3D errcode; - if (logWriter !=3D null) logWriter.traceDiagnosable (this); - } - - public XaException (LogWriter logWriter, java.lang.Throwable throwable, = int errcode) - { - super (); - errorCode =3D errcode; - throwable_ =3D throwable; - if( ((org.apache.derby.client.am.Configuration.jreLevelMajor =3D=3D 1)= && - (org.apache.derby.client.am.Configuration.jreLevelMinor >=3D 4)) = || - (org.apache.derby.client.am.Configuration.jreLevelMajor > 1) ) - { // jre 1.4 or above, init the cause - initCause( throwable ); - } - if (logWriter !=3D null) logWriter.traceDiagnosable (this); - } - - public XaException (LogWriter logWriter, String s) - { - super (s); - if (logWriter !=3D null) logWriter.traceDiagnosable (this); - } - - public XaException (LogWriter logWriter, java.lang.Throwable throwable, = String s) - { - super (s); - throwable_ =3D throwable; - if( ((org.apache.derby.client.am.Configuration.jreLevelMajor =3D=3D 1)= && - (org.apache.derby.client.am.Configuration.jreLevelMinor >=3D 4)) = || - (org.apache.derby.client.am.Configuration.jreLevelMajor > 1) ) - { // jre 1.4 or above, init the cause - initCause( throwable ); - } - if (logWriter !=3D null) logWriter.traceDiagnosable (this); - } - - public Sqlca getSqlca () - { - return null; - } - - public java.lang.Throwable getThrowable () - { - return throwable_; - } - - public void printTrace (java.io.PrintWriter printWriter, String header) - { - ExceptionFormatter.printTrace (this, printWriter, header); - } - - // Return a single XaException without the "next" pointing to another SQ= LException. - // Because the "next" is a private field in java.sql.SQLException, - // we have to create a new XaException in order to break the chain with = "next" as null. - XaException copyAsUnchainedXAException (LogWriter logWriter) - { - XaException xae =3D new XaException (logWriter, this.getThrowable(), g= etMessage()); // client error - xae.errorCode =3D this.errorCode; - return xae; - } +public class XaException extends javax.transaction.xa.XAException implemen= ts Diagnosable { + java.lang.Throwable throwable_ =3D null; + + //-----------------constructors---------------------------------------= -------- + + public XaException(LogWriter logWriter) { + super(); + if (logWriter !=3D null) { + logWriter.traceDiagnosable(this); + } + } + + public XaException(LogWriter logWriter, java.lang.Throwable throwable)= { + super(); + throwable_ =3D throwable; + if (((org.apache.derby.client.am.Configuration.jreLevelMajor =3D= =3D 1) && + (org.apache.derby.client.am.Configuration.jreLevelMinor >= =3D 4)) || + (org.apache.derby.client.am.Configuration.jreLevelMajor > = 1)) { // jre 1.4 or above, init the cause + initCause(throwable); + } + if (logWriter !=3D null) { + logWriter.traceDiagnosable(this); + } + } + + public XaException(LogWriter logWriter, int errcode) { + super(); + errorCode =3D errcode; + if (logWriter !=3D null) { + logWriter.traceDiagnosable(this); + } + } + + public XaException(LogWriter logWriter, java.lang.Throwable throwable,= int errcode) { + super(); + errorCode =3D errcode; + throwable_ =3D throwable; + if (((org.apache.derby.client.am.Configuration.jreLevelMajor =3D= =3D 1) && + (org.apache.derby.client.am.Configuration.jreLevelMinor >= =3D 4)) || + (org.apache.derby.client.am.Configuration.jreLevelMajor > = 1)) { // jre 1.4 or above, init the cause + initCause(throwable); + } + if (logWriter !=3D null) { + logWriter.traceDiagnosable(this); + } + } + + public XaException(LogWriter logWriter, String s) { + super(s); + if (logWriter !=3D null) { + logWriter.traceDiagnosable(this); + } + } + + public XaException(LogWriter logWriter, java.lang.Throwable throwable,= String s) { + super(s); + throwable_ =3D throwable; + if (((org.apache.derby.client.am.Configuration.jreLevelMajor =3D= =3D 1) && + (org.apache.derby.client.am.Configuration.jreLevelMinor >= =3D 4)) || + (org.apache.derby.client.am.Configuration.jreLevelMajor > = 1)) { // jre 1.4 or above, init the cause + initCause(throwable); + } + if (logWriter !=3D null) { + logWriter.traceDiagnosable(this); + } + } + + public Sqlca getSqlca() { + return null; + } + + public java.lang.Throwable getThrowable() { + return throwable_; + } + + public void printTrace(java.io.PrintWriter printWriter, String header)= { + ExceptionFormatter.printTrace(this, printWriter, header); + } + + // Return a single XaException without the "next" pointing to another = SQLException. + // Because the "next" is a private field in java.sql.SQLException, + // we have to create a new XaException in order to break the chain wit= h "next" as null. + XaException copyAsUnchainedXAException(LogWriter logWriter) { + XaException xae =3D new XaException(logWriter, this.getThrowable()= , getMessage()); // client error + xae.errorCode =3D this.errorCode; + return xae; + } } =20 =20 Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/ne= t/CcsidManager.java URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/o= rg/apache/derby/client/net/CcsidManager.java?rev=3D165585&r1=3D165584&r2=3D= 165585&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/Ccsi= dManager.java (original) +++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/Ccsi= dManager.java Sun May 1 23:25:59 2005 @@ -22,72 +22,71 @@ =20 // Performs character conversions as required to send and receive PROTOCOL= control data. // User data uses the JVM's built in converters, i18n.jar, -public abstract class CcsidManager -{ - public byte space_; // ' ' character - byte dot_; // '.' character - - // Byte array used to convert numbers into - // bytes containing the character representation "value" for the particu= lar ccsid. - byte[] numToCharRepresentation_; - - // Special byte array to convert first half byte of CRRTKNs TCPIP addres= s and port number - // to a character. This is required for SNA hopping. - // This was specifically added to help build the CRRTKNs. - byte[] numToSnaRequiredCrrtknChar_; - - CcsidManager (byte space, - byte dot, - byte[] numToCharRepresentation, - byte[] numToSnaRequiredCrrtknChar) - { - space_ =3D space; - dot_ =3D dot; - numToCharRepresentation_ =3D numToCharRepresentation; - numToSnaRequiredCrrtknChar_ =3D numToSnaRequiredCrrtknChar; - } - - - // Convert a Java String into bytes for a particular ccsid. - // - // @param sourceString A Java String to convert. - // @return A new byte array representing the String in a particular ccsi= d=2E - public abstract byte[] convertFromUCS2 (String sourceString, org.apache.= derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException; - - - // Convert a Java String into bytes for a particular ccsid. - // The String is converted into a buffer provided by the caller. - // - // @param sourceString A Java String to convert. - // @param buffer The buffer to convert the String into. - // @param offset Offset in buffer to start putting output. - // @return An int containing the buffer offset after conversion. - public abstract int convertFromUCS2 (String sourceString, - byte[] buffer, - int offset, - org.apache.derby.client.am.Agent agent) th= rows org.apache.derby.client.am.SqlException; - - // Convert a byte array representing characters in a particular ccsid in= to a Java String. - // - // @param sourceBytes An array of bytes to be converted. - // @return String A new Java String Object created after conversion. - abstract String convertToUCS2 (byte[] sourceBytes); - - - // Convert a byte array representing characters in a particular ccsid in= to a Java String. - // - // @param sourceBytes An array of bytes to be converted. - // @param offset An offset indicating first byte to convert. - // @param numToConvert The number of bytes to be converted. - // @return A new Java String Object created after conversion. - abstract String convertToUCS2 (byte[] sourceBytes, int offset, int numTo= Convert); - - - // Convert a byte representing a char in a particular ccsid into a Java = char. - // - // @param sourceByte The byte to be converted - // @return The converted Java char. - abstract char convertToUCS2Char (byte sourceByte); + +public abstract class CcsidManager { + public byte space_; // ' ' character + byte dot_; // '.' character + + // Byte array used to convert numbers into + // bytes containing the character representation "value" for the parti= cular ccsid. + byte[] numToCharRepresentation_; + + // Special byte array to convert first half byte of CRRTKNs TCPIP addr= ess and port number + // to a character. This is required for SNA hopping. + // This was specifically added to help build the CRRTKNs. + byte[] numToSnaRequiredCrrtknChar_; + + CcsidManager(byte space, + byte dot, + byte[] numToCharRepresentation, + byte[] numToSnaRequiredCrrtknChar) { + space_ =3D space; + dot_ =3D dot; + numToCharRepresentation_ =3D numToCharRepresentation; + numToSnaRequiredCrrtknChar_ =3D numToSnaRequiredCrrtknChar; + } + + + // Convert a Java String into bytes for a particular ccsid. + // + // @param sourceString A Java String to convert. + // @return A new byte array representing the String in a particular cc= sid. + public abstract byte[] convertFromUCS2(String sourceString, org.apache= .derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlExceptio= n; + + + // Convert a Java String into bytes for a particular ccsid. + // The String is converted into a buffer provided by the caller. + // + // @param sourceString A Java String to convert. + // @param buffer The buffer to convert the String into. + // @param offset Offset in buffer to start putting output. + // @return An int containing the buffer offset after conversion. + public abstract int convertFromUCS2(String sourceString, + byte[] buffer, + int offset, + org.apache.derby.client.am.Agent a= gent) throws org.apache.derby.client.am.SqlException; + + // Convert a byte array representing characters in a particular ccsid = into a Java String. + // + // @param sourceBytes An array of bytes to be converted. + // @return String A new Java String Object created after conversion. + abstract String convertToUCS2(byte[] sourceBytes); + + + // Convert a byte array representing characters in a particular ccsid = into a Java String. + // + // @param sourceBytes An array of bytes to be converted. + // @param offset An offset indicating first byte to convert. + // @param numToConvert The number of bytes to be converted. + // @return A new Java String Object created after conversion. + abstract String convertToUCS2(byte[] sourceBytes, int offset, int numT= oConvert); + + + // Convert a byte representing a char in a particular ccsid into a Jav= a char. + // + // @param sourceByte The byte to be converted + // @return The converted Java char. + abstract char convertToUCS2Char(byte sourceByte); =20 } =20