peterreilly 2004/12/10 02:58:36 Modified: src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers Tag: ANT_16_BRANCH AntResolver.java LocationResolver.java URLResolver.java Log: sync Revision Changes Path No revision No revision 1.6.2.5 +47 -23 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/AntResolver.java Index: AntResolver.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/AntResolver.java,v retrieving revision 1.6.2.4 retrieving revision 1.6.2.5 diff -u -r1.6.2.4 -r1.6.2.5 --- AntResolver.java 9 Mar 2004 17:01:46 -0000 1.6.2.4 +++ AntResolver.java 10 Dec 2004 10:58:36 -0000 1.6.2.5 @@ -29,63 +29,87 @@ * * @version $Revision$ $Date$ */ -public class AntResolver - implements ExtensionResolver { - private File m_antfile; - private File m_destfile; - private String m_target; - - public void setAntfile(File antfile) { - m_antfile = antfile; +public class AntResolver implements ExtensionResolver { + private File antfile; + private File destfile; + private String target; + + /** + * Sets the ant file + * @param antfile the ant file to set + */ + public void setAntfile(final File antfile) { + this.antfile = antfile; } - public void setDestfile(File destfile) { - m_destfile = destfile; + /** + * Sets the destination file + * @param destfile the destination file + */ + public void setDestfile(final File destfile) { + this.destfile = destfile; } + /** + * Sets the target + * @param target the target + */ public void setTarget(final String target) { - m_target = target; + this.target = target; } + /** + * Returns the resolved file + * @param extension the extension + * @param project the project + * @return the file resolved + * @throws BuildException if the file cannot be resolved + */ public File resolve(final Extension extension, - final Project project) - throws BuildException { + final Project project) throws BuildException { validate(); final Ant ant = (Ant) project.createTask("ant"); ant.setInheritAll(false); - ant.setAntfile(m_antfile.getName()); + ant.setAntfile(antfile.getName()); try { final File dir = - m_antfile.getParentFile().getCanonicalFile(); + antfile.getParentFile().getCanonicalFile(); ant.setDir(dir); } catch (final IOException ioe) { throw new BuildException(ioe.getMessage(), ioe); } - if (null != m_target) { - ant.setTarget(m_target); + if (null != target) { + ant.setTarget(target); } ant.execute(); - return m_destfile; + return destfile; } - + + /* + * Validates URL + */ private void validate() { - if (null == m_antfile) { + if (null == antfile) { final String message = "Must specify Buildfile"; throw new BuildException(message); } - if (null == m_destfile) { + if (null == destfile) { final String message = "Must specify destination file"; throw new BuildException(message); } } + /** + * Returns a string representation + * @return the string representation + */ public String toString() { - return "Ant[" + m_antfile + "==>" + m_destfile + "]"; + return "Ant[" + antfile + "==>" + destfile + "]"; } } 1.6.2.5 +23 -11 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/LocationResolver.java Index: LocationResolver.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/LocationResolver.java,v retrieving revision 1.6.2.4 retrieving revision 1.6.2.5 diff -u -r1.6.2.4 -r1.6.2.5 --- LocationResolver.java 9 Mar 2004 17:01:46 -0000 1.6.2.4 +++ LocationResolver.java 10 Dec 2004 10:58:36 -0000 1.6.2.5 @@ -27,26 +27,38 @@ * * @version $Revision$ $Date$ */ -public class LocationResolver - implements ExtensionResolver { - private String m_location; +public class LocationResolver implements ExtensionResolver { + private String location; + /** + * Sets the location for this resolver + * @param location the location + */ public void setLocation(final String location) { - m_location = location; + this.location = location; } + /** + * Returns the resolved file + * @param extension the extension + * @param project the project + * @return the file resolved + * @throws BuildException if no location is set + */ public File resolve(final Extension extension, - final Project project) - throws BuildException { - if (null == m_location) { + final Project project) throws BuildException { + if (null == location) { final String message = "No location specified for resolver"; throw new BuildException(message); } - return project.resolveFile(m_location); + return project.resolveFile(location); } - + /** + * Returns a string representation of the Location + * @return the string representation + */ public String toString() { - return "Location[" + m_location + "]"; + return "Location[" + location + "]"; } } 1.6.2.5 +51 -23 ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/URLResolver.java Index: URLResolver.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/URLResolver.java,v retrieving revision 1.6.2.4 retrieving revision 1.6.2.5 diff -u -r1.6.2.4 -r1.6.2.5 --- URLResolver.java 9 Mar 2004 17:01:46 -0000 1.6.2.4 +++ URLResolver.java 10 Dec 2004 10:58:36 -0000 1.6.2.5 @@ -29,45 +29,66 @@ * * @version $Revision$ $Date$ */ -public class URLResolver - implements ExtensionResolver { - private File m_destfile; - private File m_destdir; - private URL m_url; - +public class URLResolver implements ExtensionResolver { + private File destfile; + private File destdir; + private URL url; + + /** + * Sets the URL + * @param url the url + */ public void setUrl(final URL url) { - m_url = url; + this.url = url; } + /** + * Sets the destination file + * @param destfile the destination file + */ public void setDestfile(final File destfile) { - m_destfile = destfile; + this.destfile = destfile; } + /** + * Sets the destination directory + * @param destdir the destination directory + */ public void setDestdir(final File destdir) { - m_destdir = destdir; + this.destdir = destdir; } + /** + * Returns the file resolved from URL and directory + * @param extension the extention + * @param project the project + * @return file the file resolved + * @throws BuildException if the URL is invalid + */ public File resolve(final Extension extension, - final Project project) - throws BuildException { + final Project project) throws BuildException { validate(); final File file = getDest(); final Get get = (Get) project.createTask("get"); get.setDest(file); - get.setSrc(m_url); + get.setSrc(url); get.execute(); return file; } + /* + * Gets the destination file + */ private File getDest() { - if (null != m_destfile) { - return m_destfile; + File result; + if (null != destfile) { + result = destfile; } else { - final String file = m_url.getFile(); - String filename = null; + final String file = url.getFile(); + String filename; if (null == file || file.length() <= 1) { filename = "default.file"; } else { @@ -77,27 +98,34 @@ } filename = file.substring(index); } - - return new File(m_destdir, filename); + result = new File(destdir, filename); } + return result; } + /* + * Validates URL + */ private void validate() { - if (null == m_url) { + if (null == url) { final String message = "Must specify URL"; throw new BuildException(message); } - if (null == m_destdir && null == m_destfile) { + if (null == destdir && null == destfile) { final String message = "Must specify destination file or directory"; throw new BuildException(message); - } else if (null != m_destdir && null != m_destfile) { + } else if (null != destdir && null != destfile) { final String message = "Must not specify both destination file or directory"; throw new BuildException(message); } } + /** + * Returns a string representation of the URL + * @return the string representation + */ public String toString() { - return "URL[" + m_url + "]"; + return "URL[" + url + "]"; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]