- Hlavní stránka
- Balíky
- Třídy
- Soubory

# src/cz/neubauer/tomas/hazardanalysis/model/stages/Phase.java

Zobrazit dokumentaci tohoto souboru.

    00001
    00004 package cz.neubauer.tomas.hazardanalysis.model.stages;
    00005
    00006 import java.util.ArrayList;
    00007
    00008 import cz.neubauer.tomas.hazardanalysis.model.dangers.DangerType;
    00009 import cz.neubauer.tomas.hazardanalysis.model.dangers.DangerVariant;
    00010
    00020 public class Phase {
    00024         private String name;
    00025
    00029         private Stage stage;
    00030
    00034         private ArrayList<DangerVariant> variants;
    00035
    00044         public Phase(Stage stage, String name) {
    00045                 this.stage = stage;
    00046                 this.name = name;
    00047                 variants = new ArrayList<DangerVariant>(10);
    00048         }
    00049
    00055         public String getName() {
    00056                 return name;
    00057         }
    00058
    00065         public void setName(String name) {
    00066                 this.name = name;
    00067         }
    00068
    00074         public Stage getStage() {
    00075                 return stage;
    00076         }
    00077
    00084         public void setStage(Stage stage) {
    00085                 this.stage = stage;
    00086         }
    00087
    00093         public ArrayList<DangerVariant> getVariants() {
    00094                 return variants;
    00095         }
    00096
    00103         public void setVariants(ArrayList<DangerVariant> variants) {
    00104                 this.variants = variants;
    00105         }
    00106
    00113         public void addDangerVariant(DangerVariant dangerVariant) {
    00114                 variants.add(dangerVariant);
    00115         }
    00116
    00124         public DangerVariant getDangerVariant(int index) {
    00125                 return variants.get(index);
    00126         }
    00127
    00135         public void removeDangerVariant(int index) {
    00136                 variants.remove(index);
    00137         }
    00138
    00142         public void clear() {
    00143                 variants.clear();
    00144         }
    00145
    00152         public String getDangerTypesAsString() {
    00153                 ArrayList<DangerType> types = new ArrayList<DangerType>(10);
    00154                 String retVal = "";
    00155
    00156                 int variantCount = variants.size();
    00157                 boolean firstRecord = true;
    00158                 DangerType currentType;
    00159                 for (int i = 0; i < variantCount; i++) {
    00160                         currentType = variants.get(i).getDangerType();
    00161                         if (!types.contains(currentType)) {
    00162                                 if (!firstRecord) {
    00163                                         retVal += ", ";
    00164                                 } else {
    00165                                         firstRecord = false;
    00166                                 }
    00167                                 retVal += currentType.getDescription();
    00168
    00169                                 types.add(currentType);
    00170                         }
    00171                 }
    00172                 return retVal;
    00173         }
    00174
    00181         public String getDangerTypeCodesAsString() {
    00182                 ArrayList<DangerType> types = new ArrayList<DangerType>(10);
    00183                 String retVal = "";
    00184
    00185                 int variantCount = variants.size();
    00186                 boolean firstRecord = true;
    00187                 DangerType currentType;
    00188                 for (int i = 0; i < variantCount; i++) {
    00189                         currentType = variants.get(i).getDangerType();
    00190                         if (!types.contains(currentType)) {
    00191                                 if (!firstRecord) {
    00192                                         retVal += ", ";
    00193                                 } else {
    00194                                         firstRecord = false;
    00195                                 }
    00196                                 retVal += currentType.getCode();
    00197
    00198                                 types.add(currentType);
    00199                         }
    00200                 }
    00201                 return retVal;
    00202         }
    00203
    00210         public String getDangerVarantDescriptionsAsString() {
    00211                 String retVal = "";
    00212
    00213                 int variantCount = variants.size();
    00214                 boolean firstRecord = true;
    00215                 for (int i = 0; i < variantCount; i++) {
    00216                         if (!firstRecord) {
    00217                                 retVal += ", ";
    00218                         } else {
    00219                                 firstRecord = false;
    00220                         }
    00221                         retVal += variants.get(i).getDescription();
    00222                 }
    00223                 return retVal;
    00224         }
    00225 }