Source code: org/apache/derby/impl/drda/CcsidManager.java
1 /*
2
3 Derby - Class org.apache.derby.impl.drda.CcsidManager
4
5 Copyright 2001, 2004 The Apache Software Foundation or its licensors, as 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 package org.apache.derby.impl.drda;
21
22 // Peforms character conversions.
23 abstract class CcsidManager
24 {
25 byte space; // ' ' character
26 byte dot; // '.' character
27
28 // Byte array used to convert numbers into
29 // bytes containing the character representation "value" for the particular ccsid.
30 byte[] numToCharRepresentation;
31
32 CcsidManager (byte space, byte dot, byte[] numToCharRepresentation)
33 {
34 this.space = space;
35 this.dot = dot;
36 this.numToCharRepresentation = numToCharRepresentation;
37 }
38
39
40 // Convert a Java String into bytes for a particular ccsid.
41 //
42 // @param sourceString A Java String to convert.
43 // @return A new byte array representing the String in a particular ccsid.
44 abstract byte[] convertFromUCS2 (String sourceString);
45
46
47 // Convert a Java String into bytes for a particular ccsid.
48 // The String is converted into a buffer provided by the caller.
49 //
50 // @param sourceString A Java String to convert.
51 // @param buffer The buffer to convert the String into.
52 // @param offset Offset in buffer to start putting output.
53 // @return An int containing the buffer offset after conversion.
54 abstract int convertFromUCS2 (String sourceString,
55 byte[] buffer,
56 int offset);
57
58 // Convert a byte array representing characters in a particular ccsid into a Java String.
59 //
60 // @param sourceBytes An array of bytes to be converted.
61 // @return String A new Java String Object created after conversion.
62 abstract String convertToUCS2 (byte[] sourceBytes);
63
64
65 // Convert a byte array representing characters in a particular ccsid into a Java String.
66 //
67 // @param sourceBytes An array of bytes to be converted.
68 // @param offset An offset indicating first byte to convert.
69 // @param numToConvert The number of bytes to be converted.
70 // @return A new Java String Object created after conversion.
71 abstract String convertToUCS2 (byte[] sourceBytes, int offset, int numToConvert);
72
73 }