/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/**
* The Code Point Input Method is a simple input method that allows Unicode
* characters to be entered using their code point or code unit values. See the
* accompanying file README.txt for more information.
*
* @author Brian Beck
*/
private int insertionPoint;
}
/**
* This is the input method's main routine. The composed text is stored
* in buffer.
*/
// This input method handles KeyEvent only.
return;
}
// If we are not in composition mode, pass through
if (notInCompositionMode) {
return;
}
switch (e.getKeyCode()) {
break;
break;
}
char c = e.getKeyChar();
// If we are not in composition mode, wait a back slash
if (notInCompositionMode) {
// If the type character is not a back slash, pass through
if (c != '\\') {
return;
}
startComposition(); // Enter to composition mode
} else {
switch (c) {
case ' ': // Exit from composition mode
break;
case '\u007f': // Delete
break;
case '\b': // BackSpace
break;
case '\u001b': // Escape
break;
case '\n': // Return
case '\t': // Tab
break;
default:
break;
}
}
} else { // KeyEvent.KEY_RELEASED
// If we are not in composition mode, pass through
if (notInCompositionMode) {
return;
}
}
e.consume();
}
private void composeUnicodeEscape(char c) {
case 1: // \\
break;
case 2: // \\u or \\U
case 3: // \\ux or \\Ux
case 4: // \\uxx or \\Uxx
waitDigit(c);
break;
case 5: // \\uxxx or \\Uxxx
if (format == SPECIAL_ESCAPE) {
waitDigit(c);
} else {
waitDigit2(c);
}
break;
case 6: // \\uxxxx or \\Uxxxx
if (format == SPECIAL_ESCAPE) {
waitDigit(c);
} else if (format == SURROGATE_PAIR) {
} else {
beep();
}
break;
case 7: // \\Uxxxxx
// Only SPECIAL_ESCAPE format uses this state.
// Since the second "\\u" of SURROGATE_PAIR format is inserted
// automatically, users don't have to type these keys.
waitDigit(c);
break;
case 8: // \\uxxxx\\u
case 9: // \\uxxxx\\ux
case 10: // \\uxxxx\\uxx
case 11: // \\uxxxx\\uxxx
if (format == SURROGATE_PAIR) {
waitDigit(c);
} else {
beep();
}
break;
default:
beep();
break;
}
}
private void waitEscapeCharacter(char c) {
if (c == 'u' || c == 'U') {
} else {
if (c != '\\') {
}
}
}
private void waitDigit(char c) {
} else {
beep();
}
}
private void waitDigit2(char c) {
insertionPoint = 8;
} else {
}
} else {
beep();
}
}
private void waitBackSlashOrLowSurrogate(char c) {
if (insertionPoint == 6) {
if (c == '\\') {
insertionPoint = 8;
insertionPoint = 9;
} else {
beep();
}
} else {
beep();
}
}
/**
* Send the composed text to the client.
*/
private void sendComposedText() {
}
/**
* Send the committed text to the client.
*/
private void sendCommittedText() {
insertionPoint = 0;
}
/**
* Move the insertion point one position to the left in the composed text.
* Do not let the caret move to the left of the "\\u" or "\\U".
*/
private void moveCaretLeft() {
if (--insertionPoint < 2) {
beep();
insertionPoint = 8;
beep();
}
null, 0,
}
/**
* Move the insertion point one position to the right in the composed text.
*/
private void moveCaretRight() {
if (++insertionPoint > len) {
beep();
}
null, 0,
}
/**
* Delete the character preceding the insertion point in the composed text.
* If the insertion point is not at the end of the composed text and the
* preceding text is "\\u" or "\\U", ring the bell.
*/
private void deletePreviousCharacter() {
if (insertionPoint == 2) {
} else {
// Do not allow deletion of the leading "\\u" or "\\U" if there
// are other digits in the composed text.
beep();
}
} else if (insertionPoint == 8) {
if (format == SURROGATE_PAIR) {
}
} else {
// Do not allow deletion of the second "\\u" if there are other
// digits in the composed text.
beep();
}
} else {
} else {
}
}
}
/**
* Delete the character following the insertion point in the composed text.
* If the insertion point is at the end of the composed text, ring the bell.
*/
private void deleteCharacter() {
} else {
beep();
}
}
private void startComposition() {
insertionPoint = 1;
}
private void cancelComposition() {
insertionPoint = 0;
}
private void finishComposition() {
return;
}
return;
}
char[] codePoint = {
};
return;
}
}
beep();
}
int value = 0;
}
return value;
}
private static void beep() {
}
public void activate() {
insertionPoint = 0;
}
}
if (!isTemporary) {
}
}
public void dispose() {
}
return null;
}
public void endComposition() {
}
return locale;
}
public void hideWindows() {
}
public boolean isCompositionEnabled() {
// always enabled
return true;
}
}
public void reconvert() {
// not supported yet
throw new UnsupportedOperationException();
}
public void removeNotify() {
}
}
// not supported yet
throw new UnsupportedOperationException();
}
}
/*
* The Code Point Input Method supports all locales.
*/
return true;
}
}