KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > client > net > CcsidManager


1 /*
2
3    Derby - Class org.apache.derby.client.net.CcsidManager
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (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,
41                  byte dot,
42                  byte[] numToCharRepresentation,
43                  byte[] numToSnaRequiredCrrtknChar) {
44         space_ = space;
45         dot_ = dot;
46         numToCharRepresentation_ = numToCharRepresentation;
47         numToSnaRequiredCrrtknChar_ = numToSnaRequiredCrrtknChar;
48     }
49
50
51     // Convert a Java String into bytes for a particular ccsid.
52
//
53
// @param sourceString A Java String to convert.
54
// @return A new byte array representing the String in a particular ccsid.
55
public abstract byte[] convertFromUCS2(String JavaDoc sourceString, org.apache.derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException;
56
57
58     // Convert a Java String into bytes for a particular ccsid.
59
// The String is converted into a buffer provided by the caller.
60
//
61
// @param sourceString A Java String to convert.
62
// @param buffer The buffer to convert the String into.
63
// @param offset Offset in buffer to start putting output.
64
// @return An int containing the buffer offset after conversion.
65
public abstract int convertFromUCS2(String JavaDoc sourceString,
66                                         byte[] buffer,
67                                         int offset,
68                                         org.apache.derby.client.am.Agent agent) throws org.apache.derby.client.am.SqlException;
69
70     // Convert a byte array representing characters in a particular ccsid into a Java String.
71
//
72
// @param sourceBytes An array of bytes to be converted.
73
// @return String A new Java String Object created after conversion.
74
abstract String JavaDoc convertToUCS2(byte[] sourceBytes);
75
76
77     // Convert a byte array representing characters in a particular ccsid into a Java String.
78
//
79
// @param sourceBytes An array of bytes to be converted.
80
// @param offset An offset indicating first byte to convert.
81
// @param numToConvert The number of bytes to be converted.
82
// @return A new Java String Object created after conversion.
83
abstract String JavaDoc convertToUCS2(byte[] sourceBytes, int offset, int numToConvert);
84
85
86     // Convert a byte representing a char in a particular ccsid into a Java char.
87
//
88
// @param sourceByte The byte to be converted
89
// @return The converted Java char.
90
abstract char convertToUCS2Char(byte sourceByte);
91
92 }
93
94
Popular Tags