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