KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > drda > CcsidManager


1 /*
2
3    Derby - Class org.apache.derby.impl.drda.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 package org.apache.derby.impl.drda;
22
23 // Peforms character conversions.
24
abstract class CcsidManager
25 {
26   byte space; // ' ' character
27
byte dot; // '.' character
28

29   // Byte array used to convert numbers into
30
// bytes containing the character representation "value" for the particular ccsid.
31
byte[] numToCharRepresentation;
32
33   CcsidManager (byte space, byte dot, byte[] numToCharRepresentation)
34   {
35     this.space = space;
36     this.dot = dot;
37     this.numToCharRepresentation = numToCharRepresentation;
38   }
39
40
41   // Convert a Java String into bytes for a particular ccsid.
42
//
43
// @param sourceString A Java String to convert.
44
// @return A new byte array representing the String in a particular ccsid.
45
abstract byte[] convertFromUCS2 (String JavaDoc sourceString);
46
47
48   // Convert a Java String into bytes for a particular ccsid.
49
// The String is converted into a buffer provided by the caller.
50
//
51
// @param sourceString A Java String to convert.
52
// @param buffer The buffer to convert the String into.
53
// @param offset Offset in buffer to start putting output.
54
// @return An int containing the buffer offset after conversion.
55
abstract int convertFromUCS2 (String JavaDoc sourceString,
56                                 byte[] buffer,
57                                 int offset);
58
59   // Convert a byte array representing characters in a particular ccsid into a Java String.
60
//
61
// @param sourceBytes An array of bytes to be converted.
62
// @return String A new Java String Object created after conversion.
63
abstract String JavaDoc convertToUCS2 (byte[] sourceBytes);
64
65
66   // Convert a byte array representing characters in a particular ccsid into a Java String.
67
//
68
// @param sourceBytes An array of bytes to be converted.
69
// @param offset An offset indicating first byte to convert.
70
// @param numToConvert The number of bytes to be converted.
71
// @return A new Java String Object created after conversion.
72
abstract String JavaDoc convertToUCS2 (byte[] sourceBytes, int offset, int numToConvert);
73
74 }
75
Popular Tags