Example usage for java.lang Character toString

List of usage examples for java.lang Character toString

Introduction

In this page you can find the example usage for java.lang Character toString.

Prototype

public static String toString(int codePoint) 

Source Link

Document

Returns a String object representing the specified character (Unicode code point).

Usage

From source file:org.distantshoresmedia.keyboard.LatinIME.java

private void sendSpecialKey(int code) {
    if (!isConnectbot()) {
        commitTyped(getCurrentInputConnection(), true);
        sendModifiedKeyDownUp(code);//from www .  j  a va 2  s .  c  o m
        return;
    }

    // TODO(klausw): properly support xterm sequences for Ctrl/Alt modifiers?
    // See http://slackware.osuosl.org/slackware-12.0/source/l/ncurses/xterm.terminfo
    // and the output of "$ infocmp -1L". Support multiple sets, and optional 
    // true numpad keys?
    if (ESC_SEQUENCES == null) {
        ESC_SEQUENCES = new HashMap<Integer, String>();
        CTRL_SEQUENCES = new HashMap<Integer, Integer>();

        // VT escape sequences without leading Escape
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_HOME, "[1~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_END, "[4~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_PAGE_UP, "[5~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_PAGE_DOWN, "[6~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F1, "OP");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F2, "OQ");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F3, "OR");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F4, "OS");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F5, "[15~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F6, "[17~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F7, "[18~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F8, "[19~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F9, "[20~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F10, "[21~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F11, "[23~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F12, "[24~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_FORWARD_DEL, "[3~");
        ESC_SEQUENCES.put(-TKKeyboardView.KEYCODE_INSERT, "[2~");

        // Special ConnectBot hack: Ctrl-1 to Ctrl-0 for F1-F10.
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F1, KeyEvent.KEYCODE_1);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F2, KeyEvent.KEYCODE_2);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F3, KeyEvent.KEYCODE_3);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F4, KeyEvent.KEYCODE_4);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F5, KeyEvent.KEYCODE_5);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F6, KeyEvent.KEYCODE_6);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F7, KeyEvent.KEYCODE_7);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F8, KeyEvent.KEYCODE_8);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F9, KeyEvent.KEYCODE_9);
        CTRL_SEQUENCES.put(-TKKeyboardView.KEYCODE_FKEY_F10, KeyEvent.KEYCODE_0);

        // Natively supported by ConnectBot
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_DPAD_UP, "OA");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_DPAD_DOWN, "OB");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_DPAD_LEFT, "OD");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_DPAD_RIGHT, "OC");

        // No VT equivalents?
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_DPAD_CENTER, "");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_SYSRQ, "");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_BREAK, "");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_NUM_LOCK, "");
        // ESC_SEQUENCES.put(-LatinKeyboardView.KEYCODE_SCROLL_LOCK, "");
    }
    InputConnection ic = getCurrentInputConnection();
    Integer ctrlseq = null;
    if (mConnectbotTabHack) {
        ctrlseq = CTRL_SEQUENCES.get(code);
    }
    String seq = ESC_SEQUENCES.get(code);

    if (ctrlseq != null) {
        if (mModAlt) {
            // send ESC prefix for "Alt"
            ic.commitText(Character.toString((char) 27), 1);
        }
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, ctrlseq));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, ctrlseq));
    } else if (seq != null) {
        if (mModAlt) {
            // send ESC prefix for "Alt"
            ic.commitText(Character.toString((char) 27), 1);
        }
        // send ESC prefix of escape sequence
        ic.commitText(Character.toString((char) 27), 1);
        ic.commitText(seq, 1);
    } else {
        // send key code, let connectbot handle it
        sendDownUpKeyEvents(code);
    }
    handleModifierKeysUp(false, false);
}

From source file:org.distantshoresmedia.keyboard.LatinIME.java

