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:com.nridge.core.base.std.StrUtl.java

/**
 * Expand the string into a list of individual values
 * using the delimiter character to identify each one.
 *
 * @param aString One or more values separated by a
 *                delimiter character./* w w  w . j av  a2 s . c  o m*/
 * @param aDelimiterChar Delimiter character.
 *
 * @return An ArrayList of String instances.
 */
public static ArrayList<String> expandToList(final String aString, char aDelimiterChar) {
    ArrayList<String> stringList = new ArrayList<String>();

    if (StringUtils.isNotEmpty(aString)) {
        String delimiterString = Character.toString(aDelimiterChar);
        if (aDelimiterChar == StrUtl.CHAR_PIPE)
            delimiterString = String.format("%c%c", StrUtl.CHAR_BACKSLASH, aDelimiterChar);
        String regExPattern = String.format("(?<!\\\\)%s", delimiterString);

        String[] valueArray = aString.split(regExPattern);
        for (String strValue : valueArray)
            stringList.add(unEscapeStringWithBackslash(strValue, aDelimiterChar));
    }

    return stringList;
}

From source file:com.amazonaws.services.kinesis.connectors.KinesisConnectorConfiguration.java

private char getCharacterProperty(String property, char defaultValue, Properties properties) {
    String propertyValue = properties.getProperty(property, Character.toString(defaultValue));
    if (propertyValue.length() == 1) {
        return propertyValue.charAt(0);
    }//  ww  w  . ja  v a2 s. c  o m
    return defaultValue;
}

From source file:com.example.android.Game.java

/**
 * Gets the id for the sign image letter/word
 * //from  w w  w . j av a  2  s .c om
 * @param word
 * @return the id number
 */
private int picSetter(String word) {
    int resource;

    if (word.equals(Character.toString(''))) {
        resource = getResources().getIdentifier("ae", "drawable", "com.example.android");
    } else if (word.equals(Character.toString(''))) {
        resource = getResources().getIdentifier("ao", "drawable", "com.example.android");
    } else if (word.equals(Character.toString(''))) {
        resource = getResources().getIdentifier("oe", "drawable", "com.example.android");
    } else {
        resource = getResources().getIdentifier(word, "drawable", "com.example.android");
    }

    return resource;
}

From source file:com.SwedishSignAlphabet.Game.java

/**
 * Gets the id for the sign image letter/word
 * //from  w  ww.  j ava  2  s. c o  m
 * @param word
 * @return the id number
 */
private int picSetter(String word) {
    int resource;

    if (word.equals(Character.toString(''))) {
        resource = getResources().getIdentifier("ae", "drawable", "com.SwedishSignAlphabet");
    } else if (word.equals(Character.toString(''))) {
        resource = getResources().getIdentifier("ao", "drawable", "com.SwedishSignAlphabet");
    } else if (word.equals(Character.toString(''))) {
        resource = getResources().getIdentifier("oe", "drawable", "com.SwedishSignAlphabet");
    } else {
        resource = getResources().getIdentifier(word, "drawable", "com.SwedishSignAlphabet");
    }

    return resource;
}

From source file:edu.stanford.muse.util.Util.java

/** capitalizes just the first letter and returns the given string */
public static String capitalizeFirstLetter(String str) {
    if (str == null)
        return null;
    if (str.length() == 0)
        return str;
    if (str.length() == 1)
        return Character.toString((Character.toUpperCase(str.charAt(0))));
    else//from   w ww .  j a va2 s . c  om
        return Character.toUpperCase(str.charAt(0)) + str.substring(1);
}

From source file:com.frameworkset.commons.dbcp2.BasicDataSourceFactory.java

/**
 * Parse list of property values from a delimited string
 * @param value delimited list of values
 * @param delimiter character used to separate values in the list
 * @return String Collection of values/*from   ww  w.  ja  v  a2  s .c  om*/
 */
private static Collection<String> parseList(String value, char delimiter) {
    StringTokenizer tokenizer = new StringTokenizer(value, Character.toString(delimiter));
    Collection<String> tokens = new ArrayList<String>(tokenizer.countTokens());
    while (tokenizer.hasMoreTokens()) {
        tokens.add(tokenizer.nextToken());
    }
    return tokens;
}

From source file:com.todoroo.astrid.activity.TaskListFragment.java

