db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r987667 - in /db/derby/code/trunk/java: client/org/apache/derby/client/net/ drda/org/apache/derby/impl/drda/
Date Fri, 20 Aug 2010 23:01:58 GMT
Author: kmarsden
Date: Fri Aug 20 23:01:57 2010
New Revision: 987667

URL: http://svn.apache.org/viewvc?rev=987667&view=rev
Log:
DERBY-728 subtask DERBY-4757  (Client) Implement UTF8 support on DRDA
(partial) Consolidate references to CcsidManager to facilitate switch from EBCDIC to UTF8



Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetAgent.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAString.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/CcsidManager.java Fri Aug
20 23:01:57 2010
@@ -37,6 +37,9 @@ public abstract class CcsidManager {
     // This was specifically added to help build the CRRTKNs.
     byte[] numToSnaRequiredCrrtknChar_;
 
+    /* DRDA CCSID levels for UTF8 and EBCDIC */
+    public static final int UTF8_CCSID = 1208;
+    
     CcsidManager(byte space,
                  byte dot,
                  byte[] numToCharRepresentation,

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetAgent.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetAgent.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetAgent.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetAgent.java Fri Aug 20 23:01:57
2010
@@ -192,7 +192,7 @@ public class NetAgent extends Agent {
             statementReply_ = (StatementReply) resultSetReply_;
             packageReply_ = (ConnectionReply) statementReply_;
             connectionReply_ = (ConnectionReply) packageReply_;
-            NetXAConnectionRequest netXAConnectionRequest_ = new NetXAConnectionRequest(this,
currentCcsidManager_, netConnection_.commBufferSize_);
+            NetXAConnectionRequest netXAConnectionRequest_ = new NetXAConnectionRequest(this,
netConnection_.commBufferSize_);
             netResultSetRequest_ = (NetResultSetRequest) netXAConnectionRequest_;
             netStatementRequest_ = (NetStatementRequest) netResultSetRequest_;
             netPackageRequest_ = (NetPackageRequest) netStatementRequest_;
@@ -217,7 +217,7 @@ public class NetAgent extends Agent {
             statementReply_ = (StatementReply) resultSetReply_;
             packageReply_ = (ConnectionReply) statementReply_;
             connectionReply_ = (ConnectionReply) packageReply_;
-            netResultSetRequest_ = new NetResultSetRequest(this, currentCcsidManager_, netConnection_.commBufferSize_);
+            netResultSetRequest_ = new NetResultSetRequest(this, netConnection_.commBufferSize_);
             netStatementRequest_ = (NetStatementRequest) netResultSetRequest_;
             netPackageRequest_ = (NetPackageRequest) netStatementRequest_;
             netConnectionRequest_ = (NetConnectionRequest) netPackageRequest_;

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
Fri Aug 20 23:01:57 2010
@@ -29,8 +29,8 @@ import org.apache.derby.client.am.Client
 import org.apache.derby.shared.common.reference.SQLState;
 
 public class NetConnectionRequest extends Request implements ConnectionRequestInterface {
-    NetConnectionRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) {
-        super(netAgent, ccsidManager, bufferSize);
+    NetConnectionRequest(NetAgent netAgent, int bufferSize) {
+        super(netAgent, bufferSize);
     }
     //----------------------------- entry points ---------------------------------
 
@@ -485,7 +485,7 @@ public class NetConnectionRequest extend
         // see if we can optimize
         if (dontSendOnConversionError) {
             try {
-                ccsidManager_.convertFromJavaString(rdbnam, netAgent_);
+                netAgent_.getCurrentCcsidManager().convertFromJavaString(rdbnam, netAgent_);
             } catch (SqlException se)  {
                 netAgent_.exceptionConvertingRdbnam = se;
                 return;

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java Fri
Aug 20 23:01:57 2010
@@ -30,8 +30,8 @@ import org.apache.derby.shared.common.re
 public class NetPackageRequest extends NetConnectionRequest {
     static final String COLLECTIONNAME = "NULLID";
 
-    NetPackageRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) {
-        super(netAgent, ccsidManager, bufferSize);
+    NetPackageRequest(NetAgent netAgent, int bufferSize) {
+        super(netAgent, bufferSize);
     }
 
     // RDB Package Name, Consistency Token

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java Fri
Aug 20 23:01:57 2010
@@ -31,8 +31,8 @@ import org.apache.derby.shared.common.re
 
 public class NetResultSetRequest extends NetStatementRequest
         implements ResultSetRequestInterface {
-    public NetResultSetRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize)
{
-        super(netAgent, ccsidManager, bufferSize);
+    public NetResultSetRequest(NetAgent netAgent, int bufferSize) {
+        super(netAgent, bufferSize);
     }
 
     //----------------------------- entry points ---------------------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java Fri
Aug 20 23:01:57 2010
@@ -52,8 +52,8 @@ public class NetStatementRequest extends
     // is still needed for non-promototed LOBs
     java.util.HashMap promototedParameters_ = new java.util.HashMap();
 
-    NetStatementRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) {
-        super(netAgent, ccsidManager, bufferSize);
+    NetStatementRequest(NetAgent netAgent, int bufferSize) {
+        super(netAgent, bufferSize);
     }
 
     //----------------------------- entry points ---------------------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
Fri Aug 20 23:01:57 2010
@@ -27,8 +27,8 @@ import javax.transaction.xa.Xid;
 import org.apache.derby.client.am.SqlException;
 
 public class NetXAConnectionRequest extends NetResultSetRequest {
-    NetXAConnectionRequest(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize)
{
-        super(netAgent, ccsidManager, bufferSize);
+    NetXAConnectionRequest(NetAgent netAgent, int bufferSize) {
+        super(netAgent, bufferSize);
     }
 
     //----------------------------- entry points ---------------------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java Fri Aug 20 23:01:57
2010
@@ -38,7 +38,6 @@ public class Reply {
     protected org.apache.derby.client.am.Agent agent_;
     protected NetAgent netAgent_; //cheat-link to (NetAgent) agent_
 
-    private CcsidManager ccsidManager_;
     protected final static int DEFAULT_BUFFER_SIZE = 32767;
     protected byte[] buffer_;
     protected int pos_;
@@ -73,7 +72,6 @@ public class Reply {
     Reply(NetAgent netAgent, int bufferSize) {
         buffer_ = new byte[bufferSize];
         agent_ = netAgent_ = netAgent;
-        ccsidManager_ = netAgent.getCurrentCcsidManager();
         ddmCollectionLenStack_ = new int[Reply.MAX_MARKS_NESTING];
         initialize();
     }
@@ -668,7 +666,8 @@ public class Reply {
         ensureBLayerDataInBuffer(length);
         adjustLengths(length);
 
-        String result = ccsidManager_.convertToJavaString(buffer_, pos_, length);
+        String result = netAgent_.getCurrentCcsidManager()
+                            .convertToJavaString(buffer_, pos_, length);
         pos_ += length;
         return result;
     }
@@ -695,7 +694,8 @@ public class Reply {
         int len = ddmScalarLen_;
         ensureBLayerDataInBuffer(len);
         adjustLengths(len);
-        String result = ccsidManager_.convertToJavaString(buffer_, pos_, len);
+        String result = netAgent_.getCurrentCcsidManager()
+                            .convertToJavaString(buffer_, pos_, len);
         pos_ += len;
         return result;
     }
@@ -1253,7 +1253,8 @@ public class Reply {
     }
 
     final String readFastString(int length) throws DisconnectException {
-        String result = ccsidManager_.convertToJavaString(buffer_, pos_, length);
+        String result = netAgent_.getCurrentCcsidManager()
+                            .convertToJavaString(buffer_, pos_, length);
         pos_ += length;
         return result;
     }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java Fri Aug 20 23:01:57
2010
@@ -54,11 +54,6 @@ public class Request {
     private int[] markStack_ = new int[MAX_MARKS_NESTING];
     private int top_ = 0;
 
-    // the ccsid manager for the connection is stored in this object.  it will
-    // be used when constructing character ddm data.  it will NOT be used for
-    // building any FDOCA data.
-    protected CcsidManager ccsidManager_;
-
     //  This Object tracks the location of the current
     //  Dss header length bytes.  This is done so
     //  the length bytes can be automatically
@@ -82,21 +77,12 @@ public class Request {
     // construct a request object specifying the minimum buffer size
     // to be used to buffer up the built requests.  also specify the ccsid manager
     // instance to be used when building ddm character data.
-    Request(NetAgent netAgent, int minSize, CcsidManager ccsidManager) {
+    Request(NetAgent netAgent, int minSize) {
         netAgent_ = netAgent;
         bytes_ = new byte[minSize];
-        ccsidManager_ = ccsidManager;
         clearBuffer();
     }
 
-    // construct a request object specifying the ccsid manager instance
-    // to be used when building ddm character data.  This will also create
-    // a buffer using the default size (see final static DEFAULT_BUFFER_SIZE value).
-    Request(NetAgent netAgent, CcsidManager ccsidManager, int bufferSize) {
-        //this (netAgent, Request.DEFAULT_BUFFER_SIZE, ccsidManager);
-        this(netAgent, bufferSize, ccsidManager);
-    }
-
     protected final void clearBuffer() {
         offset_ = 0;
         top_ = 0;
@@ -115,13 +101,6 @@ public class Request {
         correlationID_ = 0;
     }
 
-    // set the ccsid manager value.  this method allows the ccsid manager to be
-    // changed so a request object can be reused by different connections with
-    // different ccsid managers.
-    final void setCcsidMgr(CcsidManager ccsidManager) {
-        ccsidManager_ = ccsidManager;
-    }
-
     // ensure length at the end of the buffer for a certain amount of data.
     // if the buffer does not contain sufficient room for the data, the buffer
     // will be expanded by the larger of (2 * current size) or (current size + length).
@@ -1161,8 +1140,13 @@ public class Request {
      * @throws SqlException if string exceeds byteLengthLimit
      */
     final void writeScalarString(int codePoint, String string, int byteMinLength,
-            int byteLengthLimit, String sqlState) throws SqlException {        
-        int maxByteLength = ccsidManager_.maxBytesPerChar() * string.length();
+            int byteLengthLimit, String sqlState) throws SqlException {
+        
+        /* Grab the current CCSID MGR from the NetAgent */ 
+        CcsidManager currentCcsidMgr = netAgent_.getCurrentCcsidManager();
+        
+        int maxByteLength = currentCcsidMgr.getByteLength(string);
+
         ensureLength(offset_ + maxByteLength + 4);
         // Skip length for now until we know actual length
         int lengthOffset = offset_;
@@ -1171,7 +1155,7 @@ public class Request {
         bytes_[offset_++] = (byte) ((codePoint >>> 8) & 0xff);
         bytes_[offset_++] = (byte) (codePoint & 0xff);
         
-        offset_ = ccsidManager_.convertFromJavaString(string, bytes_, offset_, netAgent_);
+        offset_ = currentCcsidMgr.convertFromJavaString(string, bytes_, offset_, netAgent_);
        
         int stringByteLength = offset_ - lengthOffset - 4;
         // reset the buffer and throw an SQLException if the length is too long
@@ -1183,7 +1167,7 @@ public class Request {
         // pad if we don't reach the byteMinLength limit
         if (stringByteLength < byteMinLength) {
             for (int i = stringByteLength ; i < byteMinLength; i++) {
-                bytes_[offset_++] = ccsidManager_.space_;
+                bytes_[offset_++] = currentCcsidMgr.space_;
             }
             stringByteLength = byteMinLength;
         }
@@ -1207,11 +1191,16 @@ public class Request {
     // character data. This method also assumes that the string.length() will
     // be the number of bytes following the conversion.
     final void writeScalarPaddedString(String string, int paddedLength) throws SqlException
{
-        int stringLength = string.length();
         ensureLength(offset_ + paddedLength);
-        offset_ = ccsidManager_.convertFromJavaString(string, bytes_, offset_, netAgent_);
+        
+        /* Grab the current CCSID MGR from the NetAgent */ 
+        CcsidManager currentCcsidMgr = netAgent_.getCurrentCcsidManager();
+        
+        int stringLength = currentCcsidMgr.getByteLength(string);
+        
+        offset_ = currentCcsidMgr.convertFromJavaString(string, bytes_, offset_, netAgent_);
         for (int i = 0; i < paddedLength - stringLength; i++) {
-            bytes_[offset_++] = ccsidManager_.space_;
+            bytes_[offset_++] = currentCcsidMgr.space_;
         }
     }
 
@@ -1327,7 +1316,8 @@ public class Request {
                 mask.append(maskChar);
             }
             // try to write mask over password.
-            ccsidManager_.convertFromJavaString(mask.toString(), bytes_, passwordStart_,
netAgent_);
+            netAgent_.getCurrentCcsidManager()
+                    .convertFromJavaString(mask.toString(), bytes_, passwordStart_, netAgent_);
         } catch (SqlException sqle) {
             // failed to convert mask,
             // them simply replace with 0xFF.
@@ -1564,8 +1554,11 @@ public class Request {
     // ccsid manager or typdef rules.  should this method write ddm character
     // data or fodca data right now it is coded for ddm char data only
     final void writeDDMString(String s) throws SqlException {
-        ensureLength(offset_ + s.length());
-        offset_ = ccsidManager_.convertFromJavaString(s, bytes_, offset_, netAgent_);
+        CcsidManager currentCcsidManager = netAgent_.getCurrentCcsidManager();
+        
+        ensureLength(offset_ + currentCcsidManager.getByteLength(s));
+        
+        offset_ = currentCcsidManager.convertFromJavaString(s, bytes_, offset_, netAgent_);
     }
 
     private void buildLengthAndCodePointForLob(int codePoint,

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Fri Aug 20
23:01:57 2010
@@ -608,10 +608,10 @@ class DRDAConnThread extends Thread {
 		
 		/* At this stage we can initialize the strings as we have
 		 * the CcsidManager for the DDMWriter. */
-		rdbnam = new DRDAString(writer.getCurrentCcsidManager());
-	    rdbcolid = new DRDAString(writer.getCurrentCcsidManager());
-	    pkgid = new DRDAString(writer.getCurrentCcsidManager());
-	    pkgcnstkn = new DRDAString(writer.getCurrentCcsidManager());
+		rdbnam = new DRDAString(writer);
+	    rdbcolid = new DRDAString(writer);
+	    pkgid = new DRDAString(writer);
+	    pkgcnstkn = new DRDAString(writer);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAString.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAString.java?rev=987667&r1=987666&r2=987667&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAString.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAString.java Fri Aug 20 23:01:57
2010
@@ -31,8 +31,9 @@ package org.apache.derby.impl.drda;
 final class DRDAString {
     /** Buffer representing the string. */
     private byte[] buffer;
-    /** Object used to convert byte buffer to string. */
-    private final CcsidManager ccsidManager;
+    
+    /** Keep the DDMWriter as it contains the current CCSID manager being used */
+    private final DDMWriter writer;
 
     /** True if the contents were modified in the previous call to
      * <code>setBytes</code>. */
@@ -47,9 +48,9 @@ final class DRDAString {
      * @param m a <code>CcsidManager</code> value specifying
      * which encoding is used
      */
-    DRDAString(CcsidManager m) {
+    DRDAString(DDMWriter w) {
         this.buffer = new byte[0];
-        this.ccsidManager = m;
+        this.writer = w;
         this.cachedString = null;
     }
 
@@ -112,7 +113,7 @@ final class DRDAString {
     public String toString() {
         if (cachedString == null) {
             cachedString =
-                ccsidManager.convertToJavaString(buffer);
+                writer.getCurrentCcsidManager().convertToJavaString(buffer);
         }
         return cachedString;
     }



Mime
View raw message