public void sendModifiableKeyChar(char ch) {
    // Support modified key events
    boolean modShift = isShiftMod();
    if ((modShift || mModCtrl || mModAlt || mModMeta) && ch > 0 && ch < 127) {
        InputConnection ic = getCurrentInputConnection();
        if (isConnectbot()) {
            if (mModAlt) {
                // send ESC prefix
                ic.commitText(Character.toString((char) 27), 1);
            }/*from w w w. j ava  2  s. c  o m*/
            if (mModCtrl) {
                int code = ch & 31;
                if (code == 9) {
                    sendTab();
                } else {
                    ic.commitText(Character.toString((char) code), 1);
                }
            } else {
                ic.commitText(Character.toString(ch), 1);
            }
            handleModifierKeysUp(false, false);
            return;
        }

        // Non-ConnectBot

        // Restrict Shift modifier to ENTER and SPACE, supporting Shift-Enter etc.
        // Note that most special keys such as DEL or cursor keys aren't handled
        // by this charcode-based method.

        int combinedCode = asciiToKeyCode[ch];
        if (combinedCode > 0) {
            int code = combinedCode & KF_MASK;
            boolean shiftable = (combinedCode & KF_SHIFTABLE) > 0;
            boolean upper = (combinedCode & KF_UPPER) > 0;
            boolean letter = (combinedCode & KF_LETTER) > 0;
            boolean shifted = modShift && (upper || shiftable);
            if (letter && !mModCtrl && !mModAlt && !mModMeta) {
                // Try workaround for issue 179 where letters don't get upcased
                ic.commitText(Character.toString(ch), 1);
                handleModifierKeysUp(false, false);
            } else {
                sendModifiedKeyDownUp(code, shifted);
            }
            return;
        }
    }

    if (ch >= '0' && ch <= '9') {
        //WIP
        InputConnection ic = getCurrentInputConnection();
        ic.clearMetaKeyStates(KeyEvent.META_SHIFT_ON | KeyEvent.META_ALT_ON | KeyEvent.META_SYM_ON);
        //EditorInfo ei = getCurrentInputEditorInfo();
        //Log.i(TAG, "capsmode=" + ic.getCursorCapsMode(ei.inputType));
        //sendModifiedKeyDownUp(KeyEvent.KEYCODE_0 + ch - '0');
        //return;
    }

    // Default handling for anything else, including unmodified ENTER and SPACE.
    sendKeyChar(ch);
}

From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java

@Override
public int getConnectorMessageCount(String channelId, String serverId, int metaDataId, Status status) {
    if (donkey.getDeployedChannels().get(channelId) != null || getLocalChannelIds().get(channelId) != null) {
        ResultSet resultSet = null;

        try {/*from  w  ww  .j  a v a  2  s . c om*/
            PreparedStatement statement = statementSource.getPreparedStatement(
                    "getConnectorMessageCountByMetaDataIdAndStatus", getLocalChannelId(channelId));
            statement.setInt(1, metaDataId);
            statement.setString(2, Character.toString(status.getStatusCode()));
            statement.setString(3, serverId);
            resultSet = statement.executeQuery();
            resultSet.next();
            return resultSet.getInt(1);
        } catch (SQLException e) {
            throw new DonkeyDaoException(e);
        } finally {
            close(resultSet);
        }
    } else {
        // the channel has never been deployed
        return 0;
    }
}

From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java

@Override
public long getConnectorMessageMaxMessageId(String channelId, String serverId, int metaDataId, Status status) {
    ResultSet resultSet = null;//  w  ww. j  a  v a2 s . c  om

    try {
        PreparedStatement statement = prepareStatement("getConnectorMessageMaxMessageIdByMetaDataIdAndStatus",
                channelId);
        statement.setInt(1, metaDataId);
        statement.setString(2, Character.toString(status.getStatusCode()));
        statement.setString(3, serverId);
        resultSet = statement.executeQuery();
        resultSet.next();
        return resultSet.getLong(1);
    } catch (SQLException e) {
        throw new DonkeyDaoException(e);
    } finally {
        close(resultSet);
    }
}

From source file:org.distantshoresmedia.keyboard.LatinIME.java

private void sendTab() {
    InputConnection ic = getCurrentInputConnection();
    boolean tabHack = isConnectbot() && mConnectbotTabHack;

    // FIXME: tab and ^I don't work in connectbot, hackish workaround
    if (tabHack) {
        if (mModAlt) {
            // send ESC prefix
            ic.commitText(Character.toString((char) 27), 1);
        }//w  ww .  jav  a 2s .c  om
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I));
        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I));
    } else {
        sendModifiedKeyDownUp(KeyEvent.KEYCODE_TAB);
    }
}

From source file:org.apache.hadoop.hive.metastore.txn.TxnHandler.java

private static String compactorStateToResponse(char s) {
    switch (s) {//from  ww  w  . ja v a2 s. co  m
    case INITIATED_STATE:
        return INITIATED_RESPONSE;
    case WORKING_STATE:
        return WORKING_RESPONSE;
    case READY_FOR_CLEANING:
        return CLEANING_RESPONSE;
    case FAILED_STATE:
        return FAILED_RESPONSE;
    case SUCCEEDED_STATE:
        return SUCCEEDED_RESPONSE;
    case ATTEMPTED_STATE:
        return ATTEMPTED_RESPONSE;
    default:
        return Character.toString(s);
    }
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

protected void testLocationCountryBlanketApprove() throws InterruptedException {
    selectFrameIframePortlet();// w ww  . ja  va  2s.  c o m
    waitAndCreateNew();
    String docId = waitForDocId();
    assertBlanketApproveButtonsPresent();
    String twoUpperCaseLetters = RandomStringUtils.randomAlphabetic(2).toUpperCase();
    String countryName = "Validation Test Country " + ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits();
    waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, countryName);
    waitAndTypeByXpath(DOC_CODE_XPATH, twoUpperCaseLetters);
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", countryName);
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.alternateCode']",
            "V" + twoUpperCaseLetters);
    int attemptCount = 0;
    blanketApproveCheck();
    while (hasDocError("same primary key already exists") && attemptCount < 25) {
        clearTextByXpath(DOC_CODE_XPATH);
        waitAndTypeByXpath(DOC_CODE_XPATH,
                twoUpperCaseLetters.substring(0, 1) + Character.toString((char) ('A' + attemptCount++)));
        blanketApproveCheck();
    }
    blanketApproveAssert();
    assertDocFinal(docId);
}

