public static String pad(int colLength, int tabPos) { StringAppender sAppend = new StringAppender(); for (int len = tabPos - colLength; len != -1; len--) { sAppend.append(' '); } return sAppend.toString(); }
private String generateErrorMessage() { StringAppender appender = new StringAppender().append("[Error: " + super.getMessage() + "]\n"); int offset = appender.length(); appender.append("[Near : {... "); offset = appender.length() - offset; appender.append(showCodeNearError(expr, cursor)) .append(" ....}]\n") .append(repeatChar(' ', offset)); if ((offset = cursor - msgOffset - 1) < 0) offset = 0; appender.append(repeatChar(' ', offset)).append("^"); if (lineNumber != -1) { appender.append('\n') .append("[Line: " + lineNumber + ", Column: " + column + "]"); } return appender.toString(); }
public boolean shouldDefer(StringAppender inBuf) { char[] buffer = new char[inBuf.length()]; inBuf.getChars(0, inBuf.length(), buffer, 0); depth = cdepth = 0; for (int i = 0; i < buffer.length; i++) { switch (buffer[i]) { case '/': if (i + 1 < buffer.length && buffer[i + 1] == '*') { cdepth++; } break; case '*': if (i + 1 < buffer.length && buffer[i + 1] == '/') { cdepth--; } break; case '{': depth++; break; case '}': depth--; break; } } return depth + cdepth > 0; }
public static char[] readIn(InputStream inStream, String encoding) throws IOException { try { byte[] buf = new byte[10]; StringAppender sb = new StringAppender(10, encoding); int bytesRead; while ((bytesRead = inStream.read(buf)) > 0) { for (int i = 0; i < bytesRead; i++) { sb.append(buf[i]); } } //noinspection unchecked return sb.toChars(); } finally { if (inStream != null) inStream.close(); } }
private void match(InputStream instream, Pattern pattern, PipeOut out, boolean caseInsensitive) throws IOException { StringAppender buf = new StringAppender(); int c; while ((c = instream.read()) != -1) { switch (c) { case '\r': case '\n': String s = caseInsensitive ? buf.toString().toLowerCase() : buf.toString(); if (pattern.matcher(s).matches()) { out.println(s); } buf.reset(); break; default: buf.append((char) c); break; } } } }
inTokens = inBuffer.append(commandBuffer).toString().split("\\s"); outputBuffer = executeExpression(compileExpression(inBuffer.toString()), ctxObject, lvrf); MVELInterpretedRuntime runtime = new MVELInterpretedRuntime(inBuffer.toString(), ctxObject, lvrf, pCtx); outputBuffer = runtime.parse(); inBuffer.reset(); return; inBuffer.reset(); inBuffer.reset();
public static String start() { return new String(new StringAppender()); }
if (buildLog != null && buildLog.length() != 0 && expr != null) { mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitLdcInsn(buildLog.toString() + "\n\n## { " + new String(expr) + " }"); mv.visitInsn(ARETURN); Label l1 = new Label();
@Override public String toString() { return appender.toString(); } }
public StringAppender append(final char[] chars, final int start, final int length) { if (length > (capacity - size)) grow(length); int x = start + length; for (int i = start; i < x; i++) { str[size++] = chars[i]; } return this; }
public StringAppender append(final byte b) { if (btr == null) btr = new byte[capacity = DEFAULT_SIZE]; if (size >= capacity) growByte(size * 2); btr[size++] = b; return this; }
public static char[] readIn(InputStream inStream, String encoding) throws IOException { try { byte[] buf = new byte[10]; StringAppender sb = new StringAppender(10, encoding); int bytesRead; while ((bytesRead = inStream.read(buf)) > 0) { for (int i = 0; i < bytesRead; i++) { sb.append(buf[i]); } } //noinspection unchecked return sb.toChars(); } finally { if (inStream != null) inStream.close(); } }
public static void main(String[] args) throws IOException { DecimalFormat df = new DecimalFormat("###,###.##"); StringAppender append = new StringAppender(); int len; long start = currentTimeMillis(); append.reset(); append.append(CHAR_TABLE[((SALTS[((rand.nextInt(1000)) + 1) % SALTS.length]) * ((flip = !flip) ? rand1.nextInt(1000) : rand2.nextInt(1000)) + 1) % CHAR_TABLE.length]); SALTS[rand3.nextInt(SALTS.length - 1)] ^= rand4.nextInt(1000) + 1; MVEL.eval(append.toString()); System.out.println("untrapped error!\n---\n" + append.toString() + "\n---\n"); System.out.flush(); e.printStackTrace();
inTokens = inBuffer.append(commandBuffer).toString().split("\\s"); outputBuffer = executeExpression(compileExpression(inBuffer.toString()), ctxObject, lvrf); MVELInterpretedRuntime runtime = new MVELInterpretedRuntime(inBuffer.toString(), ctxObject, lvrf, pCtx); outputBuffer = runtime.parse(); inBuffer.reset(); return; inBuffer.reset(); inBuffer.reset();
public MarshallerContext(Marshaller marshaller) { this.marshaller = marshaller; this.appender = new StringAppender(); }
if (buildLog != null && buildLog.length() != 0 && expr != null) { mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitLdcInsn(buildLog.toString() + "\n\n## { " + new String(expr) + " }"); mv.visitInsn(ARETURN); Label l1 = new Label();
@Override public String toString() { return appender.toString(); } }
public StringAppender append(final byte[] chars, final int start, final int length) { if (length > (capacity - size)) grow(length); int x = start + length; for (int i = start; i < x; i++) { str[size++] = (char) chars[i]; } return this; }