/** * Formats a count of milliseconds (0-999) into a numeric representation. * @param millis Millisecond coun between 0 and 999. * @param buf String buffer, may not be null. * @param offset Starting position in buffer, the length of the * buffer must be at least offset + 3. */ private static void millisecondFormat( final int millis, final StringBuffer buf, final int offset) { buf.setCharAt(offset, DIGITS.charAt(millis / 100)); buf.setCharAt(offset + 1, DIGITS.charAt((millis / 10) % 10)); buf.setCharAt(offset + 2, DIGITS.charAt(millis % 10)); }
public void finish(StringBuffer toAppendTo) { if (hStart >= 0 && !showAmPm) { for (int i = 0; i < hLen; i++) { toAppendTo.setCharAt(hStart + i, 'H'); } } } }
public static String capitalize(String name) { if (Character.isLowerCase(name.charAt(0))) { if (name.length() == 1 || Character.isLowerCase(name.charAt(1))) { StringBuffer newname = new StringBuffer(name); newname.setCharAt(0, Character.toUpperCase(name.charAt(0))); return newname.toString(); } } return name; }
private CtClass lookupClass0(String classname, boolean notCheckInner) throws NotFoundException { CtClass cc = null; do { try { cc = classPool.get(classname); } catch (NotFoundException e) { int i = classname.lastIndexOf('.'); if (notCheckInner || i < 0) throw e; else { StringBuffer sbuf = new StringBuffer(classname); sbuf.setCharAt(i, '$'); classname = sbuf.toString(); } } } while (cc == null); return cc; }
@NotNull public CharPointer set(char ch, int offset) { if (seq == null) { return this; } if (readonly) { throw new IllegalStateException("readonly string"); } StringBuffer data = (StringBuffer)seq; while (pointer + offset >= data.length()) { data.append('\u0000'); } data.setCharAt(pointer + offset, ch); return this; }
/** * Translates occurrences at a position of / or \ to correct separator of the * current platform and returns whether it had to do a * replacement. * @param buffer a buffer containing a string * @param pos the position in the string buffer to convert * @return true if the character was a / or \ */ protected static boolean translateFileSep(StringBuffer buffer, int pos) { if (buffer.charAt(pos) == '/' || buffer.charAt(pos) == '\\') { buffer.setCharAt(pos, File.separatorChar); return true; } return false; }
/** * Gets HEADER portion of packet. * @param timeStamp number of milliseconds after the standard base time. * @return HEADER portion of packet, will be zero-length string if header is false. * @since 1.2.15 */ private String getPacketHeader(final long timeStamp) { if (header) { StringBuffer buf = new StringBuffer(dateFormat.format(new Date(timeStamp))); // RFC 3164 says leading space, not leading zero on days 1-9 if (buf.charAt(4) == '0') { buf.setCharAt(4, ' '); } buf.append(getLocalHostname()); buf.append(' '); return buf.toString(); } return ""; }
buffer.setCharAt(i, ' ');
public String stripCR( StringBuffer sbsql ) { // DB2 Can't handle \n in SQL Statements... if ( !supportsNewLinesInSQL() ) { // Remove CR's for ( int i = sbsql.length() - 1; i >= 0; i-- ) { if ( sbsql.charAt( i ) == '\n' || sbsql.charAt( i ) == '\r' ) { sbsql.setCharAt( i, ' ' ); } } } return sbsql.toString(); }
/** * returns the unicode representation of a char without the leading backslash * @param ch a character * @return unicode representation of a char for property files */ public static StringBuffer EscapeUnicode(char ch) { StringBuffer unicodeBuf = new StringBuffer("u0000"); String s = Integer.toHexString(ch); //replace the last 0s by the chars contained in s for (int i = 0; i < s.length(); i++) { unicodeBuf.setCharAt(unicodeBuf.length() - s.length() + i, s.charAt(i)); } return unicodeBuf; } }
private static String lookupSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("lookupswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int npairs = iter.s32bitAt(index += 4); int end = npairs * 8 + (index += 4); for (; index < end; index += 8) { int match = iter.s32bitAt(index); int target = iter.s32bitAt(index + 4) + pos; buffer.append("\t\t").append(match).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
private static String tableSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("tableswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int low = iter.s32bitAt(index += 4); int high = iter.s32bitAt(index += 4); int end = (high - low + 1) * 4 + (index += 4); // Offset table for (int key = low; index < end; index += 4, key++) { int target = iter.s32bitAt(index) + pos; buffer.append("\t\t").append(key).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
public void set(int x, int y, char c){ if(x > getWidth() - 1 || y > getHeight() - 1) return; StringBuffer row = rows.get(y); row.setCharAt(x, c); }
private static String lookupSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("lookupswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int npairs = iter.s32bitAt(index += 4); int end = npairs * 8 + (index += 4); for (; index < end; index += 8) { int match = iter.s32bitAt(index); int target = iter.s32bitAt(index + 4) + pos; buffer.append("\t\t").append(match).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
private static String tableSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("tableswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int low = iter.s32bitAt(index += 4); int high = iter.s32bitAt(index += 4); int end = (high - low + 1) * 4 + (index += 4); // Offset table for (int key = low; index < end; index += 4, key++) { int target = iter.s32bitAt(index) + pos; buffer.append("\t\t").append(key).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
private static String lookupSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("lookupswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int npairs = iter.s32bitAt(index += 4); int end = npairs * 8 + (index += 4); for (; index < end; index += 8) { int match = iter.s32bitAt(index); int target = iter.s32bitAt(index + 4) + pos; buffer.append("\t\t").append(match).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
private static String lookupSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("lookupswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int npairs = iter.s32bitAt(index += 4); int end = npairs * 8 + (index += 4); for (; index < end; index += 8) { int match = iter.s32bitAt(index); int target = iter.s32bitAt(index + 4) + pos; buffer.append("\t\t").append(match).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
private static String tableSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("tableswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int low = iter.s32bitAt(index += 4); int high = iter.s32bitAt(index += 4); int end = (high - low + 1) * 4 + (index += 4); // Offset table for (int key = low; index < end; index += 4, key++) { int target = iter.s32bitAt(index) + pos; buffer.append("\t\t").append(key).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
private static String tableSwitch(CodeIterator iter, int pos) { StringBuffer buffer = new StringBuffer("tableswitch {\n"); int index = (pos & ~3) + 4; // default buffer.append("\t\tdefault: ").append(pos + iter.s32bitAt(index)).append("\n"); int low = iter.s32bitAt(index += 4); int high = iter.s32bitAt(index += 4); int end = (high - low + 1) * 4 + (index += 4); // Offset table for (int key = low; index < end; index += 4, key++) { int target = iter.s32bitAt(index) + pos; buffer.append("\t\t").append(key).append(": ").append(target).append("\n"); } buffer.setCharAt(buffer.length() - 1, '}'); return buffer.toString(); }
for (int i = 0; i < sbuf.length(); i++) { if (sbuf.charAt(i) >= 0x80) { sbuf.setCharAt(i, '?');