From source file:ch.cyberduck.ui.cocoa.BrowserController.java

@Action
public void deleteBookmarkButtonClicked(final ID sender) {
    NSIndexSet iterator = bookmarkTable.selectedRowIndexes();
    final List<Host> selected = new ArrayList<Host>();
    for (NSUInteger index = iterator.firstIndex(); !index.equals(NSIndexSet.NSNotFound); index = iterator
            .indexGreaterThanIndex(index)) {
        selected.add(bookmarkModel.getSource().get(index.intValue()));
    }/*from   ww w .  ja  va2 s  .c  om*/
    StringBuilder alertText = new StringBuilder(
            LocaleFactory.localizedString("Do you want to delete the selected bookmark?"));
    int i = 0;
    Iterator<Host> iter = selected.iterator();
    while (i < 10 && iter.hasNext()) {
        alertText.append("\n").append(Character.toString('\u2022')).append(" ")
                .append(BookmarkNameProvider.toString(iter.next()));
        i++;
    }
    if (iter.hasNext()) {
        alertText.append("\n").append(Character.toString('\u2022')).append(" " + "");
    }
    final NSAlert alert = NSAlert.alert(LocaleFactory.localizedString("Delete Bookmark"), alertText.toString(),
            LocaleFactory.localizedString("Delete"), LocaleFactory.localizedString("Cancel"), null);
    this.alert(alert, new SheetCallback() {
        @Override
        public void callback(int returncode) {
            if (returncode == DEFAULT_OPTION) {
                bookmarkTable.deselectAll(null);
                bookmarkModel.getSource().removeAll(selected);
            }
        }
    });
}

From source file:org.domainmath.gui.MainFrame.java

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    MainFrame.octavePanel.start();//from w  ww .j a v  a2 s .  co m

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,
            Locale.getDefault());

    String t = "# -- " + formatter.format(new Date()) + " -- #";

    histArea.append(t + "\n");

    String path = Character.toString('"') + System.getProperty("user.dir") + File.separator + "scripts"
            + Character.toString('"');

    MainFrame.octavePanel.evaluate("addpath(genpath(" + path + "));savepath();");
    MainFrame.octavePanel.evaluate("DomainMath_OctavePaths('" + parent_root + "DomainMath_OctavePaths.dat');");

    MainFrame.octavePanel
            .evaluate("DomainMath_OctavePackages('" + parent_root + "DomainMath_OctavePackages.dat');");
    MainFrame.octavePanel
            .evaluate("DomainMath_OctaveVariables('" + parent_root + "DomainMath_OctaveVariables.dat',whos);");
    // MainFrame.workspace.reload();
    MainFrame.octavePanel
            .evaluate("DomainMath_OctaveConfig('" + parent_root + "DomainMath_OctaveConfig.dat');");

    String f = System.getProperty("user.dir") + File.separator + "cache" + File.separator + "pkg_list.xml";
    MainFrame.octavePanel.evaluate("DomainMath_PkgContents('" + f + "');");

    loadLayout();
    MainFrame.reloadWorkspace();
    loadPackageAuto();
    setDirComboContent();
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    new ModuleLoader().load(this, false);
    DMILogger.msg("DMI is Ready.");
}

From source file:ca.uhn.fhir.rest.client.GenericClient.java

private static String validateAndEscapeConditionalUrl(String theSearchUrl) {
    Validate.notBlank(theSearchUrl, "Conditional URL can not be blank/null");
    StringBuilder b = new StringBuilder();
    boolean haveHadQuestionMark = false;
    for (int i = 0; i < theSearchUrl.length(); i++) {
        char nextChar = theSearchUrl.charAt(i);
        if (!haveHadQuestionMark) {
            if (nextChar == '?') {
                haveHadQuestionMark = true;
            } else if (!Character.isLetter(nextChar)) {
                throw new IllegalArgumentException(
                        "Conditional URL must be in the format \"[ResourceType]?[Params]\" and must not have a base URL - Found: "
                                + theSearchUrl);
            }/*from  w w  w .  j a v a  2s . co  m*/
            b.append(nextChar);
        } else {
            switch (nextChar) {
            case '|':
            case '?':
            case '$':
            case ':':
                b.append(UrlUtil.escape(Character.toString(nextChar)));
                break;
            default:
                b.append(nextChar);
                break;
            }
        }
    }
    return b.toString();
}