List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:org.apache.hadoop.hive.ql.stats.jdbc.JDBCStatsAggregator.java
@Override public boolean cleanUp(String rowID) { Utilities.SQLCommand<Void> execUpdate = new Utilities.SQLCommand<Void>() { @Override/*from w w w .jav a 2s . co m*/ public Void run(PreparedStatement stmt) throws SQLException { stmt.executeUpdate(); return null; } }; try { JDBCStatsUtils.validateRowId(rowID); String keyPrefix = Utilities.escapeSqlLike(rowID) + "%"; PreparedStatement delStmt = Utilities.prepareWithRetry(conn, JDBCStatsUtils.getDeleteAggr(rowID, comment), waitWindow, maxRetries); delStmt.setString(1, keyPrefix); delStmt.setString(2, Character.toString(Utilities.sqlEscapeChar)); for (int failures = 0;; failures++) { try { Utilities.executeWithRetry(execUpdate, delStmt, waitWindow, maxRetries); return true; } catch (SQLRecoverableException e) { // need to start from scratch (connection) if (failures >= maxRetries) { LOG.error("Error during clean-up after " + maxRetries + " retries. " + e); return false; } // 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)) { LOG.error("Error during clean-up. " + e); return false; } } catch (SQLException e) { // for SQLTransientException (already handled by Utilities.*WithRetries() functions // and SQLNonTransientException, just declare failure. LOG.error("Error during clean-up. " + e); return false; } } } catch (SQLException e) { LOG.error("Error during publishing aggregation. " + e); return false; } }
From source file:ca.sfu.federation.model.Expression.java
/** * Determines if a string value can be converted to a number. * @return True if the value can be converted to a number. *//* w ww. j av a 2s . com*/ private static boolean isNumberLiteral(char c) { return isNumberLiteral(Character.toString(c)); }
From source file:com.igormaznitsa.mindmap.model.ModelUtils.java
@Nonnull public static String escapeURIPath(@Nonnull final String text) { final String chars = "% :<>?"; //NOI18N String result = text;//from w w w. j a v a 2 s . com for (final char ch : chars.toCharArray()) { result = result.replace(Character.toString(ch), "%" + Integer.toHexString(ch).toUpperCase(Locale.ENGLISH)); //NOI18N } return result; }
From source file:org.apache.fop.fonts.truetype.OFFontLoader.java
private void copyGlyphMetricsSingleByte(OpenFont otf) { int[] wx = otf.getWidths(); Rectangle[] bboxes = otf.getBoundingBoxes(); for (int i = singleFont.getFirstChar(); i <= singleFont.getLastChar(); i++) { singleFont.setWidth(i, otf.getCharWidth(i)); int[] bbox = otf.getBBox(i); singleFont.setBoundingBox(i, new Rectangle(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1])); }//from w ww.j a va2 s. co m for (CMapSegment segment : otf.getCMaps()) { if (segment.getUnicodeStart() < 0xFFFE) { for (char u = (char) segment.getUnicodeStart(); u <= segment.getUnicodeEnd(); u++) { int codePoint = singleFont.getEncoding().mapChar(u); if (codePoint <= 0) { int glyphIndex = segment.getGlyphStartIndex() + u - segment.getUnicodeStart(); String glyphName = otf.getGlyphName(glyphIndex); if (glyphName.length() == 0 && otf.getPostScriptVersion() != PostScriptVersion.V2) { glyphName = "u" + HexEncoder.encode(u); } if (glyphName.length() > 0) { String unicode = Character.toString(u); NamedCharacter nc = new NamedCharacter(glyphName, unicode); singleFont.addUnencodedCharacter(nc, wx[glyphIndex], bboxes[glyphIndex]); } } } } } }
From source file:com.espertech.esper.event.bean.PropertyHelper.java
/** * Adds to the given list of property descriptors the mapped properties, ie. * properties that have a getter method taking a single String value as a parameter. * @param clazz to introspect//ww w .j a v a 2 s.co m * @param result is the list to add to */ protected static void addMappedProperties(Class clazz, List<InternalEventPropDescriptor> result) { Set<String> uniquePropertyNames = new HashSet<String>(); Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (!methodName.startsWith("get")) { continue; } String inferredName = methodName.substring(3, methodName.length()); if (inferredName.length() == 0) { continue; } Class<?> parameterTypes[] = methods[i].getParameterTypes(); if (parameterTypes.length != 1) { continue; } if (parameterTypes[0] != String.class) { continue; } String newInferredName = null; // Leave uppercase inferred names such as URL if (inferredName.length() >= 2) { if ((Character.isUpperCase(inferredName.charAt(0))) && (Character.isUpperCase(inferredName.charAt(1)))) { newInferredName = inferredName; } } // camelCase the inferred name if (newInferredName == null) { newInferredName = Character.toString(Character.toLowerCase(inferredName.charAt(0))); if (inferredName.length() > 1) { newInferredName += inferredName.substring(1, inferredName.length()); } } inferredName = newInferredName; // if the property inferred name already exists, don't supply it if (uniquePropertyNames.contains(inferredName)) { continue; } result.add(new InternalEventPropDescriptor(inferredName, methods[i], EventPropertyType.MAPPED)); uniquePropertyNames.add(inferredName); } }
From source file:com.ettrema.zsync.Upload.java
/** * Helper method that reads the String preceding the first newline in the InputStream. * //from w w w . j a va 2 s . c o m * @param in The InputStream to read from * @param maxsearch The maximum number of bytes allowed in the value * @return The CHARSET encoded String that was read * @throws ParseException If a newline or end of input is not reached within maxsearch reads * @throws IOException */ public static String readValue(InputStream in, int maxsearch) throws ParseException, IOException { byte NEWLINE = Character.toString(LF).getBytes(CHARSET)[0]; byte[] delimiters = { NEWLINE }; return readToken(in, delimiters, maxsearch); }
From source file:com.commonsware.android.EMusicDownloader.SingleBook.java
private String fixQuotes(String input) { char ctemp = 8220; String output = input.replaceAll(Character.toString(ctemp), "\""); ctemp = 8217;//w w w . j a va 2 s.c o m output = output.replaceAll(Character.toString(ctemp), "%27"); ctemp = 8221; output = output.replaceAll(Character.toString(ctemp), "\""); return output; }
From source file:org.ecoinformatics.datamanager.database.DelimitedReader.java
/** * Auxiliary method called by unescapeDelimiter(). Transforms digits for a * given radix into the equivalent character value. * /*from ww w. j a v a2s .co m*/ * @param radix the radix value, e.g. 8 or 16 * @param digits a string holding the digits to be transformed * @return a string holiding the equivalent character value */ private static String transferDigitsToCharString(int radix, String digits) { if (digits == null) { return null; } Integer integer = Integer.valueOf(digits, radix); int inter = integer.intValue(); //log.debug("The decimal value of char is "+ inter); char charactor = (char) inter; String newDelimiter = Character.toString(charactor); //log.debug("The new delimter is "+newDelimiter); return newDelimiter; }
From source file:org.jahia.utils.maven.plugin.contentgenerator.UserGroupService.java
private String getFolderName(int userNameHashcode) { int i = (userNameHashcode % 100); return Character.toString((char) ('a' + Math.round(i / 10))) + Character.toString((char) ('a' + (i % 10))); }
From source file:com.igormaznitsa.mindmap.model.ModelUtils.java
@Nonnull private static String normalizeFileURI(@Nonnull final String fileUri) { final int schemePosition = fileUri.indexOf(':'); final String scheme = schemePosition < 0 ? "" : fileUri.substring(0, schemePosition + 1); //NOI18N final String chars = " :<>?"; //NOI18N String result = fileUri.substring(scheme.length()); for (final char ch : chars.toCharArray()) { result = result.replace(Character.toString(ch), "%" + Integer.toHexString(ch).toUpperCase(Locale.ENGLISH)); //NOI18N }/*from w w w .j a v a 2 s . co m*/ return scheme + result; }