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

nyla.solutions.global.patterns.command.file.LoggingCommand Maven / Gradle / Ivy

Go to download

Nyla Solutions Global Java API provides support for basic application utilities (application configuration, data encryption, debugger and text processing).

The newest version!
package nyla.solutions.global.patterns.command.file;
import nyla.solutions.global.exception.FatalException;
import nyla.solutions.global.patterns.command.Command;
import nyla.solutions.global.util.Debugger;

/**
 * Use debugger to log input.
 * 
 * This object will inspect the input to the execute method 
 * to log the appropriate category of FATAL, ERROR, etc log levels.
 * @author Gregory Green
 *
 */
public class LoggingCommand implements Command
{
	/**
	 * 
	 * @see nyla.solutions.global.patterns.command.Command#execute(java.lang.Object)
	 */
	@Override
	public Object execute(Object input)
	{
		
		if(input instanceof FatalException)
		{
			Debugger.printFatal(input);
		}
		else if(input instanceof Exception)
		{
			Debugger.printError(input);
		}
		else
		{
			if(defaultInfo)
				Debugger.printInfo(input);
			else
				Debugger.println(input);
		}
		
		return null;
	}// --------------------------------------------------------

	
	/**
	 * @return the defaultInfo
	 */
	public boolean isDefaultInfo()
	{
		return defaultInfo;
	}


	/**
	 * @param defaultInfo the defaultInfo to set
	 */
	public void setDefaultInfo(boolean defaultInfo)
	{
		this.defaultInfo = defaultInfo;
	}


	private boolean defaultInfo;
	

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy