Refine search
@Override public void visitEnd() { p.visitClassEnd(); if (pw != null) { p.print(pw); pw.flush(); } super.visitEnd(); }
@Override public String toString() { Printer printer = new ASMifier(); TraceMethodVisitor visitor = new TraceMethodVisitor(printer); node.accept(visitor); return printer.getText().toString(); }
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { Printer p = this.p.visitMethod(access, name, desc, signature, exceptions); MethodVisitor mv = cv == null ? null : cv.visitMethod(access, name, desc, signature, exceptions); return new TraceMethodVisitor(mv, p); }
public static void main(String args[]){ Printer printer = new HP(); printer.getSystemResource(); printer.print(); }
public class Copy { private Keyboard keyboard = new Keyboard(); // concrete dependency private Printer printer = new Printer(); // concrete dependency public void copy() { for (int c = keyboard.read(); c != KeyBoard.EOF) { printer.print(c); } } } Now with dependency inversion: public class Copy { private Reader reader; // any dependency satisfying the reader interface will work private Writer writer; // any dependency satisfying the writer interface will work public void copy() { for (int c = reader.read(); c != Reader.EOF) { writer.write(c); } } public Copy(Reader reader, Writer writer) { this.reader = reader; this.writer = writer; } }
/* Create a "printer" that renders text versions of instructions */ Printer printer = new Textifier(); TraceMethodVisitor methodPrinter = new TraceMethodVisitor(printer); /* render the instruction as a string and add it to printer's internal buffer */ insnNode.accept(methodPrinter); /* convert printer's internal buffer to string and clear the buffer (so we can reuse it later) */ StringWriter sw = new StringWriter(); printer.print(new PrintWriter(sw)); printer.getText().clear(); String insnNodeAsString = sw.toString(); /* print the string out */ System.out.print(insnNodeAsString);
private String toString(MethodTree mt) { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final TraceMethodVisitor mv = new TraceMethodVisitor(new Textifier()); mt.rawNode().accept(mv); try (PrintWriter pw = new PrintWriter(bos)) { mv.p.print(pw); } return "Byte code is \n" + new String(bos.toByteArray()); }
protected void print(final Object cst) { if (cst instanceof String) { StringBuffer buf = new StringBuffer(); Printer.appendString(buf, (String) cst); pw.print(buf.toString()); } else if (cst instanceof Float) {
@Override public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { p.visit(version, access, name, signature, superName, interfaces); super.visit(version, access, name, signature, superName, interfaces); }
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { Printer p = this.p.visitClassAnnotation(desc, visible); AnnotationVisitor av = cv == null ? null : cv.visitAnnotation(desc, visible); return new TraceAnnotationVisitor(av, p); }
@Override public void visitAttribute(final Attribute attr) { p.visitClassAttribute(attr); super.visitAttribute(attr); }
@Override public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { Printer p = this.p.visitClassTypeAnnotation(typeRef, typePath, desc, visible); AnnotationVisitor av = cv == null ? null : cv.visitTypeAnnotation( typeRef, typePath, desc, visible); return new TraceAnnotationVisitor(av, p); }
public class InsnPrinter { private static final Printer printer = new Textifier(); private static final TraceMethodVisitor methodPrinter = new TraceMethodVisitor(printer); public static String prettyprint(AbsractInsnNode insnNode) { insnNode.accept(methodPrinter); StringWriter sw = new StringWriter(); printer.print(new PrintWriter(sw)); printer.getText().clear(); return sw.toString(); } }
public class MyJob extends Job { public void doJob() throws Exception { Printer printer = Spring.getBeanOfType(Printer.class); printer.print(); } }
if (fn.value instanceof String) { StringBuffer buf = new StringBuffer(); Printer.appendString(buf, (String) fn.value); pw.print(" = "); pw.print(buf.toString());
@Override public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { p.visit(version, access, name, signature, superName, interfaces); super.visit(version, access, name, signature, superName, interfaces); }
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { Printer p = this.p.visitClassAnnotation(desc, visible); AnnotationVisitor av = cv == null ? null : cv.visitAnnotation(desc, visible); return new TraceAnnotationVisitor(av, p); }
@Override public void visitAttribute(final Attribute attribute) { p.visitClassAttribute(attribute); super.visitAttribute(attribute); }
@Override public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { Printer p = this.p.visitClassTypeAnnotation(typeRef, typePath, desc, visible); AnnotationVisitor av = cv == null ? null : cv.visitTypeAnnotation( typeRef, typePath, desc, visible); return new TraceAnnotationVisitor(av, p); }