Problème implémentation de mon interface
Bonjour à tous,
J'ai une interface qui est comme ceci :
Code:
1 2 3 4 5 6 7 8
| public interface ToolInfos {
public String getToolName();
public String getToolVersion();
public List<String> getInputFiles();
public String getOutputFile() throws PayloadRootPathNotInitializedException;
} |
Et ensuite une classe qui implémente cette interface comme ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| public class MaClasse implements ToolInfos{
protected static IhmMaClasse _ihmMaClasse;
public static void main(String[] args){
_ihmMaClasse = new IhmMaClasse();
_ihmMaClasse.setVisible(true);
}
public static void Prog(IhmMaClasse _ihmMaClasse){
ListeConf.EcrireTxt(_ihmMaClasse.getFichier(), fichier, tt, om);
MaClasse iTool = new MaClasse();
Header iHeader = new Header(iTool);
@Override
public String getToolName() {
return("Fichier");
}
@Override
public String getToolVersion() {
return ("V1.1");
}
@Override
public List<String> getInputFiles() {
ArrayList<String> iInputFiles = new ArrayList<String>();
iInputFiles.add(_ihmMaClasse.getDescXXX());
iInputFiles.add(_ihmMaClasse.getDescYYY());
iInputFiles.add(_ihmMaClasse.getDescFFF());
return iInputFiles;
}
@Override
public String getOutputFile() throws PayloadRootPathNotInitializedException {
String iOutputFile = _ihmMaClasse.getFichier();
return iOutputFile;
}
} |
Enfin voici ma classe Header :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public class Header {
protected String mSoftwareName;
protected String mSoftwareVersion;
protected List<String> mInputFiles;
protected String mOutputFile; //Le fichier généré (de sortie)
public Header(ToolInfos aToolInfos) throws PayloadRootPathNotInitializedException{
mOutputFile = aToolInfos.getOutputFile();
mSoftwareName = aToolInfos.getToolName();
mSoftwareVersion = aToolInfos.getToolVersion();
mInputFiles = aToolInfos.getInputFiles();
}
} |
Mon problème c'est que au moment où je fais Header iHeader = new Header(iTool); dans MaClasse j'ai une exception de pointeur null à ce moment là String String iOutputFile = _ihmMaClasse.getFichier(); Enfait c'est comme si _ihmMaClasse n'était pas initialisé alors qu'il l'est dans le main de MaClasse. Je ne comprend pas trop où est le problème. N'hésitez pas à me poser des questions si vous ne comprenez pas trop mon code ou bien mon problème.