1 26 27 package org.objectweb.jonas.ear.lib; 28 29 import java.io.File ; 31 import java.io.IOException ; 32 import java.net.URL ; 33 import java.util.Enumeration ; 34 import java.util.StringTokenizer ; 35 import java.util.Vector ; 36 37 import org.objectweb.jonas_ear.deployment.xml.Web; 38 39 45 public class JarList extends Vector { 46 47 50 public JarList() { 51 super(); 52 } 53 54 58 public JarList(StringTokenizer st) { 59 super(); 60 61 while (st.hasMoreTokens()) { 63 String fileName = st.nextToken(); 64 add(fileName); 65 } 66 } 67 68 72 public JarList(String [] strs) { 73 super(); 74 75 for (int i = 0; i < strs.length; i++) { 76 add(strs[i]); 77 } 78 } 79 80 84 public JarList(Web[] wars) { 85 super(); 86 87 for (int i = 0; i < wars.length; i++) { 88 String s = wars[i].getWebUri(); 89 add(s); 90 } 91 } 92 93 97 public void add(String fileName) { 98 if (!contains(fileName) && !fileName.equals("")) { 99 super.add(fileName); 100 } 101 } 102 103 109 public URL [] getURLs(String dirName) throws JarListException { 110 111 URL [] urls = new URL [elementCount]; 112 for (int i = 0; i < elementCount; i++) { 113 String s = (String ) elementData[i]; 114 try { 115 urls[i] = new File (new URL (dirName + File.separator + s).getFile()).getCanonicalFile().toURL(); 116 } catch (IOException e) { 117 throw new JarListException("Error when trying to get the canonical form for the file " + elementData[i]); 118 } 119 } 120 return urls; 121 } 122 123 128 public void merge(JarList jarList) { 129 for (Enumeration e = jarList.elements(); e.hasMoreElements();) { 130 String s = (String ) e.nextElement(); 131 add(s); 133 } 134 } 135 136 140 public void remove(JarList jarList) { 141 142 for (Enumeration e = jarList.elements(); e.hasMoreElements();) { 143 String s = (String ) e.nextElement(); 144 if (contains(s)) { 145 remove(s); 146 } 147 } 148 } 149 150 156 public void setRelativePath(String path) { 157 if (path.equals("")) { 158 return; 159 } 160 161 for (int i = 0; i < elementCount; i++) { 162 elementData[i] = path + File.separator + elementData[i]; 163 } 164 } 165 } | Popular Tags |