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.aurel.track.lucene.util.StringUtil.java

public static boolean endsWith(String s, char end) {
    return endsWith(s, Character.toString(end));
}

From source file:com.xmlcalabash.util.XMLtoJSON.java

private static void build(XdmNode json, JSONStringer js, int context) throws JSONException {
    String type = null;// w ww. j a  v a2  s  .c  o m

    if (JSONtoXML.JSONX_NS.equals(json.getNodeName().getNamespaceURI())
            || JSONtoXML.JXML_NS.equals(json.getNodeName().getNamespaceURI())) {
        type = json.getNodeName().getLocalName();
    } else {
        type = json.getAttributeValue(_type);
    }

    String name = null;
    if (JSONtoXML.MLJS_NS.equals(json.getNodeName().getNamespaceURI())) {
        name = json.getNodeName().getLocalName();
        if (name.contains("_")) {
            if ("_".equals(name)) {
                name = "";
            } else {
                String decoded = "";
                int upos = name.indexOf("_");
                while (upos >= 0) {
                    decoded += name.substring(0, upos);
                    String hex = name.substring(upos + 1, upos + 5);
                    int ch = Integer.parseInt(hex, 16);
                    decoded += Character.toString((char) ch);
                    name = name.substring(upos + 5);
                    upos = name.indexOf("_");
                }
                name = decoded + name;
            }
        }
    } else {
        name = json.getAttributeValue(_name);
    }

    if (context == OBJECT && name != null) {
        js.key(name);
    }

    if ("object".equals(type)) {
        js.object();
        processChildren(json, js, OBJECT);
        js.endObject();
    } else if ("array".equals(type)) {
        js.array();
        processChildren(json, js, ARRAY);
        js.endArray();
    } else if ("member".equals(type)) { // only happens for JXML
        processChildren(json, js, OBJECT);
    } else {
        if ("null".equals(type)) {
            js.value(null);
        } else if ("number".equals(type)) {
            String value = json.getStringValue();
            if (value.contains(".")) {
                Double d = Double.parseDouble(value);
                js.value(d);
            } else {
                long i = Long.parseLong(value);
                js.value(i);
            }
        } else if ("boolean".equals(type)) {
            js.value("true".equals(json.getStringValue()));
        } else {
            js.value(json.getStringValue());
        }
    }
}

From source file:org.diorite.cfg.messages.PluginMessages.java

/**
 * Returns messages for given plugin, may return null if plugin don't use diorite message system. :(
 *
 * @param plugin plugin to get messages.
 *
 * @return messages for given plugin or null.
 *///from  w w w .  jav a  2s  .  c om
public Messages getSubPluginMesssages(final ChildPlugin plugin) {
    return this.getMessages(StringUtils.replaceEach(plugin.getName(),
            new String[] { Character.toString(this.getNodeSeparator()), ChildPlugin.CHILD_SEPARATOR },
            new String[] { "_", this.getNodeSeparator() + "plugins" + this.getNodeSeparator() }));
}

From source file:fr.aliasource.webmail.common.folders.ListSubscribedFoldersCommand.java

public String initDefaultFolders(AccountConfiguration accountConf)
        throws IOException, StoreException, InterruptedException {
    String delim = null;//  w  ww.  j av a2  s  .  c  om
    IStoreConnection proto = account.getStoreProtocol();
    try {
        proto.subscribe("INBOX");
        ListResult infos = proto.list("", "*");
        Set<String> fNames = new HashSet<String>();
        if (infos != null) {
            delim = Character.toString(infos.getImapSeparator());
            for (ListInfo info : infos) {
                fNames.add(info.getName());
            }
            for (String folderName : AccountConfiguration.DEFAULT_FOLDERS) {
                createAndSubscribe(proto, fNames,
                        accountConf.getSetting(account.getUserId(), folderName).replace("%d", delim));
            }
        }
    } finally {
        proto.destroy();
    }
    return delim;
}

From source file:Main.java

/**
 * Takes an array of chars and returns all elements assembled in
 * a {@link String} joined by the defined separator.
 * <br>//  www.j a va  2s  . c om
 * Example: Create a {@link String} using an {@link char[]}
 * separated by ", ":
 * <br>
 * <code>
 * boolean[] array = {true, true, false};
 * <br>
 * String output = CollectionUtils.join(array, ", ");
 * <br>
 * </code>
 * 
 * @param collection a {@link boolean[]} of objects to join.
 * @param separator the {@link String} separator used to join the collection. 
 * @return {@link String} joined string.
 */
