/** * Translate a string to EBCDIC for use in the protocol * * @param str string to transform * @return EBCDIC string */ private byte[] getEBCDIC(String str) { return ccsidManager.convertFromUCS2(str); } /**
/** * Convert EBCDIC byte array to unicode string * * @param buf - byte array * @return string */ protected String convertBytes(byte[] buf) { return ccsidManager.convertToUCS2 (buf, 0, buf.length); }
public void setString(String s) { buffer = ccsidManager.convertFromUCS2(s); modified = true; cachedString = s; }
/** * Convert the internal byte array to a string. The string value * is cached. * * @return a <code>String</code> value */ public String toString() { if (cachedString == null) { cachedString = ccsidManager.convertToUCS2(buffer); } return cachedString; }
public void setString(String s) { buffer = ccsidManager.convertFromUCS2(s); modified = true; cachedString = s; }
/** * Convert the internal byte array to a string. The string value * is cached. * * @return a <code>String</code> value */ public String toString() { if (cachedString == null) { cachedString = ccsidManager.convertToUCS2(buffer); } return cachedString; }
/** * Translate a string to EBCDIC for use in the protocol * * @param str string to transform * @return EBCDIC string */ private byte[] getEBCDIC(String str) { return ccsidManager.convertFromUCS2(str); } /**
/** * Convert the internal byte array to a string. The string value * is cached. * * @return a <code>String</code> value */ public String toString() { if (cachedString == null) { cachedString = ccsidManager.convertToUCS2(buffer); } return cachedString; }
/** * Translate a string to EBCDIC for use in the protocol * * @param str string to transform * @return EBCDIC string */ private byte[] getEBCDIC(String str) { return ccsidManager.convertFromUCS2(str); } /**
/** * Convert EBCDIC byte array to unicode string * * @param buf - byte array * @return string */ protected String convertBytes(byte[] buf) { return ccsidManager.convertToUCS2 (buf, 0, buf.length); }
public void setString(String s) { buffer = ccsidManager.convertFromUCS2(s); modified = true; cachedString = s; }
/** * Convert EBCDIC byte array to unicode string * * @param buf - byte array * @return string */ protected String convertBytes(byte[] buf) { return ccsidManager.convertToUCS2 (buf, 0, buf.length); }
/** * Write scalar string object includes length, codepoint and value * the string is converted into the appropriate codeset (EBCDIC) * * @param codePoint - code point to write * @param string - string to be written */ void writeScalarString (int codePoint, String string) { int stringLength = string.length(); ensureLength ((stringLength * 2) + 4); buffer.putShort((short) (stringLength + 4)); buffer.putShort((short) codePoint); ccsidManager.convertFromUCS2(string, buffer); }
/** * Read string value * Strings in DRDA protocol are encoded in EBCDIC by default so we * need to convert to UCS2 * @param length - length of string to read * @return value * * @exception DRDProtocolException */ protected String readString (int length) throws DRDAProtocolException { ensureBLayerDataInBuffer (length, ADJUST_LENGTHS); String result = ccsidManager.convertToUCS2 (buffer, pos, length); pos += length; return result; }
/** * Write scalar string object includes length, codepoint and value * the string is converted into the appropriate codeset (EBCDIC) * * @param codePoint - code point to write * @param string - string to be written */ void writeScalarString (int codePoint, String string) { int stringLength = string.length(); ensureLength ((stringLength * 2) + 4); buffer.putShort((short) (stringLength + 4)); buffer.putShort((short) codePoint); ccsidManager.convertFromUCS2(string, buffer); }
/** * Read string value * Strings in DRDA protocol are encoded in EBCDIC by default so we * need to convert to UCS2 * @param length - length of string to read * @return value * * @exception DRDProtocolException */ protected String readString (int length) throws DRDAProtocolException { ensureBLayerDataInBuffer (length, ADJUST_LENGTHS); String result = ccsidManager.convertToUCS2 (buffer, pos, length); pos += length; return result; }
/** * Write scalar string object includes length, codepoint and value * the string is converted into the appropriate codeset (EBCDIC) * * @param codePoint - code point to write * @param string - string to be written */ void writeScalarString (int codePoint, String string) { int stringLength = string.length(); ensureLength ((stringLength * 2) + 4); buffer.putShort((short) (stringLength + 4)); buffer.putShort((short) codePoint); ccsidManager.convertFromUCS2(string, buffer); }
/** * Read string value * Strings in DRDA protocol are encoded in EBCDIC by default so we * need to convert to UCS2 * @param length - length of string to read * @return value * * @exception DRDProtocolException */ protected String readString (int length) throws DRDAProtocolException { ensureBLayerDataInBuffer (length, ADJUST_LENGTHS); String result = ccsidManager.convertToUCS2 (buffer, pos, length); pos += length; return result; }
/** * Write padded scalar string object value * the string is converted into the appropriate codeset (EBCDIC) * * @param string - string to be written * @param paddedLength - length to pad string to */ protected void writeScalarPaddedString (String string, int paddedLength) { int stringLength = string.length(); int fillLength = paddedLength -stringLength; ensureLength (paddedLength); ccsidManager.convertFromUCS2(string, buffer); padBytes(ccsidManager.space, fillLength); }
/** * Read encrypted string * @param decryptM decryption manager * @param securityMechanism security mechanism * @param initVector initialization vector for cipher * @param sourcePublicKey public key (as in Deffie-Hellman algorithm) * from source (encryptor) * @return decrypted string * * @exception DRDProtocolException, SQLException(wrapping any exception in decryption) */ protected String readEncryptedString (DecryptionManager decryptM, int securityMechanism, byte[] initVector, byte[] sourcePublicKey) throws DRDAProtocolException, java.sql.SQLException { byte[] cipherText = readBytes(); byte[] plainText = null; plainText = decryptM.decryptData(cipherText, securityMechanism, initVector, sourcePublicKey); if (plainText == null) return null; else return ccsidManager.convertToUCS2(plainText); }