public Writer getWriter(final Writer out, Map args) throws TemplateModelException { int bufferSize = defaultBufferSize; boolean singleLine = false; if (args != null) { try { TemplateNumberModel num = (TemplateNumberModel) args.get(BUFFER_SIZE_KEY); if (num != null) bufferSize = num.getAsNumber().intValue(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting numerical argument to " + BUFFER_SIZE_KEY); } try { TemplateBooleanModel flag = (TemplateBooleanModel) args.get(SINGLE_LINE_KEY); if (flag != null) singleLine = flag.getAsBoolean(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting boolean argument to " + SINGLE_LINE_KEY); } } return new StandardCompressWriter(out, bufferSize, singleLine); }
@Override public void flush() throws IOException { flushInternal(); out.flush(); }
private void writeHelper(char[] cbuf, int off, int len) { for (int i = off, end = off + len; i < end; i++) { char c = cbuf[i]; if (Character.isWhitespace(c)) { inWhitespace = true; updateLineBreakState(c); } else if (inWhitespace) { inWhitespace = false; writeLineBreakOrSpace(); buf[pos++] = c; } else { buf[pos++] = c; } } }
public Writer getWriter(final Writer out, Map args) throws TemplateModelException { int bufferSize = defaultBufferSize; boolean singleLine = false; if (args != null) { try { TemplateNumberModel num = (TemplateNumberModel)args.get(BUFFER_SIZE_KEY); if (num != null) bufferSize = num.getAsNumber().intValue(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting numerical argument to " + BUFFER_SIZE_KEY); } try { TemplateBooleanModel flag = (TemplateBooleanModel)args.get(SINGLE_LINE_KEY); if (flag != null) singleLine = flag.getAsBoolean(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting boolean argument to " + SINGLE_LINE_KEY); } } return new StandardCompressWriter(out, bufferSize, singleLine); }
public Writer getWriter(final Writer out, Map args) throws TemplateModelException { int bufferSize = defaultBufferSize; boolean singleLine = false; if (args != null) { try { TemplateNumberModel num = (TemplateNumberModel) args.get(BUFFER_SIZE_KEY); if (num != null) bufferSize = num.getAsNumber().intValue(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting numerical argument to " + BUFFER_SIZE_KEY); } try { TemplateBooleanModel flag = (TemplateBooleanModel) args.get(SINGLE_LINE_KEY); if (flag != null) singleLine = flag.getAsBoolean(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting boolean argument to " + SINGLE_LINE_KEY); } } return new StandardCompressWriter(out, bufferSize, singleLine); }
public Writer getWriter(final Writer out, Map args) throws TemplateModelException { int bufferSize = defaultBufferSize; boolean singleLine = false; if (args != null) { try { TemplateNumberModel num = (TemplateNumberModel) args.get(BUFFER_SIZE_KEY); if (num != null) bufferSize = num.getAsNumber().intValue(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting numerical argument to " + BUFFER_SIZE_KEY); } try { TemplateBooleanModel flag = (TemplateBooleanModel) args.get(SINGLE_LINE_KEY); if (flag != null) singleLine = flag.getAsBoolean(); } catch (ClassCastException e) { throw new TemplateModelException("Expecting boolean argument to " + SINGLE_LINE_KEY); } } return new StandardCompressWriter(out, bufferSize, singleLine); }
@Override public void write(char[] cbuf, int off, int len) throws IOException { for (; ; ) { // Need to reserve space for the EOL potentially left in the state machine int room = buf.length - pos - MAX_EOL_LENGTH; if (room >= len) { writeHelper(cbuf, off, len); break; } else if (room <= 0) { flushInternal(); } else { writeHelper(cbuf, off, room); flushInternal(); off += room; len -= room; } } }
@Override public void write(char[] cbuf, int off, int len) throws IOException { for (; ; ) { // Need to reserve space for the EOL potentially left in the state machine int room = buf.length - pos - MAX_EOL_LENGTH; if (room >= len) { writeHelper(cbuf, off, len); break; } else if (room <= 0) { flushInternal(); } else { writeHelper(cbuf, off, room); flushInternal(); off += room; len -= room; } } }
private void writeHelper(char[] cbuf, int off, int len) { for (int i = off, end = off + len; i < end; i++) { char c = cbuf[i]; if (Character.isWhitespace(c)) { inWhitespace = true; updateLineBreakState(c); } else if (inWhitespace) { inWhitespace = false; writeLineBreakOrSpace(); buf[pos++] = c; } else { buf[pos++] = c; } } }
public void write(char[] cbuf, int off, int len) throws IOException { for (;;) { // Need to reserve space for the EOL potentially left in the state machine int room = buf.length - pos - MAX_EOL_LENGTH; if (room >= len) { writeHelper(cbuf, off, len); break; } else if (room <= 0) { flushInternal(); } else { writeHelper(cbuf, off, room); flushInternal(); off += room; len -= room; } } }
private void writeHelper(char[] cbuf, int off, int len) { for (int i = off, end = off + len; i < end; i++) { char c = cbuf[i]; if (Character.isWhitespace(c)) { inWhitespace = true; updateLineBreakState(c); } else if (inWhitespace) { inWhitespace = false; writeLineBreakOrSpace(); buf[pos++] = c; } else { buf[pos++] = c; } } }
private void writeHelper(char[] cbuf, int off, int len) { for (int i = off, end = off + len; i < end; i++) { char c = cbuf[i]; if (Character.isWhitespace(c)) { inWhitespace = true; updateLineBreakState(c); } else if (inWhitespace) { inWhitespace = false; writeLineBreakOrSpace(); buf[pos++] = c; } else { buf[pos++] = c; } } }
public void close() throws IOException { flushInternal(); } }
@Override public void close() throws IOException { flushInternal(); } }
public void flush() throws IOException { flushInternal(); out.flush(); }
@Override public void close() throws IOException { flushInternal(); } }
@Override public void flush() throws IOException { flushInternal(); out.flush(); }
@Override public void flush() throws IOException { flushInternal(); out.flush(); }
@Override public void write(char[] cbuf, int off, int len) throws IOException { for (; ; ) { // Need to reserve space for the EOL potentially left in the state machine int room = buf.length - pos - MAX_EOL_LENGTH; if (room >= len) { writeHelper(cbuf, off, len); break; } else if (room <= 0) { flushInternal(); } else { writeHelper(cbuf, off, room); flushInternal(); off += room; len -= room; } } }
@Override public void close() throws IOException { flushInternal(); } }