public static String join(char[] collection, String separator) {
    String output = "";
    for (int i = 0; i < collection.length - 1; i++) {
        String o = Character.toString(collection[i]);
        output += o + separator;
    }
    if (collection.length > 0)
        output += Character.toString(collection[collection.length - 1]);
    return output;
}

From source file:com.ansorgit.plugins.bash.editor.codecompletion.BashPathCommandCompletion.java

/**
 * Find the upper limit of the TreeSet map lookup. E.g. "git" has a upper lookup limit of "giu" (exclusive).
 *
 * @param prefix The prefix which should be used to retrieve all keys which start with this value
 * @return The key to use for the upper limit l
 *//*from ww  w  . jav a  2s  .  c  o  m*/
protected String findUpperLimit(String prefix) {
    if (prefix.isEmpty()) {
        return "z";
    }

    if (prefix.length() == 1) {
        char c = prefix.charAt(0);
        return c < 'z' ? Character.toString((char) (c + 1)) : "z";
    }

    //change the last character to 'z' to create the lookup range
    //if it already is 'z' then cut it of and call again with the substring
    char lastChar = prefix.charAt(prefix.length() - 1);
    if (lastChar < 'z') {
        return prefix.substring(0, prefix.length() - 1) + Character.toString((char) (lastChar + 1));
    }

    return findUpperLimit(prefix.substring(0, prefix.length() - 1));
}

From source file:de.tntinteractive.portalsammler.sources.IngDibaSourceV1.java

@Override
public Pair<Integer, Integer> poll(final SourceSettings settings, final UserInteraction gui,
        final SecureStore store) throws Exception {
    final WebDriver driver = this.createDriver("https://banking.ing-diba.de/app/login");

    final WebElement userField = driver.findElement(By.name("view:kontonummer:border:border_body:kontonummer"));
    userField.sendKeys(settings.get(USER, gui));

    final WebElement passwordField = driver.findElement(By.name("view:pin:border:border_body:pin"));
    passwordField.sendKeys(settings.get(PASSWORD, gui));

    passwordField.submit();/*from w ww.j a v  a  2  s.co  m*/

    waitForPresence(driver, By.className("dbkpBoard"));

    final List<Integer> missingValues = new ArrayList<Integer>();
    for (final WebElement possibleKeyInput : driver.findElements(By.tagName("input"))) {
        final String missingValuePrefix = "view:key:border:border_body:key:dbkpDisplayDiv:values:";
        final String name = possibleKeyInput.getAttribute("name");
        if (startsWith(name, missingValuePrefix)) {
            final String s = name.substring(missingValuePrefix.length(), missingValuePrefix.length() + 1);
            missingValues.add(Integer.parseInt(s));
        }
    }

    final String code = settings.get(CODE, gui);

    for (final Integer missing : missingValues) {
        final String number = Character.toString(code.charAt(missing));
        clickButton(driver, number);
    }

    clickButton(driver, "Anmelden");

    waitForPresence(driver, By.partialLinkText("Post-Box"));
    clickLink(driver, "Post-Box");

    (new WebDriverWait(driver, WAIT_TIME))
            .until(ExpectedConditions.invisibilityOfElementLocated(By.id("busy")));

    int newDocs = 0;
    int knownDocs = 0;
    try {
        final FileDownloader d = new FileDownloader(driver);
        for (final WebElement row : driver.findElements(By.tagName("tbody"))) {
            final DocumentInfo metadata = DocumentInfo.create(this.getId(), DocumentFormat.PDF);

            for (final WebElement cell : row.findElements(By.tagName("td"))) {
                final String text = cell.getText();
                if (this.isDate(text)) {
                    metadata.setDate(parseDate(text));
                } else {
                    metadata.addKeywords(text);
                }
            }

            if (!store.containsDocument(metadata)) {
                final WebElement link = row.findElement(By.tagName("a"));
                final byte[] file = d.downloadFile(link);
                store.storeDocument(metadata, file);
                newDocs++;
            } else {
                knownDocs++;
            }
        }

    } finally {
        clickLink(driver, "Log-out");
    }
    return Pair.of(newDocs, knownDocs);
}

