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.kuali.coeus.common.framework.person.signature.PersonSignatureLocationHelper.java

/**
 * This method is to find the count of first character in the signature tag
 * @return/*from  w ww .  j  a v  a2 s  .c o  m*/
 */
protected int getCountMatchOfSignatureTagFirstCharacter() {
    String firstChar = Character.toString(getCurrentSignatureTag().charAt(0));
    return StringUtils.countMatches(getCurrentSignatureTag(), firstChar);
}

From source file:ml.shifu.shifu.core.binning.CategoricalBinning.java

/**
 * convert @CategoricalBinning to String
 *///  w ww.  ja  va  2s  . c  o m
public void stringToObj(String objValStr) {
    super.stringToObj(objValStr);

    if (categoricalVals == null) {
        categoricalVals = new HashSet<String>();
    } else {
        categoricalVals.clear();
    }

    String[] objStrArr = CommonUtils.split(objValStr, Character.toString(FIELD_SEPARATOR));
    this.isValid = Boolean.valueOf(objStrArr[4]);
    if (objStrArr.length > 5 && StringUtils.isNotBlank(objStrArr[5])) {
        String[] elements = CommonUtils.split(objStrArr[5], Character.toString(SETLIST_SEPARATOR));
        for (String element : elements) {
            categoricalVals.add(element);
        }
    } else {
        log.warn("Empty categorical bin - " + objValStr);
    }
}

From source file:org.apache.tika.parser.ctakes.CTAKESConfig.java

private void init(InputStream stream) {
    if (stream == null) {
        return;//from   ww  w  .  ja  v  a  2  s.  c o  m
    }
    Properties props = new Properties();

    try {
        props.load(stream);
    } catch (IOException e) {
        // TODO warning
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException ioe) {
                // TODO warning
            }
        }
    }

    setAeDescriptorPath(props.getProperty("aeDescriptorPath", getAeDescriptorPath()));
    setUMLSUser(props.getProperty("UMLSUser", getUMLSUser()));
    setUMLSPass(props.getProperty("UMLSPass", getUMLSPass()));
    setText(Boolean.valueOf(props.getProperty("text", Boolean.toString(isText()))));
    setMetadata(props.getProperty("metadata", getMetadataAsString()).split(","));
    setAnnotationProps(props.getProperty("annotationProps", getAnnotationPropsAsString()).split(","));
    setSeparatorChar(props.getProperty("separatorChar", Character.toString(getSeparatorChar())).charAt(0));
}

From source file:org.apache.accumulo.test.YieldScannersIT.java

@Test
public void testScan() throws Exception {
    // make a table
    final String tableName = getUniqueNames(1)[0];
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        client.tableOperations().create(tableName);
        final BatchWriter writer = client.createBatchWriter(tableName, new BatchWriterConfig());
        for (int i = 0; i < 10; i++) {
            byte[] row = { (byte) (START_ROW + i) };
            Mutation m = new Mutation(new Text(row));
            m.put(new Text(), new Text(), new Value());
            writer.addMutation(m);/*from ww w.  j a  v a  2  s.  co  m*/
        }
        writer.flush();
        writer.close();

        log.info("Creating scanner");
        // make a scanner for a table with 10 keys
        try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) {
            final IteratorSetting cfg = new IteratorSetting(100, YieldingIterator.class);
            scanner.addScanIterator(cfg);

            log.info("iterating");
            Iterator<Map.Entry<Key, Value>> it = scanner.iterator();
            int keyCount = 0;
            int yieldNextCount = 0;
            int yieldSeekCount = 0;
            while (it.hasNext()) {
                Map.Entry<Key, Value> next = it.next();
                log.info(Integer.toString(keyCount) + ": Got key " + next.getKey() + " with value "
                        + next.getValue());

                // verify we got the expected key
                char expected = (char) (START_ROW + keyCount);
                assertEquals("Unexpected row", Character.toString(expected), next.getKey().getRow().toString());

                // determine whether we yielded on a next and seek
                if ((keyCount & 1) != 0) {
                    yieldNextCount++;
                    yieldSeekCount++;
                }
                String[] value = StringUtils.split(next.getValue().toString(), ',');
                assertEquals("Unexpected yield next count", Integer.toString(yieldNextCount), value[0]);
                assertEquals("Unexpected yield seek count", Integer.toString(yieldSeekCount), value[1]);
                assertEquals("Unexpected rebuild count", Integer.toString(yieldNextCount + yieldSeekCount),
                        value[2]);

                keyCount++;
            }
            assertEquals("Did not get the expected number of results", 10, keyCount);
        }
    }
}

From source file:com.bragi.sonify.composer.lsystem.LSystem.java

/**
 * Creates the next generation of a word from the input given by currentState.
 * @param currentState The current state to work with
 * @return The next generation of the word
 *///from www .  ja v  a 2s.c  o  m
private String nextStep(String currentState) {

    StringBuilder sb = new StringBuilder();

    for (char c : currentState.toCharArray()) {
        if (rules.containsKey(Character.toString(c))) {
            sb.append(rules.get(Character.toString(c)));
        } else {
            sb.append(Character.toString(c));
        }
    }

    return sb.toString();

}

