List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:com.gst.infrastructure.core.serialization.JsonParserHelper.java
public Integer convertToInteger(final String numericalValueFormatted, final String parameterName, final Locale clientApplicationLocale) { if (clientApplicationLocale == null) { final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final String defaultMessage = new StringBuilder( "The parameter '" + parameterName + "' requires a 'locale' parameter to be passed with it.") .toString();//from ww w . ja v a2 s .co m final ApiParameterError error = ApiParameterError .parameterError("validation.msg.missing.locale.parameter", defaultMessage, parameterName); dataValidationErrors.add(error); throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } try { Integer number = null; if (StringUtils.isNotBlank(numericalValueFormatted)) { String source = numericalValueFormatted.trim(); final NumberFormat format = NumberFormat.getInstance(clientApplicationLocale); final DecimalFormat df = (DecimalFormat) format; final DecimalFormatSymbols symbols = df.getDecimalFormatSymbols(); df.setParseBigDecimal(true); // http://bugs.sun.com/view_bug.do?bug_id=4510618 final char groupingSeparator = symbols.getGroupingSeparator(); if (groupingSeparator == '\u00a0') { source = source.replaceAll(" ", Character.toString('\u00a0')); } final Number parsedNumber = df.parse(source); final double parsedNumberDouble = parsedNumber.doubleValue(); final int parsedNumberInteger = parsedNumber.intValue(); if (source.contains(Character.toString(symbols.getDecimalSeparator()))) { throw new ParseException(source, 0); } if (!Double.valueOf(parsedNumberDouble) .equals(Double.valueOf(Integer.valueOf(parsedNumberInteger)))) { throw new ParseException(source, 0); } number = parsedNumber.intValue(); } return number; } catch (final ParseException e) { final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final ApiParameterError error = ApiParameterError.parameterError( "validation.msg.invalid.integer.format", "The parameter " + parameterName + " has value: " + numericalValueFormatted + " which is invalid integer value for provided locale of [" + clientApplicationLocale.toString() + "].", parameterName, numericalValueFormatted, clientApplicationLocale); error.setValue(numericalValueFormatted); dataValidationErrors.add(error); throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } }
From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.por.PORFileReader.java
private void decodeNumberOfVariables(BufferedReader reader) throws IOException { if (reader == null) { throw new IllegalArgumentException("decodeNumberOfVariables: reader == null!"); }/*from w w w . j av a 2s .c o m*/ String temp = null; char[] tmp = new char[1]; StringBuilder sb = new StringBuilder(); while (reader.read(tmp) > 0) { temp = Character.toString(tmp[0]); if (temp.equals("/")) { break; } else { sb.append(temp); } } String rawNumberOfVariables = sb.toString(); int rawLength = rawNumberOfVariables.length(); String numberOfVariables = StringUtils.stripStart((StringUtils.strip(rawNumberOfVariables)), "0"); if ((numberOfVariables.equals("")) && (numberOfVariables.length() == rawLength)) { numberOfVariables = "0"; } varQnty = Integer.valueOf(numberOfVariables, 30); smd.getFileInformation().put("varQnty", varQnty); }
From source file:com.npower.dm.processor.BaseProcessor.java
/** * @param sessionContext/* w ww .j a va2 s . c o m*/ */ protected void trackJobLog(SessionContext sessionContext) { try { DMJobLogger jobLogger = DMJobLoggerFactory.newInstance().getLogger(); String deviceExtID = sessionContext.getDmstate().deviceId; long jobID = 0; if (StringUtils.isNotEmpty(sessionContext.getDmstate().mssid)) { jobID = Long.parseLong(sessionContext.getDmstate().mssid); } Date startTime = sessionContext.getDmstate().start; Date endTime = sessionContext.getDmstate().end; String dmSessionID = sessionContext.getHttpSessionId(); String sessionStatus = Character.toString((char) sessionContext.getDmstate().state); jobLogger.log(dmSessionID, jobID, deviceExtID, this, startTime, endTime, sessionStatus); } catch (NumberFormatException e) { log.error("Failure to tracking job log.", e); } catch (Exception e) { log.error("Failure to tracking job log.", e); } }
From source file:org.apache.phoenix.schema.stats.BaseStatsCollectorIT.java
@Test public void testWithMultiCF() throws Exception { int nRows = 20; Connection conn = getConnection(0); PreparedStatement stmt;//from w w w . j a v a2 s . co m conn.createStatement() .execute("CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY KEY, a.v INTEGER, b.v INTEGER, c.v INTEGER NULL, d.v INTEGER NULL) " + tableDDLOptions); stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + " VALUES(?,?, ?, ?, ?)"); byte[] val = new byte[250]; for (int i = 0; i < nRows; i++) { stmt.setString(1, Character.toString((char) ('a' + i)) + Bytes.toString(val)); stmt.setInt(2, i); stmt.setInt(3, i); stmt.setInt(4, i); stmt.setInt(5, i); stmt.executeUpdate(); } conn.commit(); stmt = conn.prepareStatement("UPSERT INTO " + fullTableName + "(k, c.v, d.v) VALUES(?,?,?)"); for (int i = 0; i < 5; i++) { stmt.setString(1, Character.toString((char) ('a' + 'z' + i)) + Bytes.toString(val)); stmt.setInt(2, i); stmt.setInt(3, i); stmt.executeUpdate(); } conn.commit(); ResultSet rs; collectStatistics(conn, fullTableName); List<KeyRange> keyRanges = getAllSplits(conn, fullTableName); assertEquals(26, keyRanges.size()); rs = conn.createStatement().executeQuery("EXPLAIN SELECT * FROM " + fullTableName); assertEquals("CLIENT 26-CHUNK 25 ROWS " + (columnEncoded ? (mutable ? "12530" : "13902") : (TransactionFactory.Provider.OMID.name().equals(transactionProvider)) ? "25044" : "12420") + " BYTES PARALLEL 1-WAY FULL SCAN OVER " + physicalTableName, QueryUtil.getExplainPlan(rs)); ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); List<HRegionLocation> regions = services.getAllTableRegions(Bytes.toBytes(physicalTableName)); assertEquals(1, regions.size()); collectStatistics(conn, fullTableName, Long.toString(1000)); keyRanges = getAllSplits(conn, fullTableName); boolean oneCellPerColFamliyStorageScheme = !mutable && columnEncoded; boolean hasShadowCells = TransactionFactory.Provider.OMID.name().equals(transactionProvider); assertEquals(oneCellPerColFamliyStorageScheme ? 13 : hasShadowCells ? 23 : 12, keyRanges.size()); rs = conn.createStatement().executeQuery( "SELECT COLUMN_FAMILY,SUM(GUIDE_POSTS_ROW_COUNT),SUM(GUIDE_POSTS_WIDTH),COUNT(*) from \"SYSTEM\".STATS where PHYSICAL_NAME = '" + physicalTableName + "' GROUP BY COLUMN_FAMILY ORDER BY COLUMN_FAMILY"); assertTrue(rs.next()); assertEquals("A", rs.getString(1)); assertEquals(24, rs.getInt(2)); assertEquals(columnEncoded ? (mutable ? 12252 : 13624) : hasShadowCells ? 24756 : 12144, rs.getInt(3)); assertEquals(oneCellPerColFamliyStorageScheme ? 12 : hasShadowCells ? 22 : 11, rs.getInt(4)); assertTrue(rs.next()); assertEquals("B", rs.getString(1)); assertEquals(oneCellPerColFamliyStorageScheme ? 24 : 20, rs.getInt(2)); assertEquals(columnEncoded ? (mutable ? 5600 : 6972) : hasShadowCells ? 11260 : 5540, rs.getInt(3)); assertEquals(oneCellPerColFamliyStorageScheme ? 6 : hasShadowCells ? 10 : 5, rs.getInt(4)); assertTrue(rs.next()); assertEquals("C", rs.getString(1)); assertEquals(24, rs.getInt(2)); assertEquals(columnEncoded ? (mutable ? 6724 : 6988) : hasShadowCells ? 13520 : 6652, rs.getInt(3)); assertEquals(hasShadowCells ? 12 : 6, rs.getInt(4)); assertTrue(rs.next()); assertEquals("D", rs.getString(1)); assertEquals(24, rs.getInt(2)); assertEquals(columnEncoded ? (mutable ? 6724 : 6988) : hasShadowCells ? 13520 : 6652, rs.getInt(3)); assertEquals(hasShadowCells ? 12 : 6, rs.getInt(4)); assertFalse(rs.next()); // Disable stats conn.createStatement().execute( "ALTER TABLE " + fullTableName + " SET " + PhoenixDatabaseMetaData.GUIDE_POSTS_WIDTH + "=0"); collectStatistics(conn, fullTableName); // Assert that there are no more guideposts rs = conn.createStatement() .executeQuery("SELECT count(1) FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " WHERE " + PhoenixDatabaseMetaData.PHYSICAL_NAME + "='" + physicalTableName + "' AND " + PhoenixDatabaseMetaData.COLUMN_FAMILY + " IS NOT NULL"); assertTrue(rs.next()); assertEquals(0, rs.getLong(1)); assertFalse(rs.next()); rs = conn.createStatement().executeQuery("EXPLAIN SELECT * FROM " + fullTableName); assertEquals("CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER " + physicalTableName, QueryUtil.getExplainPlan(rs)); }
From source file:io.doist.datetimepicker.time.TimePickerClockDelegate.java
/** * The time separator is defined in the Unicode CLDR and cannot be supposed to be ":". * * See http://unicode.org/cldr/trac/browser/trunk/common/main * * We pass the correct "skeleton" depending on 12 or 24 hours view and then extract the * separator as the character which is just after the hour marker in the returned pattern. *//*w w w.ja va 2s . c om*/ private void updateHeaderSeparator() { final String bestDateTimePattern = getBestTimePattern(mCurrentLocale, mIs24HourView); final String separatorText; // See http://www.unicode.org/reports/tr35/tr35-dates.html for hour formats final char[] hourFormats = { 'H', 'h', 'K', 'k' }; int hIndex = lastIndexOfAny(bestDateTimePattern, hourFormats); if (hIndex == -1) { // Default case separatorText = ":"; } else { separatorText = Character.toString(bestDateTimePattern.charAt(hIndex + 1)); } mSeparatorView.setText(separatorText); }
From source file:net.malisis.core.client.gui.component.interaction.UITextField.java
/** * Called when a key is pressed.//from w w w .ja v a 2 s. c o m * * @param event the event */ @Subscribe public void keyTyped(KeyboardEvent event) { if (!focused) return; char keyChar = event.getKeyChar(); int keyCode = event.getKeyCode(); if (keyCode == Keyboard.KEY_ESCAPE) return; event.cancel(); if (handleCtrlKeyDown(keyCode)) return; switch (keyCode) { case Keyboard.KEY_LEFT: startSelecting(); cursorPosition.shiftLeft(); return; case Keyboard.KEY_RIGHT: startSelecting(); cursorPosition.shiftRight(); return; case Keyboard.KEY_UP: if (multiLine) { startSelecting(); cursorPosition.jumpLine(true); } return; case Keyboard.KEY_DOWN: if (multiLine) { startSelecting(); cursorPosition.jumpLine(false); } return; case Keyboard.KEY_HOME: startSelecting(); cursorPosition.jumpToLineStart(); return; case Keyboard.KEY_END: startSelecting(); cursorPosition.jumpToLineEnd(); return; case Keyboard.KEY_BACK: this.deleteFromCursor(-1); return; case Keyboard.KEY_DELETE: this.deleteFromCursor(1); return; default: if (ChatAllowedCharacters.isAllowedCharacter(keyChar) || (multiLine && keyCode == Keyboard.KEY_RETURN)) this.addText(Character.toString(keyChar)); return; } }
From source file:com.tr4android.support.extension.picker.time.AppCompatTimePickerDelegate.java
/** * The time separator is defined in the Unicode CLDR and cannot be supposed to be ":". * * See http://unicode.org/cldr/trac/browser/trunk/common/main * * We pass the correct "skeleton" depending on 12 or 24 hours view and then extract the * separator as the character which is just after the hour marker in the returned pattern. *///from ww w . j a v a 2 s .c o m private void updateHeaderSeparator() { final String bestDateTimePattern = DateFormatUtils.getBestDateTimePattern(mCurrentLocale, (mIs24HourView) ? "Hm" : "hm"); final String separatorText; // See http://www.unicode.org/reports/tr35/tr35-dates.html for hour formats final char[] hourFormats = { 'H', 'h', 'K', 'k' }; int hIndex = lastIndexOfAny(bestDateTimePattern, hourFormats); if (hIndex == -1) { // Default case separatorText = ":"; } else { separatorText = Character.toString(bestDateTimePattern.charAt(hIndex + 1)); } mSeparatorView.setText(separatorText); }
From source file:org.infoscoop.util.HtmlUtil.java
/** * substitute "<>"&" for "&lt;&gt;&quot;&amp;". * /*from ww w . j a v a 2s . c o m*/ * @param ch * @return */ public static String escapeHtmlEntities(char ch) { if (ch == '&') { return "&"; } else if (ch == '<') { return "<"; } else if (ch == '>') { return ">"; } else if (ch == '"') { return """; } else { return Character.toString(ch); } }
From source file:org.j2free.util.ServletUtils.java
/** * Returns the argument String surrounded in the argument quore with any pf * the argument quotes that were in the string escaped. * @param toQuote //from w ww.j ava2 s. c om * @param quote * @return */ public static String quote(String toQuote, char quote) { return String.format("%s%s%s", quote, toQuote.replace(Character.toString(quote), "\\" + quote), quote); }
From source file:org.apache.ambari.server.controller.utilities.PropertyHelper.java
/** * Returns tag inserted metric name after the prefix. * @param tag E.g.: client/* w ww . j ava 2 s . c o m*/ * @param metricName : rpc.rpc.CallQueueLength Or metrics/rpc/CallQueueLen * @param prefix : rpc.rpc * @return rpc.rpc.client.CallQueueLength Or metrics/rpc/client/CallQueueLen */ static String insertTagInToMetricName(String tag, String metricName, String prefix) { String sepExpr = "\\."; String seperator = "."; if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) { sepExpr = Character.toString(EXTERNAL_PATH_SEP); seperator = sepExpr; } String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP; // Remove separator if any if (prefix.substring(prefix.length() - 1).equals(prefixSep)) { prefix = prefix.substring(0, prefix.length() - 1); } int pos = prefix.split(prefixSep).length - 1; String[] parts = metricName.split(sepExpr); StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.length; i++) { sb.append(parts[i]); if (i < parts.length - 1) { sb.append(seperator); } if (i == pos) { // append the tag sb.append(tag); sb.append(seperator); } } return sb.toString(); }