/*
 * Historico.java
 *
 * Created on 7 de Dezembro de 2004, 16:50
 */

package siprp.data;

import java.text.*;
import java.util.*;

import com.evolute.utils.jdo.*;
import com.evolute.utils.tables.*;

import siprp.*;
/**
 *
 * @author  fpalma
 */
public abstract class Historico extends JDOObject
	implements ColumnizedObject
{
	protected static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT );
	
	public static final String DATA = "data";
	public static final String TEXTO = "texto";
	
	/** Creates a new instance of Historico */
	public Historico()
	{
	}
	
	public Object getValue(int col)
	{
		switch( col )
		{
			case 0:
				Date data = (Date) get( DATA );
				String dataStr = DATE_FORMAT.format( data );
				return dataStr;
				
			case 1:
				String textoStr = (String ) get( TEXTO );
				if( textoStr == null )
				{
					textoStr = "";
				}
				textoStr = textoStr.trim();
				int index = textoStr.indexOf( "\n" );
				if( index != -1 )
				{
					textoStr = textoStr.substring( 0, index );
				}
				return textoStr;
		}
		return null;
	}
}