protected void setUpUiComponents() {
    // set listener for quick-changing task priority
    getListView().setOnKeyListener(new OnKeyListener() {
        @Override//from   w  w w .j a v  a 2  s .c  o m
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (event.getAction() != KeyEvent.ACTION_UP || view == null)
                return false;

            boolean filterOn = getListView().isTextFilterEnabled();
            View selected = getListView().getSelectedView();

            // hot-key to set task priority - 1-4 or ALT + Q-R
            if (!filterOn && event.getUnicodeChar() >= '1' && event.getUnicodeChar() <= '4'
                    && selected != null) {
                int importance = event.getNumber() - '1';
                Task task = ((ViewHolder) selected.getTag()).task;
                task.setValue(Task.IMPORTANCE, importance);
                taskService.save(task);
                taskAdapter.setFieldContentsAndVisibility(selected);
            }
            // filter
            else if (!filterOn && event.getUnicodeChar() != 0) {
                getListView().setTextFilterEnabled(true);
                getListView().setFilterText(Character.toString((char) event.getUnicodeChar()));
            }
            // turn off filter if nothing is selected
            else if (filterOn && TextUtils.isEmpty(getListView().getTextFilter())) {
                getListView().setTextFilterEnabled(false);
            }

            return false;
        }
    });

    SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(getActivity());
    sortFlags = publicPrefs.getInt(SortHelper.PREF_SORT_FLAGS, 0);
    sortSort = publicPrefs.getInt(SortHelper.PREF_SORT_SORT, 0);
    sortFlags = SortHelper.setManualSort(sortFlags, isDraggable());

    getView().findViewById(R.id.progressBar).setVisibility(View.GONE);
}

From source file:immf.ImodeNetClient.java

/**
 * imode.net????//from  ww w  .  j  ava 2s. co m
 *
 * @param mail
 * @return
 * @throws IOException
 */
public synchronized void sendMail(SenderMail mail, boolean forcePlaintext) throws IOException, LoginException {
    if (this.logined == null) {
        log.warn("i.net????????");
        this.logined = Boolean.FALSE;
        throw new LoginException("imode.net nologin");
    }
    if (this.logined != null && this.logined == Boolean.FALSE) {
        try {
            this.login();
        } catch (LoginException e) {
            throw new IOException("Could not login to imode.net");
        }
    }
    List<String> inlineFileIdList = new LinkedList<String>();
    List<String> attachmentFileIdList = new LinkedList<String>();
    if (!forcePlaintext) {
        // html?????
        for (SenderAttachment file : mail.getInlineFile()) {
            String docomoFileId = this.sendAttachFile(inlineFileIdList, true,
                    file.getContentTypeWithoutParameter(), file.getFilename(), file.getData());
            file.setDocomoFileId(docomoFileId);
        }
    }
    List<SenderAttachment> attachFiles = mail.getAttachmentFile();
    for (SenderAttachment file : attachFiles) {
        // ?
        this.sendAttachFile(attachmentFileIdList, false, file.getContentTypeWithoutParameter(),
                file.getFilename(), file.getData());
    }

    // html??
    boolean htmlMail = false;
    String body = null;
    if (forcePlaintext) {
        htmlMail = false;
        body = mail.getPlainBody();
    } else {
        body = mail.getHtmlBody(true);
        if (body == null) {
            htmlMail = false;
            body = mail.getPlainBody();
        } else {
            htmlMail = true;
        }
    }

    // html??????cid?
    if (htmlMail) {
        // (???? <img src="40_... ??)
        body = HtmlConvert.replaceAllCaseInsenstive(body, "<img src=\"cid:[^>]*>", "");
    }
    log.info("Html " + htmlMail);
    log.info("body " + body);

    MultipartEntity multi = new MultipartEntity();
    try {
        multi.addPart("folder.id", new StringBody("0", Charset.forName("UTF-8")));
        String mailType = null;
        if (htmlMail) {
            mailType = "1";
        } else {
            mailType = "0";
        }
        multi.addPart("folder.mail.type", new StringBody(mailType, Charset.forName("UTF-8")));

        // ?
        int recipient = 0;
        for (InternetAddress ia : mail.getTo()) {
            multi.addPart("folder.mail.addrinfo(" + recipient + ").mladdr",
                    new StringBody(ia.getAddress(), Charset.forName("UTF-8")));
            multi.addPart("folder.mail.addrinfo(" + recipient + ").type",
                    new StringBody("1", Charset.forName("UTF-8")));
            recipient++;
        }
        for (InternetAddress ia : mail.getCc()) {
            multi.addPart("folder.mail.addrinfo(" + recipient + ").mladdr",
                    new StringBody(ia.getAddress(), Charset.forName("UTF-8")));
            multi.addPart("folder.mail.addrinfo(" + recipient + ").type",
                    new StringBody("2", Charset.forName("UTF-8")));
            recipient++;
        }
        for (InternetAddress ia : mail.getBcc()) {
            multi.addPart("folder.mail.addrinfo(" + recipient + ").mladdr",
                    new StringBody(ia.getAddress(), Charset.forName("UTF-8")));
            multi.addPart("folder.mail.addrinfo(" + recipient + ").type",
                    new StringBody("3", Charset.forName("UTF-8")));
            recipient++;
        }
        if (recipient > 5) {
            throw new IOException("Too Much Recipient");
        }

        // ??
        multi.addPart("folder.mail.subject",
                new StringBody(Util.reverseReplaceUnicodeMapping(mail.getSubject()), Charset.forName("UTF-8")));

        // 
        body = Util.reverseReplaceUnicodeMapping(body);

        // imode.net?? ?10000Bytes?
        if (body.getBytes().length > 10000) {
            // ?byte???????????byte??
            log.warn("????????10000byte");
            throw new IOException("Too Big Message Body. Max 10000 byte.");
        }
        multi.addPart("folder.mail.data", new StringBody(body, Charset.forName("UTF-8")));

        if (!attachmentFileIdList.isEmpty()) {
            // 
            for (int i = 0; i < attachmentFileIdList.size(); i++) {
                multi.addPart("folder.tmpfile(" + i + ").file(0).id",
                        new StringBody(attachmentFileIdList.get(i), Charset.forName("UTF-8")));
            }
        }

        // ??????
        multi.addPart("iemoji(0).id",
                new StringBody(Character.toString((char) 0xe709), Charset.forName("UTF-8"))); // e709 = UTF-8?ee89c9?
        multi.addPart("iemoji(1).id",
                new StringBody(Character.toString((char) 0xe6f0), Charset.forName("UTF-8"))); // e6f0 = UTF-8?ee9bb0?

        multi.addPart("reqtype", new StringBody("0", Charset.forName("UTF-8")));

        HttpPost post = new HttpPost(SendMailUrl);
        try {
            addDumyHeader(post);
            post.setEntity(multi);

            HttpResponse res = this.executeHttp(post);
            if (!isJson(res)) {
                log.warn("?JSON??????");
                if (res != null) {
                    // JSON?????????????????
                    log.debug(toStringBody(res));
                    this.logined = Boolean.FALSE;
                    throw new LoginException("Bad response. no json format.");
                } else {
                    throw new IOException("imode.net not responding. Try later.");
                }
            }
            JSONObject json = JSONObject.fromObject(toStringBody(res));
            String result = json.getJSONObject("common").getString("result");
            if (result.equals("PW1409")) {
                // ????
                this.logined = Boolean.FALSE;
                throw new IOException("PW1409 - session terminated because of your bad mail.");
            } else if (result.equals("PW1430")) {
                // ???
                throw new IOException("PW1430 - User Unknown.");
            } else if (result.equals("PW1436")) {
                // ?????
                JSONArray jsonaddrs = json.getJSONObject("data").getJSONArray("seaddr");
                String addrs = "";
                for (int i = 0; i < jsonaddrs.size(); i++) {
                    if (i > 0) {
                        addrs += ", ";
                    }
                    addrs += jsonaddrs.getString(i);
                }
                throw new IOException("PW1436 - User Unknown.: " + addrs);
            } else if (!result.equals("PW1000")) {
                log.debug(json.toString(2));
                throw new IOException("Bad response " + result);
            }
        } finally {
            post.abort();
            log.info("??");
        }
    } catch (UnsupportedEncodingException e) {
        log.fatal(e);
    }
}

