List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:org.t2framework.commons.util.HtmlEscapeUtil.java
public void testescape_00A5_withDefaultStrategy() throws Exception { char c = '\u00a5'; assertEquals("¥", HtmlEscapeUtil.escape(Character.toString(c), false, false)); assertEquals("¥", HtmlEscapeUtil.escape(Character.toString(c), true, true)); c = '\u005c\';//from ww w. j a v a 2s.c o m assertNotSame("¥", HtmlEscapeUtil.escape(Character.toString(c), false, false)); assertNotSame("¥", HtmlEscapeUtil.escape(Character.toString(c), true, true)); assertEquals("\\", HtmlEscapeUtil.escape(Character.toString(c), false, false)); assertEquals("\\", HtmlEscapeUtil.escape(Character.toString(c), true, true)); }
From source file:com.expedia.tesla.compiler.Util.java
/** * Parse a Java {@code classpath} string to URLs. The {@code classpath} is represented with the same format of the * {@code CLASSPATH} variable or {@code -cp} java option. It supports the {@code *} wildcard. * /*from ww w . j av a 2 s. c o m*/ * @param classpath * the classpath string. * @return * URLs. * * @throws IOException * on IO errors. */ public static URL[] parseClassPath(String classpath) throws IOException { final String splitPattern = Character.toString(File.pathSeparatorChar); final String wildcardPattern = ".+\\*"; String[] paths = classpath.split(splitPattern); List<URL> urls = new ArrayList<URL>(); for (String path : paths) { path = path.trim(); if (path.matches(wildcardPattern)) { File folder = new File(path.replace("\\*", "")); if (folder.exists()) { File[] files = folder.listFiles(); for (File f : files) { urls.add(f.toURI().toURL()); } } } else { urls.add(new File(path).toURI().toURL()); } } URL[] result = new URL[urls.size()]; return urls.toArray(result); }
From source file:org.jdto.util.expression.Expression.java
private String readToken(String previousToken, String expression) { boolean operatorAllowed = true; //logic for negative numbers if (previousToken == null || previousToken.equals("(") || isOperator(previousToken)) { operatorAllowed = false;// w w w . j ava 2 s . c om } StringBuilder tokenBuilder = null; //convenience variable while (position < expression.length()) { //get and increment the character char character = expression.charAt(position++); //if is space, then ignore it if (character == ' ') { continue; } //if is parentheses if (character == '(' || character == ')') { return Character.toString(character); } if (isOperator(character) && operatorAllowed) { return Character.toString(character); } if (isOperator(character) && character != '-') { throw new IllegalArgumentException("Operator " + character + " not allowed here"); } //if none of the previous, then read a nuber or variable. tokenBuilder = getOrCreateBuilder(tokenBuilder); tokenBuilder.append(character); while (position < expression.length()) { character = expression.charAt(position++); if (character == ' ') { //this character is not important break; } if (character == ')' || isOperator(character)) { position--; break; } else { tokenBuilder.append(character); } } return tokenBuilder.toString(); } return null; }
From source file:com.bellman.bible.android.control.link.LinkControl.java
/** * IBT use _nn_ for punctuation chars in references to dictionaries e.g. _32_ represents a space so 'Holy_32_Spirit' should be converted to 'Holy Spirit' * * @param ref Key e.g. dictionary key//from ww w . j a v a2 s. c o m * @return ref with _nn_ replaced by punctuation */ private String replaceIBTSpecialCharacters(String ref) { Matcher refIBTSpecialCharMatcher = IBT_SPECIAL_CHAR_RE.matcher(ref); StringBuffer output = new StringBuffer(); while (refIBTSpecialCharMatcher.find()) { String specialChar = Character.toString((char) Integer.parseInt(refIBTSpecialCharMatcher.group(1))); refIBTSpecialCharMatcher.appendReplacement(output, specialChar); } refIBTSpecialCharMatcher.appendTail(output); return output.toString(); }
From source file:ml.shifu.shifu.core.binning.AbstractBinning.java
/** * convert @AbstractBinning to String//from www . j a va 2 s . c om * * @param objValStr * value string */ public void stringToObj(String objValStr) { String[] objStrArr = objValStr.split(Character.toString(FIELD_SEPARATOR), -1); if (objStrArr.length < 4) { throw new IllegalArgumentException("The size of argument is incorrect"); } missingValCnt = Integer.parseInt(StringUtils.trim(objStrArr[0])); invalidValCnt = Integer.parseInt(StringUtils.trim(objStrArr[1])); expectedBinningNum = Integer.parseInt(StringUtils.trim(objStrArr[2])); if (missingValSet == null) { missingValSet = new HashSet<String>(); } else { missingValSet.clear(); } String[] elements = objStrArr[3].split(Character.toString(SETLIST_SEPARATOR), -1); for (String element : elements) { missingValSet.add(element); } }
From source file:org.gradle.api.internal.plugins.StartScriptTemplateBindingFactory.java
private String escapeWindowsJvmOpt(String jvmOpts) { boolean wasOnBackslash = false; StringBuilder escapedJvmOpt = new StringBuilder(); CharacterIterator it = new StringCharacterIterator(jvmOpts); //argument quoting: // - " must be encoded as \" // - % must be encoded as %% // - pathological case: \" must be encoded as \\\", but other than that, \ MUST NOT be quoted // - other characters (including ') will not be quoted // - use a state machine rather than regexps for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) { String repl = Character.toString(ch); if (ch == '%') { repl = "%%"; } else if (ch == '"') { repl = (wasOnBackslash ? '\\' : "") + "\\\""; }/*from w w w . j a va2s . c o m*/ wasOnBackslash = ch == '\\'; escapedJvmOpt.append(repl); } return escapedJvmOpt.toString(); }
From source file:org.jboss.dashboard.commons.misc.ReflectionUtils.java
/** * Convert the fieldName to a valid name to be append to METHOD_PREFIX_GET/SET * * @param fieldName name of the accessor property * @return valid name for accessor/* w w w . j ava2 s. com*/ */ private static String getValidAccessorName(String fieldName) { char firstChar = fieldName.charAt(0); String field = StringUtil.toJavaClassName(fieldName); if (fieldName.length() > 1) { //fix if firstCharacter is lowercase and second is uppercase, then create correct accessor (i.e. getter for field xXX is getxXX) char secondChar = fieldName.charAt(1); if (Character.isLowerCase(firstChar) && Character.isUpperCase(secondChar)) { field = field.replaceFirst(Character.toString(field.charAt(0)), Character.toString(firstChar)); } } return field; }
From source file:com.inspiracode.nowgroup.scspro.xl.source.ExcelFile.java
private List<LogMessage> validateFieldNames(Sheet sheet) { List<LogMessage> result = new ArrayList<LogMessage>(); String nombreHoja = sheet.getSheetName(); String errDescription = ""; Row headingRow = sheet.getRow(HEADING_ROW); Properties prop = new Properties(); String propFileName = "excel/column_names.properties"; InputStream is = null;/*from ww w . j a va 2s . com*/ try { is = getClass().getClassLoader().getResourceAsStream(propFileName); if (is != null) { prop.load(is); for (int i = 1; i <= HEADING_COUNT; i++) { String expected = prop.getProperty(Integer.toString(i)); log.debug("Validando [" + Integer.toString(i) + "] validada como [" + headingRow.getCell(i - 1) + "]"); String current = headingRow.getCell(i - 1) == null || headingRow.getCell(i - 1).getStringCellValue() == null ? "" : headingRow.getCell(i - 1).getStringCellValue(); if (!expected.equals(current)) { int charValue = 64 + i; boolean aValue = false; if (charValue > 90) { charValue -= 25; aValue = true; } String columnName = aValue ? "A" : ""; columnName += Character.toString((char) charValue); errDescription = "La columna [" + nombreHoja + "]!" + columnName + " tiene el ttulo [" + current + "], " + " se esperaba: [" + expected + "]"; log.info(errDescription); result.add(new LogMessage("Validacin de encabezados", errDescription)); } else { log.debug("columna [" + expected + "] validada"); } } } else { errDescription = "Imposible abrir configuracin de campos de excel (column_names.properties)"; log.info(errDescription); result.add(new LogMessage("Validacin de encabezados", errDescription)); } } catch (Exception e) { errDescription = "Error al validar campos en la hoja [" + nombreHoja + "]: [" + e.getMessage() + "]"; log.error(errDescription, e); result.add(new LogMessage("Validacin de encabezados", errDescription)); } finally { if (is != null) { try { is.close(); } catch (Exception e) { log.error(e.getMessage(), e); } } } return result; }
From source file:org.apache.hadoop.hive.ql.stats.jdbc.JDBCStatsAggregator.java
@Override public String aggregateStats(String fileID, String statType) { if (!JDBCStatsUtils.isValidStatistic(statType)) { LOG.warn("Invalid statistic: " + statType + ", supported stats: " + JDBCStatsUtils.getSupportedStatistics()); return null; }/*w w w.j av a 2 s.c o m*/ Utilities.SQLCommand<ResultSet> execQuery = new Utilities.SQLCommand<ResultSet>() { @Override public ResultSet run(PreparedStatement stmt) throws SQLException { return stmt.executeQuery(); } }; JDBCStatsUtils.validateRowId(fileID); String keyPrefix = Utilities.escapeSqlLike(fileID) + "%"; for (int failures = 0;; failures++) { try { long retval = 0; PreparedStatement selStmt = columnMapping.get(statType); selStmt.setString(1, keyPrefix); selStmt.setString(2, Character.toString(Utilities.sqlEscapeChar)); ResultSet result = Utilities.executeWithRetry(execQuery, selStmt, waitWindow, maxRetries); if (result.next()) { retval = result.getLong(1); } else { LOG.warn("Nothing published. Nothing aggregated."); return null; } return Long.toString(retval); } catch (SQLRecoverableException e) { // need to start from scratch (connection) if (failures >= maxRetries) { return null; } // close the current connection closeConnection(); long waitTime = Utilities.getRandomWaitTime(waitWindow, failures, r); try { Thread.sleep(waitTime); } catch (InterruptedException iex) { } // getting a new connection if (!connect(hiveconf, sourceTask)) { // if cannot reconnect, just fail because connect() already handles retries. LOG.error("Error during publishing aggregation. " + e); return null; } } catch (SQLException e) { // for SQLTransientException (already handled by Utilities.*WithRetries() functions // and SQLNonTransientException, just declare failure. LOG.error("Error during publishing aggregation. " + e); return null; } } }