001: /**
002: * $RCSfile: VAStats.java,v $
003: * @creation 02/04/00
004: * @modification $Date: 2005/03/06 23:04:18 $
005: */package com.memoire.vainstall;
006:
007: import java.io.File;
008: import java.util.Vector;
009:
010: /**
011: * @version $Id: VAStats.java,v 1.4 2005/03/06 23:04:18 deniger Exp $
012: * @author Axel von Arnim
013: */
014:
015: public class VAStats {
016: public static final boolean SUCCESS = true;
017: public static final boolean FAILURE = false;
018:
019: Vector dirs_;
020: Vector files_;
021: Vector exes_;
022: int nbDirSucc_, nbFileSucc_;
023:
024: public VAStats() {
025: dirs_ = new Vector();
026: files_ = new Vector();
027: exes_ = new Vector();
028: nbDirSucc_ = nbFileSucc_ = 0;
029: }
030:
031: public void addFile(File f, boolean success) {
032: if (success) {
033: if (f.isDirectory())
034: nbDirSucc_++;
035: else
036: nbFileSucc_++;
037: } else {
038: if (f.isDirectory())
039: dirs_.add(f);
040: else
041: files_.add(f);
042: }
043: }
044:
045: public void addDirectory(File f, boolean success) {
046: if (success)
047: nbDirSucc_++;
048: else
049: dirs_.add(f);
050: }
051:
052: public void addExecutable(File exe) {
053: exes_.add(exe);
054: }
055:
056: public File[] getSuccessfulDirs() {
057: return new File[nbDirSucc_];
058: }
059:
060: public File[] getSuccessfulFiles() {
061: return new File[nbFileSucc_];
062: }
063:
064: public File[] getExecutables() {
065: File[] res = new File[exes_.size()];
066: for (int i = 0; i < exes_.size(); i++) {
067: res[i] = (File) exes_.get(i);
068: }
069: return res;
070: }
071:
072: public File[] getFailedDirs() {
073: File[] res = new File[dirs_.size()];
074: for (int i = 0; i < dirs_.size(); i++) {
075: res[i] = (File) dirs_.get(i);
076: }
077: return res;
078: }
079:
080: public File[] getFailedFiles() {
081: File[] res = new File[files_.size()];
082: for (int i = 0; i < files_.size(); i++) {
083: res[i] = (File) files_.get(i);
084: }
085: return res;
086: }
087:
088: public String getSuccessReport() {
089: String res = "";
090: switch (VAGlobals.OPERATION) {
091: case VAGlobals.UPDATE:
092: case VAGlobals.INSTALL: {
093: res += VAGlobals.i18n("VAStats_CreatedDirectories") + " "
094: + nbDirSucc_ + "\n";
095: res += VAGlobals.i18n("VAStats_CreatedFiles") + " "
096: + nbFileSucc_ + "\n";
097: break;
098: }
099: case VAGlobals.UNINSTALL: {
100: res += VAGlobals.i18n("VAStats_DeletedDirectories") + " "
101: + nbDirSucc_ + "\n";
102: res += VAGlobals.i18n("VAStats_DeletedFiles") + " "
103: + nbFileSucc_ + "\n";
104: break;
105: }
106: }
107: return res;
108: }
109:
110: public String getFailureReport() {
111: String res = "";
112: if (dirs_.size() > 0) {
113: switch (VAGlobals.OPERATION) {
114: case VAGlobals.UPDATE:
115: case VAGlobals.INSTALL:
116: res += VAGlobals.i18n("VAStats_NotCreateDirectories")
117: + "\n";
118: break;
119: case VAGlobals.UNINSTALL:
120: res += VAGlobals.i18n("VAStats_NotRemoveDirectories")
121: + "\n";
122: break;
123: }
124: for (int i = 0; i < dirs_.size(); i++) {
125: res += " " + ((File) dirs_.get(i)).getAbsolutePath()
126: + "\n";
127: }
128: }
129: if (files_.size() > 0) {
130: switch (VAGlobals.OPERATION) {
131: case VAGlobals.UPDATE:
132: case VAGlobals.INSTALL:
133: res += VAGlobals.i18n("VAStats_NotCreateFiles") + "\n";
134: break;
135: case VAGlobals.UNINSTALL:
136: res += VAGlobals.i18n("VAStats_NotRemoveFiles") + "\n";
137: break;
138: }
139: for (int i = 0; i < files_.size(); i++) {
140: res += " " + ((File) files_.get(i)).getAbsolutePath()
141: + "\n";
142: }
143: }
144: return res;
145: }
146:
147: public String getExecutablesReport() {
148: String res = "";
149: if ((exes_.size() > 0)
150: && ((VAGlobals.OPERATION == VAGlobals.INSTALL) || (VAGlobals.OPERATION == VAGlobals.UPDATE))) {
151: res += VAGlobals.i18n("VAStats_Executables") + "\n";
152: for (int i = 0; i < exes_.size(); i++) {
153: res += " " + ((File) exes_.get(i)).getAbsolutePath()
154: + "\n";
155: }
156: }
157: return res;
158: }
159: }
|