/** * Set the URL from a File. * @param f the File to set as a URL. */ public synchronized void setFile(File f) { try { setURL(FILE_UTILS.getFileURL(f)); } catch (MalformedURLException e) { throw new BuildException(e); } }
return FILE_UTILS.getFileURL(resource); } catch (MalformedURLException ex) { return null; if (entry != null) { try { return new URL("jar:" + FILE_UTILS.getFileURL(file) + "!/" + entry); } catch (MalformedURLException ex) { return null;
URL baseURL = FILE_UTILS.getFileURL(pathComponent); StringTokenizer st = new StringTokenizer(classpath); while (st.hasMoreTokens()) {
/** * get the URL of the schema * @return a URL to the schema * @throws BuildException if not */ public String getSchemaLocationURL() { boolean hasFile = file != null; boolean hasURL = isSet(url); //error if both are empty, or both are set if (!hasFile && !hasURL) { throw new BuildException(ERROR_NO_LOCATION + namespace); } if (hasFile && hasURL) { throw new BuildException(ERROR_TWO_LOCATIONS + namespace); } String schema = url; if (hasFile) { if (!file.exists()) { throw new BuildException(ERROR_NO_FILE + file); } try { schema = FileUtils.getFileUtils().getFileURL(file).toString(); } catch (MalformedURLException e) { //this is almost implausible, but required handling throw new BuildException(ERROR_NO_URL_REPRESENTATION + file, e); } } return schema; }
/** * sets the build file to which the XML context belongs * @param buildFile ant build file */ public void setBuildFile(File buildFile) { this.buildFile = buildFile; if (buildFile != null) { this.buildFileParent = new File(buildFile.getParent()); implicitTarget.setLocation(new Location(buildFile.getAbsolutePath())); try { setBuildFile(FileUtils.getFileUtils().getFileURL(buildFile)); } catch (MalformedURLException ex) { throw new BuildException(ex); } } else { this.buildFileParent = null; } }
final URL baseURL = FILE_UTILS.getFileURL(pathComponent); final StringTokenizer st = new StringTokenizer(classpath); while (st.hasMoreTokens()) {
return FileUtils.getFileUtils().getFileURL(file); } catch (Exception ex) { message =
return FILE_UTILS.getFileURL(resource); } catch (final MalformedURLException ex) { return null; if (entry != null) { try { return new URL("jar:" + FILE_UTILS.getFileURL(file) + "!/" + entry); } catch (final MalformedURLException ex) { return null;
} else { try { baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); } catch (MalformedURLException ex) { throw new BuildException("Project basedir cannot be converted to a URL");
} else { try { baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); } catch (MalformedURLException ex) { throw new BuildException("Project basedir cannot be converted to a URL"); + uri + "' matches a readable file", Project.MSG_DEBUG); try { url = FILE_UTILS.getFileURL(testFile); } catch (MalformedURLException ex1) { throw new BuildException(
/** * Define a class given its bytes * * @param container the container from which the class data has been read * may be a directory or a jar/zip file. * * @param classData the bytecode data for the class * @param classname the name of the class * * @return the Class instance created from the given data * * @throws IOException if the class data cannot be read. */ protected Class defineClassFromData(File container, byte[] classData, String classname) throws IOException { definePackage(container, classname); ProtectionDomain currentPd = Project.class.getProtectionDomain(); String classResource = getClassFilename(classname); CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), getCertificates(container, classResource)); ProtectionDomain classesPd = new ProtectionDomain(src, currentPd.getPermissions(), this, currentPd.getPrincipals()); return defineClass(classname, classData, 0, classData.length, classesPd); }
try { if (base == null) { baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); } else { baseURL = new URL(base);
base = FILE_UTILS.getFileURL(getProject().getBaseDir()).toString(); } catch (MalformedURLException x) { throw new TransformerException(x);
/** * Define a class given its bytes * * @param container the container from which the class data has been read * may be a directory or a jar/zip file. * * @param classData the bytecode data for the class * @param classname the name of the class * * @return the Class instance created from the given data * * @throws IOException if the class data cannot be read. */ protected Class<?> defineClassFromData(final File container, final byte[] classData, final String classname) throws IOException { definePackage(container, classname); final ProtectionDomain currentPd = Project.class.getProtectionDomain(); final String classResource = getClassFilename(classname); final CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), getCertificates(container, classResource)); final ProtectionDomain classesPd = new ProtectionDomain(src, currentPd.getPermissions(), this, currentPd.getPrincipals()); return defineClass(classname, classData, 0, classData.length, classesPd); }
if (hrefAsFile.exists()) { try { link = FILE_UTILS.getFileURL(hrefAsFile) .toExternalForm(); } catch (final MalformedURLException ex) { try { packageListURL = FILE_UTILS.getFileURL(packageListLocation); } catch (final MalformedURLException ex) { log("Warning: Package list location was "
return FILE_UTILS.getFileURL(resource); } catch (MalformedURLException ex) { return null; if (entry != null) { try { return new URL("jar:" + FILE_UTILS.getFileURL(file) + "!/" + entry); } catch (MalformedURLException ex) { return null;
URL baseURL = FILE_UTILS.getFileURL(pathComponent); StringTokenizer st = new StringTokenizer(classpath); while (st.hasMoreTokens()) {
/** * Define a class given its bytes * * @param container the container from which the class data has been read * may be a directory or a jar/zip file. * * @param classData the bytecode data for the class * @param classname the name of the class * * @return the Class instance created from the given data * * @throws IOException if the class data cannot be read. */ protected Class defineClassFromData(File container, byte[] classData, String classname) throws IOException { definePackage(container, classname); ProtectionDomain currentPd = Project.class.getProtectionDomain(); String classResource = getClassFilename(classname); CodeSource src = new CodeSource(FILE_UTILS.getFileURL(container), getCertificates(container, classResource)); ProtectionDomain classesPd = new ProtectionDomain(src, currentPd.getPermissions(), this, currentPd.getPrincipals()); return defineClass(classname, classData, 0, classData.length, classesPd); }