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.amazonaws.services.cognito.streams.connector.AmazonCognitoStreamsEventBeanTransformer.java

/**
 * Remove characters known to cause issues in Redshift import
 * @param string/*  ww  w  .j  a  v  a  2s .co  m*/
 * @return
 */
private String sanitize(String string) {
    if (string == null) {
        return null;
    }
    string = string.replace("\n", " ");
    string = string.replace(Character.toString(delim), " ");
    string = string.replaceAll("\\x00", "?");
    return string;
}

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

public String objToString() {
    return super.objToString() + Character.toString(FIELD_SEPARATOR) + Double.toString(maxVal)
            + Character.toString(FIELD_SEPARATOR) + Double.toString(minVal);
}

From source file:ee.ria.xroad.asyncdb.AsyncLogWriterBehavior.java

License:asdf

/**
 * Tests whether the entry is correctly written into async log.
 *
 * @throws Exception - when writing entry into async log fails.
 *///from  ww w . j a v a  2 s. co m
@Test
public void shouldWriteCorrectlyToAsyncLog() throws Exception {
    // Initialize
    String lastSendResult1 = "OK";
    int requestSendCount1 = 0;

    Date receivedTime1 = new Date(1292509011);

    ClientId client1 = ClientId.create("EE", "GOV", "client1");
    ServiceId service1 = ServiceId.create("EE", "GOV", "client1", null, "service1");

    RequestInfo request1 = new RequestInfo(0, "d41d8cd98f00b204e9800998ecf8427e", receivedTime1, null, client1,
            "EE27001010001", service1);

    AsyncLogWriter logWriter1 = new AsyncLogWriter(service1.getClientId());

    String lastSendResult2 = "NOK";
    int requestSendCount2 = 7;

    Date receivedTime2 = new Date(1292509311);
    Date removedTime2 = new Date(1292509321);

    ClientId client2 = ClientId.create("EE", "GOV", "client2");
    ServiceId service2 = ServiceId.create("EE", "GOV", "client2", null, "service2");

    RequestInfo request2 = new RequestInfo(1, "tab\tnewline\nbackslash\\asdfs", receivedTime2, removedTime2,
            client2, "EE27001010002", service2);

    AsyncLogWriter logWriter2 = new AsyncLogWriter(service2.getClientId());

    // Write
    logWriter1.appendToLog(request1, lastSendResult1, requestSendCount1);

    logWriter2.appendToLog(request2, lastSendResult2, requestSendCount2);

    // Validate
    List<String> logFileLines = FileUtils.readLines(new File(ASYNC_LOG_PATH), StandardCharsets.UTF_8);

    assertEquals(2, logFileLines.size());

    String[] firstLineData = logFileLines.get(0).split(Character.toString(AsyncLogWriter.FIELD_SEPARATOR));

    assertEquals(AsyncDBTestUtil.LOG_FILE_FIELDS, firstLineData.length);

    assertTrue(StringUtils.isNotBlank(firstLineData[FIELD_LOGGING_TIME]));
    assertEquals("1292509", firstLineData[FIELD_RECEIVED_TIME]);
    assertEquals("0", firstLineData[FIELD_REMOVED_TIME]);
    assertEquals("OK", firstLineData[FIELD_SENDING_RESULT]);
    assertEquals("0", firstLineData[FIELD_FIRST_REQUEST_SEND_COUNT]);
    assertEquals("EE/GOV/client1", firstLineData[FIELD_PROVIDER_NAME]);
    assertEquals(client1.toString(), firstLineData[FIELD_SENDER]);
    assertEquals("EE27001010001", firstLineData[FIELD_USER]);
    assertEquals(service1.toString(), firstLineData[FIELD_SERVICE]);
    assertEquals("d41d8cd98f00b204e9800998ecf8427e", firstLineData[FIELD_ID]);

    String[] secondLineData = logFileLines.get(1).split(Character.toString(AsyncLogWriter.FIELD_SEPARATOR));

    assertEquals(AsyncDBTestUtil.LOG_FILE_FIELDS, secondLineData.length);

    assertTrue(StringUtils.isNotBlank(secondLineData[FIELD_LOGGING_TIME]));
    assertEquals("1292509", secondLineData[FIELD_RECEIVED_TIME]);
    assertEquals("1292509", secondLineData[FIELD_REMOVED_TIME]);
    assertEquals("NOK", secondLineData[FIELD_SENDING_RESULT]);
    assertEquals("7", secondLineData[FIELD_FIRST_REQUEST_SEND_COUNT]);
    assertEquals("EE/GOV/client2", secondLineData[FIELD_PROVIDER_NAME]);
    assertEquals(client2.toString(), secondLineData[FIELD_SENDER]);
    assertEquals("EE27001010002", secondLineData[FIELD_USER]);
    assertEquals(service2.toString(), secondLineData[FIELD_SERVICE]);

    String expectedSecondId = StringEscapeUtils.escapeJava("tab\tnewline\nbackslash\\asdfs");
    assertEquals(expectedSecondId, secondLineData[FIELD_ID]);
}

