https://hal.archives-ouvertes.fr/hal-02177293
Tip revision: a5c3a632ff52caf942ac0457ce1ec733926a867b authored by Software Heritage on 01 January 2004, 00:00:00 UTC
hal: Deposit 315 in collection hal
hal: Deposit 315 in collection hal
Tip revision: a5c3a63
InformationEvent.java
/*
* Créé le 25 avr. 2004
*
*/
package information;
/**
* évènement émis par une InterfaceInformation pour signaler diverses modifications.
* Il peut s'agir de l'insertion/remplacement/suppression d'un des constituant de l'InterfaceInformation.
* Il peut aussi s'agir d'un changement de sa complétude, d'un renommage.
* Cela peut aussi être la suppression pure et simple de l'InterfaceInformation.
*
* @author Vincent Labatut
* @version 1
* @see information.InterfaceInformation
* @see information.InformationListener
*/
public class InformationEvent
{ /**
* InterfaceInformation qui émet l'InformationEvent.
*/
private InterfaceInformation source;
/**
* InterfaceInformation qui participe à l'InformationEvent.
*/
private InterfaceInformation cible;
/**
* Type de modification, dans le cas d'un InformationEvent de modification de constituant.
*/
private int type;
/**
* Index du constituant modifié, dans le cas d'un InformationEvent de modification de constituant.
*/
private int index;
// ----------------------------------------
// Constantes de classe
// ----------------------------------------
/**
* Si l'InformationEvent n'est pas une modification de constituant.
*/
public final static int NONE = 0;
/**
* Si l'InformationEvent est une modification de constituant : insertion d'un nouveau composant.
*/
public final static int ELT_INSER = 1;
/**
* Si l'InformationEvent est une modification de constituant : suppression d'un composant.
*/
public final static int ELT_SUPPR = 2;
/**
* Si l'InformationEvent est une modification de constituant : remplacement d'un composant.
*/
public final static int ELT_REMPL = 3;
public final static int RENOMMAGE = 4;
// ----------------------------------------
// Constructeurs
// ----------------------------------------
/**
* Constructeur pour créer un InformationEvent à partir d'une source.
* Les type et index sont initialisés à des valeurs neutres.
* Plutot dédié à des InformationEvents de raffraichissement, cache, completude,
* renommage, suppression.
*
* @param i source de l'InformationEvent.
*/
public InformationEvent(InterfaceInformation i)
{ source = i;
cible = null;
type = NONE;
index = -1;
}
/**
* Constructeur pour créer un InformationEvent à partir d'une source et d'un type.
* L'index est initialisé à -1.
*
* @param i source de l'InformationEvent.
* @param t type de l'InformationEvent.
*/
public InformationEvent(InterfaceInformation i, int t)
{ source = i;
cible = null;
type = t;
index = -1;
}
/**
* Constructeur pour créer un InformationEvent à partir d'une source,
* d'un type et d'un index.
* Plutot dédié à des InformationEvents de modification de constituant.
*
* @param i source de l'InformationEvent.
* @param t type de l'InformationEvent.
* @param id index de l'InformationEvent.
*/
public InformationEvent(InterfaceInformation i, int t, int id)
{ source = i;
cible = null;
type = t;
index = id;
}
/**
* Constructeur pour créer un InformationEvent à partir d'une source,
* et d'une cible.
* Plutot dédié à des InformationEvents de remplacement.
*
* @param s source de l'InformationEvent.
* @param c type de l'InformationEvent.
*/
public InformationEvent(InterfaceInformation s, InterfaceInformation c)
{ source = s;
cible = c;
type = NONE;
index = -1;
}
// ----------------------------------------
// Champs
// ----------------------------------------
/**
* renvoie la source de l'InformationEvent.
* C'est à dire l'InterfaceInformation qui l'a émis.
*
* @return source de l'InformationEvent.
*/
public InterfaceInformation getSource()
{ return source;
}
/**
* renvoie la cible de l'InformationEvent.
*
* @return cible de l'InformationEvent.
*/
public InterfaceInformation getCible()
{ return cible;
}
/**
* renvoie le type de l'InformationEvent.
* C.f. les constantes de classe.
*
* @return type de l'InformationEvent.
*/
public int getType()
{ return type;
}
/**
* renvoie l'index de l'InformationEvent.
* Dans le cas d'un InformationEvent de modification de constituant.
*
* @return index de l'InformationEvent.
*/
public int getIndex()
{ return index;
}
}