public static long fnv1a_64_lower(StringBuilder key) { long hashCode = BASIC; for (int i = 0; i < key.length(); ++i) { char ch = key.charAt(i); if (ch >= 'A' && ch <= 'Z') { ch = (char) (ch + 32); } hashCode ^= ch; hashCode *= PRIME; } return hashCode; }
public static long fnv1a_64_lower(long basic, StringBuilder key) { long hashCode = basic; for (int i = 0; i < key.length(); ++i) { char ch = key.charAt(i); if (ch >= 'A' && ch <= 'Z') { ch = (char) (ch + 32); } hashCode ^= ch; hashCode *= PRIME; } return hashCode; }
public void removeTrailingSlash() { int index = this.path.length() - 1; if (this.path.charAt(index) == '/') { this.path.deleteCharAt(index); } }
public static int lineNumber(StringBuilder s, int index) { int cnt = 1; for (int i = 0; i < index; i++) { if (s.charAt(i) == '\n') { cnt++; } } return cnt; }
private static void convertRemainingAccentCharacters(final StringBuilder decomposed) { for (int i = 0; i < decomposed.length(); i++) { if (decomposed.charAt(i) == '\u0141') { decomposed.deleteCharAt(i); decomposed.insert(i, 'L'); } else if (decomposed.charAt(i) == '\u0142') { decomposed.deleteCharAt(i); decomposed.insert(i, 'l'); } } }
@Override public char lastChar() { if ( builder.length() > 0 ) { return builder.charAt(builder.length()-1); } return 0; }
public static String dbName(String javaName) { StringBuilder builder = new StringBuilder(javaName); for (int i = 1; i < builder.length(); i++) { boolean lastWasUpper = Character.isUpperCase(builder.charAt(i - 1)); boolean isUpper = Character.isUpperCase(builder.charAt(i)); if (isUpper && !lastWasUpper) { builder.insert(i, '_'); i++; } } return builder.toString().toUpperCase(); }
/** * Trim all occurrences of the supplied leading character from the given {@code String}. * @param str the {@code String} to check * @param leadingCharacter the leading character to be trimmed * @return the trimmed {@code String} */ public static String trimLeadingCharacter(String str, char leadingCharacter) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && sb.charAt(0) == leadingCharacter) { sb.deleteCharAt(0); } return sb.toString(); }
/** * Trim leading whitespace from the given {@code String}. * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace */ public static String trimLeadingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) { sb.deleteCharAt(0); } return sb.toString(); }
/** * Trim all occurrences of the supplied trailing character from the given {@code String}. * @param str the {@code String} to check * @param trailingCharacter the trailing character to be trimmed * @return the trimmed {@code String} */ public static String trimTrailingCharacter(String str, char trailingCharacter) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
/** * Trim trailing whitespace from the given {@code String}. * @param str the {@code String} to check * @return the trimmed {@code String} * @see java.lang.Character#isWhitespace */ public static String trimTrailingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
private static String convertToAsciiNumber(String convId) { StringBuilder buf = new StringBuilder(convId); for (int i = 0; i < buf.length(); i++) { char ch = buf.charAt(i); int digit = Character.digit(ch, 10); if (digit >= 0) { buf.setCharAt(i, (char) ('0' + digit)); } } return buf.toString(); }
private static String toKey(String prefix, String id) { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotEmpty(prefix)) { sb.append(prefix); } if (StringUtils.isNotEmpty(id)) { sb.append(id); } if (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') { sb.append("."); } if (sb.length() > 0) { return sb.toString(); } return Constants.DUBBO; }
private static String toKey(String prefix, String id) { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotEmpty(prefix)) { sb.append(prefix); } if (StringUtils.isNotEmpty(id)) { sb.append(id); } if (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') { sb.append("."); } if (sb.length() > 0) { return sb.toString(); } return Constants.DUBBO; }
@Override public void encodeValueInto(int depth, Block block, int position, SliceOutput output) { float value = Float.intBitsToFloat((int) type.getLong(block, position)); buffer.setLength(0); buffer.append(value); for (int index = 0; index < buffer.length(); index++) { output.writeByte(buffer.charAt(index)); } }
@Override public void encodeValueInto(int depth, Block block, int position, SliceOutput output) { long value = type.getLong(block, position); buffer.setLength(0); buffer.append(value); for (int index = 0; index < buffer.length(); index++) { output.writeByte(buffer.charAt(index)); } }
private void encodeValue(Block block, int position, SliceOutput output) { double value = type.getDouble(block, position); buffer.setLength(0); buffer.append(value); for (int index = 0; index < buffer.length(); index++) { output.writeByte(buffer.charAt(index)); } }
private void encodeValue(Block block, int position, SliceOutput output) { long days = type.getLong(block, position); long millis = TimeUnit.DAYS.toMillis(days); buffer.setLength(0); HIVE_DATE_PARSER.printTo(buffer, millis); for (int index = 0; index < buffer.length(); index++) { output.writeByte(buffer.charAt(index)); } }
@Override public void encodeValueInto(int depth, Block block, int position, SliceOutput output) { long millis = type.getLong(block, position); buffer.setLength(0); dateTimeFormatter.printTo(buffer, millis); for (int index = 0; index < buffer.length(); index++) { output.writeByte(buffer.charAt(index)); } }