From source file:com.naman14.timber.adapters.SongsListAdapter.java

@Override
public String getTextToShowInBubble(final int pos) {
    Character ch = arraylist.get(pos).title.charAt(0);
    if (Character.isDigit(ch)) {
        return "#";
    } else//  w w  w.  jav a 2 s .co  m
        return Character.toString(ch);
}

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

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

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

@Test
public void testSerialObject() {
    EqualPopulationBinning binning = new EqualPopulationBinning(10);
    String binStr = binning.objToString();
    String[] fieldArr = binStr.split(Character.toString(AbstractBinning.FIELD_SEPARATOR));
    Assert.assertTrue(fieldArr.length == 5);
}

From source file:io.wcm.handler.url.suffix.impl.UrlSuffixUtil.java

/**
 * Decode key/*from w ww  .j  a  va2s.  c o  m*/
 * @param suffixPart Suffix part
 * @return Decoded key
 */
public static String decodeKey(String suffixPart) {
    // key is the part *before* KEY_VALUE_DELIMITER
    String key = StringUtils.substringBefore(suffixPart, Character.toString(KEY_VALUE_DELIMITER));

    // un-escape special chars
    for (Map.Entry<String, String> entry : SPECIAL_CHARS_ESCAPEMAP.entrySet()) {
        key = StringUtils.replace(key, entry.getValue(), entry.getKey());
    }

    return key;
}

From source file:org.jamwiki.db.WikiPreparedStatement.java

/**
 *
 *///  ww  w  . j  a v  a2  s .c  o m
private void loadStatement() throws Exception {
    for (int i = 0; i < this.paramTypes.length; i++) {
        if (params[i] == null) {
            this.statement.setNull(i + 1, paramTypes[i]);
        } else if (paramTypes[i] == Types.CHAR) {
            char value = ((Character) params[i]).charValue();
            this.statement.setString(i + 1, Character.toString(value));
        } else if (paramTypes[i] == Types.INTEGER) {
            int value = ((Integer) params[i]).intValue();
            this.statement.setInt(i + 1, value);
        } else if (paramTypes[i] == Types.TIMESTAMP) {
            Timestamp value = (Timestamp) params[i];
            this.statement.setTimestamp(i + 1, value);
        } else if (paramTypes[i] == Types.VARCHAR) {
            String value = (String) params[i];
            this.statement.setString(i + 1, value);
        }
    }
}

From source file:com.dbschools.quickquiz.client.giver.MainWindow.java

private void addListeners() {
    takerTableDisplay.addTableKeyListener(new KeyAdapter() {
        @Override/*w  ww  .  jav a2 s .c o  m*/
        public void keyPressed(KeyEvent e) {
            char keyChar = e.getKeyChar();
            if (Character.isDigit(keyChar) && e.isControlDown()) {
                awardPoints(Integer.parseInt(Character.toString(keyChar)));
            }
        }
    });
    final ListSelectionModel takerTableSelectionModel = takerTableDisplay.getSelectionModel();
    takerTableSelectionModel.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            btnAwardPoints.setEnabled(!takerTableSelectionModel.isSelectionEmpty());
        }
    });
    countdownMeter.addCountdownFinishListener(new CountdownFinishListener() {
        public void countdownFinished() {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    btnSendQuestion.setEnabled(true);
                }
            });
        }
    });
}

From source file:org.kiji.schema.hbase.KijiManagedHBaseTableName.java

/**
 * Constructs using an HBase HTable name.
 *
 * @param hbaseTableName The HBase HTable name.
 * @return A new kiji-managed HBase table name.
 * @throws NotAKijiManagedTableException If the HBase table is not managed by kiji.
 *//* w  w w .j  a v a  2s. c  om*/
public static KijiManagedHBaseTableName get(String hbaseTableName) throws NotAKijiManagedTableException {
    // Split it into components.
    String[] components = StringUtils.splitPreserveAllTokens(hbaseTableName, Character.toString(DELIMITER), 4);

    // Make sure the first component is 'kiji'.
    if (!components[0].equals(KIJI_COMPONENT)) {
        throw new NotAKijiManagedTableException(hbaseTableName, "Doesn't start with kiji name component.");
    }

    if (components.length == 3) {
        // It's a managed kiji meta/schema/system table.
        return new KijiManagedHBaseTableName(components[1], components[2]);
    } else if (components.length == 4) {
        // It's a user-space kiji table.
        return new KijiManagedHBaseTableName(components[1], components[2], components[3]);
    } else {
        // Wrong number of components... must not be a kiji table.
        throw new NotAKijiManagedTableException(hbaseTableName, "Invalid number of name components.");
    }
}