All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.nervalreports.generators.CSVFooterBuilder Maven / Gradle / Ivy

/** This file is part of nervalreports.
 *
 * nervalreports is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * nervalreports is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with nervalreports.  If not, see . */
package net.sf.nervalreports.generators;

/** Builder for footers on CSV files. As the footer is declared at Generator's init, the {@link CSVReportGenerator} must wait
 * before the end of file to add it.
 * @author farrer */
/* default*/ class CSVFooterBuilder {
	
	/** If footer defintion is currently opened. */
	private boolean isOpened;
	
	/** {@link StringBuilder} to use for footer definition. */
	private StringBuilder stringBuilder;
	
	/** Start the definition of a footer. */
	public void initCreation() {
		isOpened = true;
		stringBuilder = new StringBuilder();
	}
	
	/** End the definition of a footer. */
	public void endCreation() {
		isOpened = false;
	}
	
	/** @return {@link #stringBuilder}. */
	public StringBuilder getStringBuilder() {
		return stringBuilder;
	}
	
	/** {@link #isOpened}. */
	public boolean isOpened() {
		return isOpened;
	}
	
	/** {@inheritDoc} */
	@Override
	public String toString() {
		if (stringBuilder != null) {
			return stringBuilder.toString();
		}
		
		return "";
	}
	
	/** Clear all used memory. */
	public void release() {
		isOpened = false;
		stringBuilder = null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy