1 23 package org.objectweb.clif.isac.plugins.httpmatrix10.tools; 24 25 31 public class MatrixDescription { 32 private double[][] matrix ; 33 private String [] urls ; 34 private double[] waiting_times ; 35 private int[] nbHitBeforeEnding ; 36 private int size ; 37 38 43 public MatrixDescription(int number) { 44 this.matrix = new double[number][number] ; 46 this.urls = new String [number] ; 47 this.waiting_times = new double[number] ; 48 this.nbHitBeforeEnding = new int[number] ; 49 this.size = number ; 51 } 52 53 60 public boolean setCell(int i, int j, double value) { 61 if (i <= size && j <= size) { 63 matrix[i][j] = value ; 65 return true ; 66 } 67 else 68 return false ; 70 } 71 72 78 public double getCell(int i, int j) { 79 if (i <= size && j <= size) { 81 return matrix[i][j] ; 83 } 84 else 85 return -1 ; 86 } 87 88 94 public boolean setUrl(int n, String url) { 95 if (n <= size) { 96 urls[n] = new String (url) ; 97 return true ; 98 } 99 else 100 return false ; 101 } 102 103 108 public String getUrl(int n) { 109 if (n <= size) { 110 return urls[n] ; 111 } 112 else 113 return null ; 114 } 115 116 122 public boolean setWaitingTime(int n, double waiting_time) { 123 if (n <= size) { 124 waiting_times[n] = waiting_time ; 125 return true ; 126 } 127 else 128 return false ; 129 } 130 131 136 public double getWaitingTime(int n) { 137 if (n <= size) { 138 return waiting_times[n] ; 139 } 140 else 141 return -1 ; 142 } 143 144 150 public boolean setNbHitBeforeEnding(int n, int nbB) { 151 if (n<=size) { 152 nbHitBeforeEnding[n] = nbB ; 153 return true; 154 } 155 return false ; 156 } 157 158 163 public int getNbHitBeforeEnding(int n) { 164 if (n<=size) { 165 return nbHitBeforeEnding[n]; 166 } 167 return -1; 168 } 169 170 173 public int getSize() { 174 return size; 175 } 176 177 180 public void setSize(int size) { 181 this.size = size; 182 } 183 184 188 public String toString() { 189 String result = "** Matrix Description : \n" ; 190 result = result.concat("-size=" + this.size + "\n") ; 191 for (int i=0;i<this.size;i++) { 192 result = result.concat("url"+i+"="+this.urls[i]+"\n") ; 193 result = result.concat(" waiting_time=" + waiting_times[i]+"\n") ; 194 } 195 for (int i=0;i<this.size;i++) { 196 for (int j=0;j<this.size;j++) { 197 result = result.concat(this.matrix[i][j]+" ") ; 198 } 199 result = result.concat("\n") ; 200 } 201 return result ; 202 } 203 } | Popular Tags |