https://hal.archives-ouvertes.fr/hal-02177293
Raw File
Tip revision: a5c3a632ff52caf942ac0457ce1ec733926a867b authored by Software Heritage on 01 January 2004, 00:00:00 UTC
hal: Deposit 315 in collection hal
Tip revision: a5c3a63
AbstractFonctionFilsSimilitude.java
/*
 * Créé le 15 juil. 2004
 *
 */
package fonction.similitude;

import java.lang.reflect.InvocationTargetException;

import principal.copiercoller.CopiableIncompatibleException;
import principal.copiercoller.InterfaceCopiable;
import principal.copiercoller.Tampon;

import fonction.AbstractFonctionFils;
import information.DomaineIncompatibleException;

import traitement.similitude.InterfaceSimilitude;


/**
 * InterfaceFonctionFilsSimilitude dont certaines méthodes communes ŕ la plupart 
 * de ces fonctions sont implémentées.
 * 
 * @author	Vincent Labatut
 * @version	1
  */
public abstract class AbstractFonctionFilsSimilitude extends AbstractFonctionFils implements InterfaceFonctionFilsSimilitude
{	/**
	* dernier résultat de la fonction.
	 */
	protected InterfaceSimilitude similitude;

//	----------------------------------------	
//	Constructeurs
//	----------------------------------------
	/**
	 * crée une fonction de parent la fonction passée en paramčtre. 
	 * 
	 * @param 	p	parent de cette fonction.
	  */
	public AbstractFonctionFilsSimilitude(InterfaceFonctionParentSimilitude p)
	{	super(p);		
	}	

//	----------------------------------------	
//	InterfaceContientSimilitude
//	----------------------------------------
	/*
	 *
	 */
	public InterfaceSimilitude getSimilitude()
	{	return similitude;
	}

//	----------------------------------------	
//	Interface Graphique
//	----------------------------------------
	/*
	 *
	 */
	public void substituer(Class classe)
	{	Object a[]=new Object[1];
		
		try
		{	a[0] = parent;
			((InterfaceFonctionParentSimilitude)parent).remplacerFils(this, (InterfaceFonctionFilsSimilitude) classe.getConstructors()[0].newInstance(a));
		}
		catch (IllegalAccessException e)
		{	e.printStackTrace();
		}
		catch (InstantiationException e)
		{	e.printStackTrace();
		} 
		catch (IllegalArgumentException e)
		{	e.printStackTrace();
		}
		catch (SecurityException e)
		{	e.printStackTrace();
		}
		catch (InvocationTargetException e)
		{	e.printStackTrace();
		}
		catch (DomaineIncompatibleException e)
		{	e.printStackTrace();
		}
	}
	/*
	 *
	 */
	public boolean estCollable()
	{	boolean resultat = true;
	    Tampon tampon = getModele().getTampon();
		if (tampon.estVide())
			resultat = false;
		else
		{	InterfaceCopiable buffer = tampon.get();
			if (buffer instanceof InterfaceFonctionFilsSimilitude)
			{	resultat = true;
			}
			else
				resultat = false;
		}
		return resultat;
	}
	/*
	 *
	 */
	public void coller() throws CopiableIncompatibleException
	{	Tampon tampon = getModele().getTampon();
		if (tampon.estVide())
			throw new CopiableIncompatibleException(getIdentification());
		InterfaceCopiable buffer = tampon.get();
		if (buffer instanceof InterfaceFonctionFilsSimilitude)
		{	InterfaceFonctionFilsSimilitude temp = (InterfaceFonctionFilsSimilitude) buffer;
			try
			{	((InterfaceFonctionParentSimilitude)parent).remplacerFils(this, temp);
			}
			catch (DomaineIncompatibleException e)
			{	throw new CopiableIncompatibleException(getIdentification());
			}
		}
		else
			throw new CopiableIncompatibleException(getIdentification());
	}
}
back to top