protected void processContainerLog(Block html, long[] range, InputStream in, int bufferSize, byte[] cbuf) throws IOException { long totalSkipped = 0; long start = range[0]; long toRead = range[1] - range[0]; while (totalSkipped < start) { long ret = in.skip(start - totalSkipped); if (ret == 0) { //Read one byte int nextByte = in.read(); // Check if we have reached EOF if (nextByte == -1) { throw new IOException("Premature EOF from container log"); } ret = 1; } totalSkipped += ret; } int len = 0; int currentToRead = toRead > bufferSize ? bufferSize : (int) toRead; Hamlet.PRE<Hamlet> pre = html.pre(); while (toRead > 0 && (len = in.read(cbuf, 0, currentToRead)) > 0) { pre.__(new String(cbuf, 0, len, Charset.forName("UTF-8"))); toRead = toRead - len; currentToRead = toRead > bufferSize ? bufferSize : (int) toRead; } pre.__(); }
@Override protected void render(Page.HTML<__> html) { set(JQueryUI.ACCORDION_ID, "msg"); String title = "Sorry, got error "+ status(); html. title(title). link(root_url("static", "yarn.css")). __(JQueryUI.class). // an embedded sub-view style("#msg { margin: 1em auto; width: 88%; }", "#msg h1 { padding: 0.2em 1.5em; font: bold 1.3em serif; }"). div("#msg"). h1(title). div(). __("Please consult"). a("http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "RFC 2616").__(" for meanings of the error code.").__(). h1("Error Details"). pre(). __(errorDetails()).__().__().__(); }
@Override public PRE<T> bdo(Dir dir, String cdata) { return bdo().$dir(dir).__(cdata).__(); }
@Override public PRE<T> b(String cdata) { return b().__(cdata).__(); }
private <T extends __> PRE<T> pre_(T e, boolean inline) { return new PRE<T>("pre", e, opt(true, inline, true)); }
@Override public PRE<T> $onkeyup(String value) { addAttr("onkeyup", value); return this; }
@Override public PRE<T> $onmouseover(String value) { addAttr("onmouseover", value); return this; }
@Override public PRE<T> $title(String value) { addAttr("title", value); return this; }
@Override public PRE<T> __(Object... lines) { _p(true, lines); return this; }
@Override public PRE<T> a(String href, String anchorText) { return a().$href(href).__(anchorText).__(); }
@Override public PRE<T> b(String selector, String cdata) { return setSelector(b(), selector).__(cdata).__(); }
@Override public PRE<T> $onkeydown(String value) { addAttr("onkeydown", value); return this; }
@Override public PRE<T> $ondblclick(String value) { addAttr("ondblclick", value); return this; }
@Override public PRE<T> _r(Object... lines) { _p(false, lines); return this; }
@Override public PRE<T> abbr(String selector, String cdata) { return setSelector(abbr(), selector).__(cdata).__(); }
@Override public PRE<T> abbr(String cdata) { return abbr().__(cdata).__(); }