01: /*
02:
03: Derby - Class org.apache.derby.client.net.CcsidManager
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.client.net;
23:
24: // Performs character conversions as required to send and receive PROTOCOL control data.
25: // User data uses the JVM's built in converters, i18n.jar,
26:
27: public abstract class CcsidManager {
28: public byte space_; // ' ' character
29: byte dot_; // '.' character
30:
31: // Byte array used to convert numbers into
32: // bytes containing the character representation "value" for the particular ccsid.
33: byte[] numToCharRepresentation_;
34:
35: // Special byte array to convert first half byte of CRRTKNs TCPIP address and port number
36: // to a character. This is required for SNA hopping.
37: // This was specifically added to help build the CRRTKNs.
38: byte[] numToSnaRequiredCrrtknChar_;
39:
40: CcsidManager(byte space, byte dot, byte[] numToCharRepresentation,
41: byte[] numToSnaRequiredCrrtknChar) {
42: space_ = space;
43: dot_ = dot;
44: numToCharRepresentation_ = numToCharRepresentation;
45: numToSnaRequiredCrrtknChar_ = numToSnaRequiredCrrtknChar;
46: }
47:
48: // Convert a Java String into bytes for a particular ccsid.
49: //
50: // @param sourceString A Java String to convert.
51: // @return A new byte array representing the String in a particular ccsid.
52: public abstract byte[] convertFromUCS2(String sourceString,
53: org.apache.derby.client.am.Agent agent)
54: throws org.apache.derby.client.am.SqlException;
55:
56: // Convert a Java String into bytes for a particular ccsid.
57: // The String is converted into a buffer provided by the caller.
58: //
59: // @param sourceString A Java String to convert.
60: // @param buffer The buffer to convert the String into.
61: // @param offset Offset in buffer to start putting output.
62: // @return An int containing the buffer offset after conversion.
63: public abstract int convertFromUCS2(String sourceString,
64: byte[] buffer, int offset,
65: org.apache.derby.client.am.Agent agent)
66: throws org.apache.derby.client.am.SqlException;
67:
68: // Convert a byte array representing characters in a particular ccsid into a Java String.
69: //
70: // @param sourceBytes An array of bytes to be converted.
71: // @return String A new Java String Object created after conversion.
72: abstract String convertToUCS2(byte[] sourceBytes);
73:
74: // Convert a byte array representing characters in a particular ccsid into a Java String.
75: //
76: // @param sourceBytes An array of bytes to be converted.
77: // @param offset An offset indicating first byte to convert.
78: // @param numToConvert The number of bytes to be converted.
79: // @return A new Java String Object created after conversion.
80: abstract String convertToUCS2(byte[] sourceBytes, int offset,
81: int numToConvert);
82:
83: // Convert a byte representing a char in a particular ccsid into a Java char.
84: //
85: // @param sourceByte The byte to be converted
86: // @return The converted Java char.
87: abstract char convertToUCS2Char(byte sourceByte);
88:
89: }
|