001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.cdc.i18n.j2me;
028:
029: /**
030: * Character conversion base class
031: */
032: class Conv {
033: /**
034: * Native method to get a handle to specific character
035: * encoding conversion routine.
036: *
037: * @param encoding character encoding
038: * @return identifier for requested handler, or -1 if
039: * the encoding was not supported.
040: */
041: native static int getHandler(String encoding);
042:
043: /**
044: * Native function to set the maximum length in bytes
045: * for a converted string.
046: *
047: * @param handler handle returned from getHandler
048: * @return maximum byte length, or zero if handler
049: * is not valid
050: * @see #getHandler
051: */
052: native static int getMaxByteLength(int handler);
053:
054: /**
055: * Get the length of a specific converted string.
056: *
057: * @param handler handle returned from getHandler
058: * @param b buffer of bytes to be converted
059: * @param offset offset into the provided buffer
060: * @param len length of data to be processed
061: * @return length of the converted string, or zero
062: * if arguments were not valid
063: * @see #getHandler
064: */
065: native static int getByteLength(int handler, byte[] b, int offset,
066: int len);
067:
068: /**
069: * Native function to convert an array of bytes to
070: * converted array of characters.
071: *
072: * @param handler handle returned from getHandler
073: * @param input buffer of bytes to be converted
074: * @param in_offset offset into the provided buffer
075: * @param in_len length of data to be processed
076: * @param output buffer of converted bytes
077: * @param out_offset offset into the provided output buffer
078: * @param out_len length of data processed
079: * @return length of the converted string, or zero if
080: * the arguments were not valid
081: * @see #getHandler
082: */
083: native static int byteToChar(int handler, byte[] input,
084: int in_offset, int in_len, char[] output, int out_offset,
085: int out_len);
086:
087: /**
088: * Native function to convert an array of characters
089: * to an array of converted characters.
090: *
091: * @param handler handle returned from getHandler
092: * @param input buffer of bytes to be converted
093: * @param in_offset offset into the provided buffer
094: * @param in_len length of data to be processed
095: * @param output buffer of converted bytes
096: * @param out_offset offset into the provided output buffer
097: * @param out_len length of data processed
098: * @return length of the converted string, or zero if
099: * the arguments were not valid
100: * @see #getHandler
101: */
102: native static int charToByte(int handler, char[] input,
103: int in_offset, int in_len, byte[] output, int out_offset,
104: int out_len);
105:
106: /**
107: * Native function to get the length of a specific
108: * converted string as an array of Unicode bytes.
109: *
110: * @param handler handle returned from getHandler
111: * @param b buffer of bytes to be converted
112: * @param offset offset into the provided buffer
113: * @param length length of data to be processed
114: * @return length of the converted string, or zero
115: * if the arguments were not valid
116: * @see #getHandler
117: */
118: native static int sizeOfByteInUnicode(int handler, byte[] b,
119: int offset, int length);
120:
121: /**
122: * Native function to get the length of a specific
123: * converted string as an array of Unicode characters.
124: *
125: * @param handler handle returned from getHandler
126: * @param c buffer of characters to be converted
127: * @param offset offset into the provided buffer
128: * @param length length of data to be processed
129: * @return length of the converted string, or zero
130: * if the arguments were not valid
131: * @see #getHandler
132: */
133: native static int sizeOfUnicodeInByte(int handler, char[] c,
134: int offset, int length);
135: }
|