CPD Results

The following document contains the results of PMD's CPD 3.9.

Duplications

FileProjectLine
net\n0fx\netserve\classloader\ClassLoaderUtil.javaStartup12
net\n0fx\netserve\classloader\util\ClassLoaderUtil.javaCore18
	private static final FilenameFilter LIB_FILTER = new LibraryFilter();
	
	public static final String ALLOWED_SEPERATORS = ",|;";
	
	public static URL[] directoryToUrls(String directory){
		ArrayList urlList = new ArrayList();
		if(directory == null || directory.length() == 0){
			throw new IllegalArgumentException("Directory must not be null");
		}
		
		File dir = new File(directory);
		if(!dir.isDirectory()){
			throw new IllegalArgumentException(directory+" is not a directory");
		}
		
		String[] libraries = dir.list(LIB_FILTER);
		for (int i = 0; i < libraries.length; i++) {
			URL url = convertToUrl(directory+"/"+libraries[i]);
			if(url != null){
				urlList.add(url);
			}
		}
		
		return toUrlArray(urlList);
	}
	/**
	 * Converts the configuration file library String to an URL array.
	 * 
	 * @param library
	 * @return URLs
	 * @throws MalformedURLException
	 */
	public static URL[] convertToUrls(String library) {
		if (library == null || library.length() == 0) {
			return (URL[])null;
		}
		String[] files = library.split(ALLOWED_SEPERATORS);
		ArrayList urlList = new ArrayList();
		for (int idx = 0; idx < files.length; idx++) {
			URL url = convertToUrl(files[idx]);
			if(url!=null && !urlList.contains(url)){
				urlList.add(url);
			}
		}
		return toUrlArray(urlList);
	}
	private static URL[] toUrlArray(ArrayList urlList) {
		URL[] urls = new URL[urlList.size()];
		urlList.toArray(urls);
		return (URL[]) urlList.toArray(urls);
	}

	public static URL convertToUrl(String fileName) {
		URL url = null;
		File file = null;
		try {
			file = new File(fileName);
			if (file.exists() && file.isFile()) {
				url = file.toURI().toURL();