From source file:cn.xiongyihui.wificar.Car.java

public void run() {
    Looper.prepare();/*from   w  w w  .ja v  a 2s . c  o  m*/

    mHandler = new Handler() {
        public void handleMessage(Message msg) {
            String url = "http://" + mIp + "/cgi-bin/serial?" + (String) msg.obj;
            URI uri = URI.create(url);

            HttpResponse httpResponse;
            DefaultHttpClient httpClient = new DefaultHttpClient();
            try {
                httpResponse = httpClient.execute(new HttpGet(uri));
            } catch (IOException e) {
                Log.v(TAG, "Unable to connect to car.");

                mState = STATE_UNCONNECTED;

                return;
            }

            char get;
            try {
                get = (char) httpResponse.getEntity().getContent().read();
            } catch (IOException e) {
                Log.v(TAG, "Unkown situation when connecting car.");

                mState = STATE_UNKOWN;
                return;
            }

            mState = mCommandList.indexOf(Character.toString(get));
        }
    };

    changeTo(STATE_STOP);

    Looper.loop();
}

From source file:de.fau.cs.osr.utils.StringUtils.java

public static String strrep(char c, int times) {
    return org.apache.commons.lang.StringUtils.repeat(Character.toString(c), times);
}

From source file:com.github.hexocraft.random.items.command.RiCommandList.java

@Override
public boolean onCommand(CommandInfo commandInfo) {
    String name = commandInfo.getNamedArg("name");

    if (RandomItemsApi.Count() == 0) {
        WarningMessage.toPlayer(commandInfo.getPlayer(), plugin.messages.eListEmpty);
    } else {//from  w w w  .j a va  2s.c o m
        if (name == null) {
            // Empty line
            EmptyMessage.toPlayer(commandInfo.getPlayer());

            // Title line
            Title title = new Title('-', ChatColor.AQUA, new Sentence(plugin.messages.mList, ChatColor.YELLOW));
            TitleMessage.toPlayer(commandInfo.getPlayer(), title);

            // Pools
            for (Map.Entry<String, RandomPool> entry : RandomItemsApi.getList().entrySet()) {
                // Create the clickable sentence
                Sentence poolName = new Sentence(
                        entry.getValue().getName() + (entry.getValue().getItemCount() > 0 ? " : " : ""));

                MessageBuilder hoverText = new MessageBuilder("");
                hoverText.append(plugin.messages.mListClick).color(MessageColor.SUBCOMMAND.color());
                ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND,
                        "/ri " + "l" + " " + entry.getValue().getName());
                HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText.create());
                poolName.color(MessageColor.COMMAND.color()).event(clickEvent).event(hoverEvent);

                // Line
                Line poolLine = new Line();
                poolLine.add(
                        new Sentence(Character.toString('\u00BB') + " ").color(MessageColor.COMMAND.color()));
                // - Pool
                poolLine.add(poolName);
                // - Number of items
                if (entry.getValue().getItemCount() > 0)
                    poolLine.add(new Sentence("" + entry.getValue().getItemCount() + " items")
                            .color(MessageColor.MANDATORY_ARGUMENT.color()));

                new Message(poolLine).send(commandInfo.getPlayer());
            }
        } else {
            if (RandomItemsApi.get(name) == null) {
                WarningMessage.toPlayer(commandInfo.getPlayer(), plugin.messages.eListEmpty);
            } else {
                RandomPool pool = RandomItemsApi.get(name);

                // Empty line
                EmptyMessage.toPlayer(commandInfo.getPlayer());

                // Title line
                Title title = new Title('-', ChatColor.AQUA,
                        new Sentence(plugin.messages.mList + " : " + pool.getName(), ChatColor.YELLOW));
                TitleMessage.toPlayer(commandInfo.getPlayer(), title);

                // Items
                for (RandomItem item : pool.getList()) {
                    // Item name / desc / ...
                    String itemName = "";
                    if (item.getItemStack() != null)
                        itemName = item.getName() + " (" + item.getItemStack().getAmount() + ")";
                    else if (item.getCommand() != null)
                        itemName = "Command : " + item.getCommand();
                    if (itemName.isEmpty() == false)
                        itemName += " : " + item.getWeight();

                    // Create the clickable sentence
                    Sentence itemInfo = new Sentence(itemName);

                    // Line
                    Line itemLine = new Line();
                    itemLine.add(new Sentence(Character.toString('\u00BB') + " ")
                            .color(MessageColor.COMMAND.color()));
                    // - Pool
                    itemLine.add(itemInfo);

                    new Message(itemLine).send(commandInfo.getPlayer());
                }
            }
        }
    }

    return true;
}

From source file:hammingcode.HammingCode.java

String takeNthPower(String str, int power) {
    String parityStr = "";
    for (int i = power - 1; i < str.length();) {
        int pos = power + i;
        while (i < pos) {
            if (i < str.length()) {
                parityStr += Character.toString(str.charAt(i));
            }//  w ww.j  av a  2s . c o m
            i++;
        }
        i += power;
    }
    return parityStr;
}

From source file:com.salesmanager.core.module.impl.application.currencies.USDCurrencyModule.java

public String getCurrencySymbol() {
    return Character.toString(DOLLAR);
}