1 19 20 package com.izforge.izpack; 21 22 import java.io.Serializable ; 23 import java.text.DecimalFormat ; 24 import java.util.ArrayList ; 25 import java.util.HashSet ; 26 import java.util.List ; 27 import java.util.Set ; 28 29 import com.izforge.izpack.compiler.PackInfo; 30 31 36 public class Pack implements Serializable 37 { 38 39 static final long serialVersionUID = -5458360562175088671L; 40 41 42 public boolean loose; 43 44 45 public String name; 46 47 48 public String id; 49 50 55 public Set installGroups = new HashSet (); 56 57 61 public String excludeGroup = new String (); 62 63 67 public String group; 68 69 70 public String description; 71 72 73 public List osConstraints = null; 74 75 76 public List dependencies = null; 77 78 79 public List revDependencies = null; 80 81 82 public boolean required; 83 84 85 public long nbytes; 86 87 88 public boolean preselected; 89 90 91 public int color; 92 93 94 public final static int WHITE = 0; 95 96 97 public final static int GREY = 1; 98 99 100 public final static int BLACK = 2; 101 102 115 public Pack(String name, String id, String description, List osConstraints, List dependencies, 116 boolean required, boolean preselected, boolean loose, String excludegroup) 117 { 118 this.name = name; 119 this.id = id; 120 this.description = description; 121 this.osConstraints = osConstraints; 122 this.dependencies = dependencies; 123 this.required = required; 124 this.preselected = preselected; 125 this.loose = loose; 126 this.excludeGroup = excludegroup; 127 nbytes = 0; 128 color = PackInfo.WHITE; 129 } 130 131 136 public String toString() 137 { 138 return name + " (" + description + ")"; 139 } 140 141 143 public List getDependencies() 144 { 145 return dependencies; 146 } 147 148 149 155 public void addRevDep(String name0) 156 { 157 if (revDependencies == null) revDependencies = new ArrayList (); 158 revDependencies.add(name0); 159 } 160 161 166 public String depString() 167 { 168 String text = ""; 169 if (dependencies == null) return text; 170 String name0; 171 for (int i = 0; i < dependencies.size() - 1; i++) 172 { 173 name0 = (String ) dependencies.get(i); 174 text += name0 + ","; 175 } 176 name0 = (String ) dependencies.get(dependencies.size() - 1); 177 text += name0; 178 return text; 179 180 } 181 182 183 private final static double KILOBYTES = 1024.0; 184 185 186 private final static double MEGABYTES = 1024.0 * 1024.0; 187 188 189 private final static double GIGABYTES = 1024.0 * 1024.0 * 1024.0; 190 191 192 private final static DecimalFormat formatter = new DecimalFormat ("#,###.##"); 193 194 200 public static String toByteUnitsString(long bytes) 201 { 202 if (bytes < KILOBYTES) 203 return String.valueOf(bytes) + " bytes"; 204 else if (bytes < (MEGABYTES)) 205 { 206 double value = bytes / KILOBYTES; 207 return formatter.format(value) + " KB"; 208 } 209 else if (bytes < (GIGABYTES)) 210 { 211 double value = bytes / MEGABYTES; 212 return formatter.format(value) + " MB"; 213 } 214 else 215 { 216 double value = bytes / GIGABYTES; 217 return formatter.format(value) + " GB"; 218 } 219 } 220 } 221 | Popular Tags |