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

nyla.solutions.global.data.DataRowCreator 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.data;

import java.util.HashMap;

import nyla.solutions.global.patterns.creational.RowObjectCreator;
import nyla.solutions.global.patterns.reflection.JavaBeanVisitor;
import nyla.solutions.global.util.JavaBean;

/**
 * Create a Data ROW that data from a object
 * @author Gregory Green
 *
 */
public class DataRowCreator implements JavaBeanVisitor, RowObjectCreator
{
	public DataRowCreator()
	{
	}

	/**
	 * @see nyla.solutions.global.patterns.reflection.JavaBeanVisitor#visitClass(java.lang.Class, java.lang.Object)
	 */
	@Override
	public void visitClass(Class aClass, Object object)
	{
	}

	/**
	 * @see nyla.solutions.global.patterns.reflection.JavaBeanVisitor#visitProperty(java.lang.String, java.lang.Object, java.lang.Object)
	 */
	@Override
	public void visitProperty(String name, Object value, Object object)
	{
		map.put(name, value);
	}// --------------------------------------------------------
	/**
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public DataRow getDataRow()
	{
		return new DataRow((HashMap)map.clone());
	}// --------------------------------------------------------
	
	@Override
	public DataRow create(Object rs, int index)
	{
		JavaBean.acceptVisitor(rs, this);
		
		DataRow dataRow = this.getDataRow();
		
		dataRow.setRowNum(index);
		
		this.clear();
		
		return dataRow;
	}// --------------------------------------------------------
	
	/**
	 * Clear the current built properties
	 */
	public void clear()
	{
		map.clear();
	}
	
	private HashMap map = new HashMap();



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy