private synchronized void flushAndClose() throws SecurityException { if (writer != null) { try { if (!doneHeader) { writer.write(getFormatter().getHead(this)); doneHeader = true; } writer.write(getFormatter().getTail(this)); writer.flush(); writer.close(); } catch (Exception ex) { // We don't want to throw an exception here, but we // report the exception to any registered ErrorManager. reportError(null, ex, ErrorManager.CLOSE_FAILURE); } writer = null; } }
/** * Closes this handler, but the underlying output stream is only closed if * {@code closeStream} is {@code true}. Security is not checked. * * @param closeStream * whether to close the underlying output stream. */ void close(boolean closeStream) { if (this.os != null) { if (this.writerNotInitialized) { initializeWriter(); } write(getFormatter().getTail(this)); try { this.writer.flush(); if (closeStream) { this.writer.close(); this.writer = null; this.os = null; } } catch (Exception e) { getErrorManager().error("Exception occurred when closing the output stream", e, ErrorManager.CLOSE_FAILURE); } } }
/** * Creates the tail or reports a formatting error. * @param f the formatter. * @param def the default string to use when there is an error. * @return the tail string or the given default string. */ private String tail(final Formatter f, final String def) { try { return f.getTail(this); } catch (final RuntimeException RE) { reportError(RE.getMessage(), RE, ErrorManager.FORMAT_FAILURE); return def; } }
/** * Creates the tail or reports a formatting error. * @param f the formatter. * @param def the default string to use when there is an error. * @return the tail string or the given default string. */ private String tail(final Formatter f, final String def) { try { return f.getTail(this); } catch (final RuntimeException RE) { reportError(RE.getMessage(), RE, ErrorManager.FORMAT_FAILURE); return def; } }
protected void closeWriter() { writerLock.writeLock().lock(); try { if (writer == null) return; writer.write(getFormatter().getTail(this)); writer.flush(); writer.close(); writer = null; date = ""; } catch (Exception e) { reportError(null, e, ErrorManager.CLOSE_FAILURE); } finally { writerLock.writeLock().unlock(); } }
super.getTail(h); //Be forward compatible with super.getHead. return formatRecord(h, true);
super.getTail(h); //Be forward compatible with super.getHead. return formatRecord(h, true);
head = f.getHead(h); msg = record != null ? f.format(record) : ""; tail = f.getTail(h);
head = f.getHead(h); msg = record != null ? f.format(record) : ""; tail = f.getTail(h);
/** * Return the tail string for a set of formatted records. * * @param h PARAM * @return The tail value */ public String getTail( Handler h ) { return super.getTail( h ); }
/** * Return the tail string for a set of formatted records. * * @param h PARAM * @return The tail value */ public String getTail( Handler h ) { return super.getTail( h ); }
@Override public String getTail(Handler h) { return super.getTail(h); } }
/** * Return the tail string for a set of formatted records. * * @param h PARAM * @return The tail value */ public String getTail( Handler h ) { return super.getTail( h ); }
/** * Return the tail string for a set of formatted records. * * @param h PARAM * @return The tail value */ public String getTail( Handler h ) { return super.getTail( h ); }
private String tail(final Formatter f, final String def) { try { return f.getTail(this); } catch (final RuntimeException RE) { reportError(RE.getMessage(), RE, ErrorManager.FORMAT_FAILURE); return def; } }
/** * Creates the tail or reports a formatting error. * @param f the formatter. * @param def the default string to use when there is an error. * @return the tail string or the given default string. */ private String tail(final Formatter f, final String def) { try { return f.getTail(this); } catch (final RuntimeException RE) { reportError(RE.getMessage(), RE, ErrorManager.FORMAT_FAILURE); return def; } }
/** * Creates the tail or reports a formatting error. * @param f the formatter. * @param def the default string to use when there is an error. * @return the tail string or the given default string. */ private String tail(final Formatter f, final String def) { try { return f.getTail(this); } catch (final RuntimeException RE) { reportError(RE.getMessage(), RE, ErrorManager.FORMAT_FAILURE); return def; } }
/** * Creates the tail or reports a formatting error. * @param f the formatter. * @param def the default string to use when there is an error. * @return the tail string or the given default string. */ private String tail(final Formatter f, final String def) { try { return f.getTail(this); } catch (final RuntimeException RE) { reportError(RE.getMessage(), RE, ErrorManager.FORMAT_FAILURE); return def; } }
private void writeTail(final Writer writer) { try { final Formatter formatter = getFormatter(); if (formatter != null) writer.write(formatter.getTail(this)); } catch (Exception ex) { reportError("Error writing section tail", ex, ErrorManager.WRITE_FAILURE); } }
private void writeTail(final Writer writer) { try { final Formatter formatter = getFormatter(); if (formatter != null) writer.write(formatter.getTail(this)); } catch (Exception ex) { reportError("Error writing section tail", ex, ErrorManager.WRITE_FAILURE); } }