public void deleteData(int offset, int count) throws DOMException { buffer.delete(offset, offset + count); }
/** * Abbreviate name. * @param buf buffer to append abbreviation. * @param nameStart start of name to abbreviate. */ public void abbreviate(final int nameStart, final StringBuffer buf) { int i = count; for(int pos = buf.indexOf(".", nameStart); pos != -1; pos = buf.indexOf(".", pos + 1)) { if(--i == 0) { buf.delete(nameStart, pos + 1); break; } } } }
/** * filter out the first comment line * @param stringBuffer the string buffer * @return true if filtered successfully, false otherwise */ static boolean filterPropertiesComment(StringBuffer stringBuffer) { //check whether has comment in the first line if (stringBuffer.charAt(0) != '#') { return false; } int commentLineIndex = stringBuffer.indexOf("\n"); if (commentLineIndex == -1) { return false; } stringBuffer.delete(0, commentLineIndex + 1); return true; } }
public void clear() { // DELETE content.delete(0, content.length()); }
StringBuffer sb = new StringBuffer(); for (int n = 0; n < 10; n++) { sb.append("a"); // This will clear the buffer sb.delete(0, sb.length()); }
/** * Abbreviate name. * @param buf buffer to append abbreviation. * @param nameStart start of name to abbreviate. */ public void abbreviate(final int nameStart, final StringBuffer buf) { // We substract 1 from 'len' when assigning to 'end' to avoid out of // bounds exception in return r.substring(end+1, len). This can happen if // precision is 1 and the category name ends with a dot. int end = buf.length() - 1; String bufString = buf.toString(); for (int i = count; i > 0; i--) { end = bufString.lastIndexOf(".", end - 1); if ((end == -1) || (end < nameStart)) { return; } } buf.delete(nameStart, end + 1); } }
private int replaceHolder( StringBuffer dateBuffer, Boolean inPattern ) { String placeHolder = inPattern ? ESCAPED_NANOSECOND_PLACEHOLDER : NANOSECOND_PLACEHOLDER; int placeholderPosition = dateBuffer.indexOf( placeHolder ); if ( placeholderPosition == -1 ) { return 0; } dateBuffer.delete( placeholderPosition, placeholderPosition + placeHolder.length() ); return placeholderPosition; }
/** * Abbreviate element of name. * @param buf buffer to receive element. * @param startPos starting index of name element. * @return starting index of next element. */ public int abbreviate(final StringBuffer buf, final int startPos) { int nextDot = buf.toString().indexOf(".", startPos); if (nextDot != -1) { if ((nextDot - startPos) > charCount) { buf.delete(startPos + charCount, nextDot); nextDot = startPos + charCount; if (ellipsis != '\0') { buf.insert(nextDot, ellipsis); nextDot++; } } nextDot++; } return nextDot; } }
public void setContent(String replacement) { // PUT content.delete(0, content.length()).append(replacement); }
@Override public void onNewLine(String line) { sb.delete(0, sb.length()); sb.append(line); } });
/** * Writes the buffer as far as possible. * @return false to be inline with the Replacefilter. * (Yes defining an interface crossed my mind, but would publish the * internal behavior.) * @throws IOException when the output cannot be written. */ boolean process() throws IOException { writer.write(inputBuffer.toString()); inputBuffer.delete(0, inputBuffer.length()); return false; }
@Override public void onStart(String command) { mErrorOutput.delete(0, mErrorOutput.length()); mErrorOutput.append("running: "); mErrorOutput.append(command); mErrorOutput.append("\n"); }
buffer.delete(fieldStart, buffer.length() - maxLength); } else if (rawLength < minLength) { if (leftAlign) {
@Override public void internalStartElement(String elemName, HashMap mapMandatory, HashMap mapAllowed) throws SAXException { String temp; fileName.delete(0, fileName.length()); temp = (String) mapMandatory.get("NAME"); // NOI18N if (temp == null) { temp = (String) mapMandatory.get("name"); // NOI18N } if (temp != null) { fileName.append(temp); } }
@Override public String toString() { StringBuffer sb = new StringBuffer(); for (Map.Entry<String, Exception> entry : this.exceptionsMap.entrySet()) { sb.append("Creation of index: ").append(entry.getKey()).append(" failed due to: ") .append(entry.getValue()).append(", "); } sb.delete(sb.length() - 2, sb.length()); return sb.toString(); }
/** * Processes the buffer to the end. Does not take into account that * appended data may make it possible to replace the end of the already * received data. */ void flush() { replace(); outputBuffer.append(inputBuffer); inputBuffer.delete(0, inputBuffer.length()); }
public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; buffer.append( line ); // See if we don't have too many lines on board... nrLines++; if ( maxNrLines > 0 && nrLines > maxNrLines ) { buffer.delete( 0, line.length() ); nrLines--; } for ( BufferChangedListener listener : bufferChangedListeners ) { listener.contentWasAdded( buffer, line, nrLines ); } }
/** * Get backup request meta data dir as string. * @param backupInfo backup info * @return meta data dir */ protected String obtainBackupMetaDataStr(BackupInfo backupInfo) { StringBuffer sb = new StringBuffer(); sb.append("type=" + backupInfo.getType() + ",tablelist="); for (TableName table : backupInfo.getTables()) { sb.append(table + ";"); } if (sb.lastIndexOf(";") > 0) { sb.delete(sb.lastIndexOf(";"), sb.lastIndexOf(";") + 1); } sb.append(",targetRootDir=" + backupInfo.getBackupRootDir()); return sb.toString(); }
protected String printItAndReturnIt(byte[] classdata, boolean quoted) { OutputStream os = new SimpleOutputStream(); ClassReader reader = new ClassReader(classdata); reader.accept(new ClassPrinter(new PrintStream(os)), 0); StringBuffer sb = new StringBuffer(os.toString().replace("\r", "")); if (!quoted) { return sb.toString(); } for (int i = 0; i < sb.length(); i++) { if (sb.charAt(i) == '\n') { sb.insert(i + 1, "\""); sb.insert(i, "\\n\"+"); i += 4; } } sb.delete(sb.length() - 3, sb.length()); sb.insert(0, "\""); return sb.toString(); }
protected String toStringClass(byte[] classdata, boolean includeBytecode, boolean quoted) { OutputStream os = new SimpleOutputStream(); ClassPrinter.print(new PrintStream(os), classdata, includeBytecode); String s = os.toString(); StringBuffer sb = new StringBuffer(s.replaceAll("\r", "")); if (!quoted) { return sb.toString(); } for (int i = 0; i < sb.length(); i++) { if (sb.charAt(i) == '\n') { sb.insert(i + 1, "\""); sb.insert(i, "\\n\"+"); i += 4; } } sb.insert(0, "\""); sb.delete(sb.length() - 3, sb.length()); return sb.toString(); }