package siprp.database.cayenne.objects;

import java.text.DateFormat;
import java.util.Locale;

import org.apache.cayenne.CayenneDataObject;
import org.apache.cayenne.PersistenceState;

import siprp.database.cayenne.providers.MedicinaDAO;

import com.evolute.utils.strings.UnicodeChecker;

public class BaseObject extends CayenneDataObject
{

	static {
		UnicodeChecker.setUseDoubleSlash( true );
	}
	
	private static final long serialVersionUID = 1L;
	
	protected static MedicinaDAO medicinaProvider = new MedicinaDAO();
	
	protected static final DateFormat sdf = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );

	protected static final String isNewMessage = " ";
	
	public boolean isNew()
	{
		return getPersistenceState() == PersistenceState.NEW;
	}
	
	public boolean isCommited()
	{
		return getPersistenceState() == PersistenceState.COMMITTED;
	}
	
	public boolean isModified()
	{
		return getPersistenceState() == PersistenceState.MODIFIED;
	}
	

	
	protected String parseToUnicode( String string )
	{
		String result = UnicodeChecker.parseToUnicode( string );
		return result.replaceAll( "\\\\\\\\", "\\\\" );
	}
	
	protected String parseFromUnicode( String string )
	{
		return UnicodeChecker.parseFromUnicode( string );
	}
	
}