From source file:com.android.tools.lint.checks.GradleDetector.java

private void checkIntegerAsString(Context context, String value, Object valueCookie) {
    // When done developing with a preview platform you might be tempted to switch from
    //     compileSdkVersion 'android-G'
    // to//from   ww w .j a  v  a2s.c o m
    //     compileSdkVersion '19'
    // but that won't work; it needs to be
    //     compileSdkVersion 19
    String string = getStringLiteralValue(value);
    if (isNumberString(string)) {
        String quote = Character.toString(value.charAt(0));
        String message = String.format(
                "Use an integer rather than a string here " + "(replace %1$s%2$s%1$s with just %2$s)", quote,
                string);
        report(context, valueCookie, STRING_INTEGER, message);
    }
}

From source file:org.apache.phoenix.end2end.BasePermissionsIT.java

AccessTestAction readMultiTenantTableWithIndex(final String tableName, final String tenantId)
        throws SQLException {
    return new AccessTestAction() {
        @Override/*  ww  w  .j a  va2 s.c om*/
        public Object run() throws Exception {
            try (Connection conn = getConnection(tenantId); Statement stmt = conn.createStatement()) {
                // Accessing only the 'data' from the table uses index since index tables are built on 'data' column
                String readTableSQL = "SELECT data FROM " + tableName;
                ResultSet rs = stmt.executeQuery(readTableSQL);
                assertNotNull(rs);
                int i = 0;
                String explainPlan = Joiner.on(" ")
                        .join(((PhoenixStatement) stmt).getQueryPlan().getExplainPlan().getPlanSteps());
                assertTrue(explainPlan.contains("_IDX_"));
                rs = stmt.executeQuery(readTableSQL);
                if (tenantId != null) {
                    rs.next();
                    assertEquals(((PhoenixConnection) conn).getTenantId().toString(), tenantId);
                    // For tenant ID "o3", the value in table will be 3
                    assertEquals(Character.toString(tenantId.charAt(1)), rs.getString(1));
                    // Only 1 record is inserted per Tenant
                    assertFalse(rs.next());
                } else {
                    while (rs.next()) {
                        assertEquals(Integer.toString(i), rs.getString(1));
                        i++;
                    }
                    assertEquals(NUM_RECORDS, i);
                }
            }
            return null;
        }
    };
}