final ScreenContextConsumer adapter = new ScreenContextConsumer(new ScreenContext() { public int getWidth() { return processContext.getWidth();
public void flush() throws IOException { adapter.flush(); }
@Override public Screenable append(Style style) throws IOException { adapter.provide(style); return this; }
@Override public Screenable append(char c) throws IOException { adapter.send(); buffer.append(c); return this; }
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { if (start < end) { adapter.send(); buffer.append(csq, start, end); } return this; }
public void flush() throws IOException { send(); out.flush(); }
public void provide(Object element) throws IOException { adapter.provide(element); }
public void flush() throws IOException { if (adapter != null) { adapter.flush(); } command.flush(); }
public void open(final CONSUMER consumer) throws Exception { // try { command.open(consumer); } catch (CommandException e) { Throwable cause = e.getCause(); if (cause instanceof Exception) { throw (Exception)cause; } else if (cause instanceof Error) { throw (Error)cause; } else { throw new UndeclaredThrowableException(cause); } } // ScreenContext screenContext = command.getScreenContext(); ScreenContextConsumer adapter = screenContext != null ? new ScreenContextConsumer(screenContext) : null; // this.screenContext = screenContext; this.adapter = adapter; this.consumer = consumer; }
public void provide(Object element) throws IOException { Renderer current = Renderer.getRenderable(element.getClass()); if (current == null) { send(); if (element instanceof CharSequence) { out.append((CharSequence)element); } else if (element instanceof CLS) { out.cls(); } else if (element instanceof Style) { out.append((Style)element); } else { out.append(element.toString()); } } else { if (renderable != null && !current.equals(renderable)) { send(); } buffer.addLast(element); renderable = current; } }
@Override public void provide(Object element) throws Exception { if (adapter != null) { adapter.provide(element); } if (consumedType.isInstance(element)) { try { command.provide(consumedType.cast(element)); } catch (CommandException e) { Throwable cause = e.getCause(); if (cause instanceof Exception) { throw (Exception)cause; } else if (cause instanceof Error) { throw (Error)cause; } else { throw new UndeclaredThrowableException(cause); } } } }
public void close() throws Exception { if (adapter != null) { adapter.flush(); } try { command.close(); } catch (CommandException e) { Throwable cause = e.getCause(); if (cause instanceof Exception) { throw (Exception)cause; } else if (cause instanceof Error) { throw (Error)cause; } else { throw new UndeclaredThrowableException(cause); } } } }
final ScreenContextConsumer adapter = new ScreenContextConsumer(new ScreenContext() { public int getWidth() { return processContext.getWidth();
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { if (start < end) { adapter.send(); buffer.append(csq, start, end); } return this; }
@Override public Screenable append(Style style) throws IOException { adapter.provide(style); return this; }
public void flush() throws IOException { adapter.flush(); }
final ScreenContextConsumer adapter = new ScreenContextConsumer(new ScreenContext() { public int getWidth() { return processContext.getWidth();
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { if (start < end) { adapter.send(); buffer.append(csq, start, end); } return this; }
@Override public Screenable append(Style style) throws IOException { adapter.provide(style); return this; }
public void flush() throws IOException { adapter.flush(); }