From source file:com.chinamobile.bcbsp.util.StaffAttemptID.java

/**
 * Split string concatenation/*from   w  ww . j a va 2  s  . c  o m*/
 *
 * @param str That will be split string.
 * @return StaffAttemptID a unique identifier for a staff attempt.
 */
public static StaffAttemptID forName(String str) throws IllegalArgumentException {
    if (str == null) {
        return null;
    }
    try {
        String[] parts = str.split(Character.toString(SEPARATOR));
        if (parts.length == 5) {
            if (parts[0].equals(ATTEMPT)) {
                return new StaffAttemptID(parts[1], Integer.parseInt(parts[2]), Integer.parseInt(parts[3]),
                        Integer.parseInt(parts[4]));
            }
        }
    } catch (Exception ex) {
        LOG.error("[forName]", ex);
    }
    throw new IllegalArgumentException("StaffAttemptId string : " + str + " is not properly formed");
}

From source file:com.appdynamics.monitors.pingdom.communicator.PingdomCommunicator.java

@SuppressWarnings("rawtypes")
private void getCredits(Map<String, Integer> metrics) {

    try {/*  ww  w .  jav  a2s.  c o  m*/
        HttpClient httpclient = new DefaultHttpClient();

        UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
        HttpGet httpget = new HttpGet(baseAddress + "/api/2.0/credits");
        httpget.addHeader(BasicScheme.authenticate(creds, "US-ASCII", false));
        httpget.addHeader("App-Key", appkey);

        HttpResponse response;
        response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

        // reading in the JSON response
        String result = "";
        if (entity != null) {
            InputStream instream = entity.getContent();
            int b;
            try {
                while ((b = instream.read()) != -1) {
                    result += Character.toString((char) b);
                }
            } finally {
                instream.close();
            }
        }

        // parsing the JSON response
        try {

            JSONParser parser = new JSONParser();

            ContainerFactory containerFactory = new ContainerFactory() {
                public List creatArrayContainer() {
                    return new LinkedList();
                }

                public Map createObjectContainer() {
                    return new LinkedHashMap();
                }
            };

            // retrieving the metrics and populating HashMap
            JSONObject obj = (JSONObject) parser.parse(result);
            if (obj.get("credits") == null) {
                logger.error("Error retrieving data. " + obj);
                return;
            }
            Map json = (Map) parser.parse(obj.get("credits").toString(), containerFactory);

            if (json.containsKey("autofillsms")) {
                if (json.get("autofillsms").toString().equals("false")) {
                    metrics.put("Credits|autofillsms", 0);
                } else if (json.get("autofillsms").toString().equals("true")) {
                    metrics.put("Credits|autofillsms", 1);
                } else {
                    logger.error("can't determine whether Credits|autofillsms is true or false!");
                }
            }

            if (json.containsKey("availablechecks")) {
                try {
                    metrics.put("Credits|availablechecks",
                            Integer.parseInt(json.get("availablechecks").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|availablechecks!");
                }
            }

            if (json.containsKey("availablesms")) {
                try {
                    metrics.put("Credits|availablesms", Integer.parseInt(json.get("availablesms").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|availablesms!");
                }
            }

            if (json.containsKey("availablesmstests")) {
                try {
                    metrics.put("Credits|availablesmstests",
                            Integer.parseInt(json.get("availablesmstests").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|availablesmstests!");
                }
            }

            if (json.containsKey("checklimit")) {
                try {
                    metrics.put("Credits|checklimit", Integer.parseInt(json.get("checklimit").toString()));
                } catch (NumberFormatException e) {
                    logger.error("Error parsing metric value for Credits|checklimit!");
                }
            }

        } catch (ParseException e) {
            logger.error("JSON Parsing error: " + e.getMessage());
        } catch (Throwable e) {
            logger.error(e.getMessage());
        }

    } catch (IOException e1) {
        logger.error(e1.getMessage());
    } catch (Throwable t) {
        logger.error(t.getMessage());
    }

}

From source file:org.exoplatform.wiki.rendering.internal.parser.confluence.ConfluenceLinkReferenceParser.java

private String divideAfter(StringBuffer buffer, char divider) {
    if (buffer.length() == 0) {
        return null;
    }/*from w  ww .j  a  v  a  2 s.  c  o  m*/
    return divideAfter(buffer, buffer.indexOf(Character.toString(divider)));
}