git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274774 13f79535-47bb-0310-9956-ffa450edef68master
@@ -35,7 +35,7 @@ | |||||
<!-- Import conventions --> | <!-- Import conventions --> | ||||
<module name="AvoidStarImport"/> | <module name="AvoidStarImport"/> | ||||
<module name="IllegalImport"/> | |||||
<!-- <module name="IllegalImport"/> --> | |||||
<module name="RedundantImport"/> | <module name="RedundantImport"/> | ||||
<module name="UnusedImports"/> | <module name="UnusedImports"/> | ||||
@@ -100,7 +100,7 @@ | |||||
<noframes> | <noframes> | ||||
<h2>Frame Alert</h2> | <h2>Frame Alert</h2> | ||||
<p> | <p> | ||||
This document is designed to be viewed using the frames feature. | |||||
This document is designed to be viewed using the frames feature. | |||||
If you see this message, you are using a non-frame-capable web client. | If you see this message, you are using a non-frame-capable web client. | ||||
</p> | </p> | ||||
</noframes> | </noframes> | ||||
@@ -113,8 +113,8 @@ | |||||
<td class="text-align:right"><h2>CheckStyle Audit</h2></td> | <td class="text-align:right"><h2>CheckStyle Audit</h2></td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td class="text-align:right">Designed for use with | |||||
<a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and | |||||
<td class="text-align:right">Designed for use with | |||||
<a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and | |||||
<a href='http://ant.apache.org/'>Ant</a>.</td> | <a href='http://ant.apache.org/'>Ant</a>.</td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
@@ -152,10 +152,10 @@ | |||||
background-color:#FFFFFF; | background-color:#FFFFFF; | ||||
color:#000000; | color:#000000; | ||||
} | } | ||||
.a td { | |||||
.oddrow td { | |||||
background: #efefef; | background: #efefef; | ||||
} | } | ||||
.b td { | |||||
.evenrow td { | |||||
background: #fff; | background: #fff; | ||||
} | } | ||||
th, td { | th, td { | ||||
@@ -305,14 +305,17 @@ | |||||
<h3>Summary</h3> | <h3>Summary</h3> | ||||
<xsl:variable name="fileCount" select="count(file)"/> | <xsl:variable name="fileCount" select="count(file)"/> | ||||
<xsl:variable name="errorCount" select="count(file/error)"/> | <xsl:variable name="errorCount" select="count(file/error)"/> | ||||
<xsl:variable name="fileErrorCount" select="count(file[count(error) != 0])"/> | |||||
<table class="log" border="0" cellpadding="5" cellspacing="2" width="100%"> | <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%"> | ||||
<tr> | <tr> | ||||
<th>Files</th> | |||||
<th>Total Files</th> | |||||
<th>Files With Errors</th> | |||||
<th>Errors</th> | <th>Errors</th> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<xsl:call-template name="alternated-row"/> | <xsl:call-template name="alternated-row"/> | ||||
<td><xsl:value-of select="$fileCount"/></td> | <td><xsl:value-of select="$fileCount"/></td> | ||||
<td><xsl:value-of select="$fileErrorCount"/></td> | |||||
<td><xsl:value-of select="$errorCount"/></td> | <td><xsl:value-of select="$errorCount"/></td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
@@ -320,8 +323,8 @@ | |||||
<xsl:template name="alternated-row"> | <xsl:template name="alternated-row"> | ||||
<xsl:attribute name="class"> | <xsl:attribute name="class"> | ||||
<xsl:if test="position() mod 2 = 1">a</xsl:if> | |||||
<xsl:if test="position() mod 2 = 0">b</xsl:if> | |||||
<xsl:if test="position() mod 2 = 1">oddrow</xsl:if> | |||||
<xsl:if test="position() mod 2 = 0">evenrow</xsl:if> | |||||
</xsl:attribute> | </xsl:attribute> | ||||
</xsl:template> | </xsl:template> | ||||
</xsl:stylesheet> | </xsl:stylesheet> | ||||
@@ -91,7 +91,7 @@ | |||||
</table> | </table> | ||||
</section> | </section> | ||||
</xsl:template> | </xsl:template> | ||||
<xsl:template match="file" mode="filelist"> | <xsl:template match="file" mode="filelist"> | ||||
<tr> | <tr> | ||||
<xsl:call-template name="alternated-row"/> | <xsl:call-template name="alternated-row"/> | ||||
@@ -139,14 +139,17 @@ | |||||
<section name="Summary"> | <section name="Summary"> | ||||
<xsl:variable name="fileCount" select="count(file)"/> | <xsl:variable name="fileCount" select="count(file)"/> | ||||
<xsl:variable name="errorCount" select="count(file/error)"/> | <xsl:variable name="errorCount" select="count(file/error)"/> | ||||
<xsl:variable name="fileErrorCount" select="count(file[count(error) != 0])"/> | |||||
<table> | <table> | ||||
<tr> | <tr> | ||||
<th>Files</th> | <th>Files</th> | ||||
<th>Files With Errors</th> | |||||
<th>Errors</th> | <th>Errors</th> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<xsl:call-template name="alternated-row"/> | <xsl:call-template name="alternated-row"/> | ||||
<td><xsl:value-of select="$fileCount"/></td> | <td><xsl:value-of select="$fileCount"/></td> | ||||
<td><xsl:value-of select="$fileErrorCount"/></td> | |||||
<td><xsl:value-of select="$errorCount"/></td> | <td><xsl:value-of select="$errorCount"/></td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
@@ -63,12 +63,12 @@ import java.util.Enumeration; | |||||
- ns param. It could be used to provide "namespaces" for properties, which | - ns param. It could be used to provide "namespaces" for properties, which | ||||
may be more flexible. | may be more flexible. | ||||
- Object value. In ant1.5 String is used for Properties - but it would be nice | - Object value. In ant1.5 String is used for Properties - but it would be nice | ||||
to support generic Objects ( the property remains imutable - you can't change | |||||
the associated object ). This will also allow JSP-EL style setting using the | |||||
Object if an attribute contains only the property ( name="${property}" could | |||||
avoid Object->String->Object conversion ) | |||||
- Currently we "chain" only for get and set property ( probably most users | |||||
will only need that - if they need more they can replace the top helper ). | |||||
to support generic Objects (the property remains imutable - you can't change | |||||
the associated object). This will also allow JSP-EL style setting using the | |||||
Object if an attribute contains only the property (name="${property}" could | |||||
avoid Object->String->Object conversion) | |||||
- Currently we "chain" only for get and set property (probably most users | |||||
will only need that - if they need more they can replace the top helper). | |||||
Need to discuss this and find if we need more. | Need to discuss this and find if we need more. | ||||
*/ | */ | ||||
@@ -84,66 +84,89 @@ import java.util.Enumeration; | |||||
*/ | */ | ||||
public class PropertyHelper { | public class PropertyHelper { | ||||
protected Project project; | |||||
protected PropertyHelper next; | |||||
private Project project; | |||||
private PropertyHelper next; | |||||
/** Project properties map (usually String to String). */ | /** Project properties map (usually String to String). */ | ||||
protected Hashtable properties = new Hashtable(); | |||||
private Hashtable properties = new Hashtable(); | |||||
/** | /** | ||||
* Map of "user" properties (as created in the Ant task, for example). | * Map of "user" properties (as created in the Ant task, for example). | ||||
* Note that these key/value pairs are also always put into the | * Note that these key/value pairs are also always put into the | ||||
* project properties, so only the project properties need to be queried. | * project properties, so only the project properties need to be queried. | ||||
* Mapping is String to String. | * Mapping is String to String. | ||||
*/ | */ | ||||
protected Hashtable userProperties = new Hashtable(); | |||||
private Hashtable userProperties = new Hashtable(); | |||||
/** | /** | ||||
* Map of inherited "user" properties - that are those "user" | * Map of inherited "user" properties - that are those "user" | ||||
* properties that have been created by tasks and not been set | * properties that have been created by tasks and not been set | ||||
* from the command line or a GUI tool. | * from the command line or a GUI tool. | ||||
* Mapping is String to String. | * Mapping is String to String. | ||||
*/ | */ | ||||
protected Hashtable inheritedProperties = new Hashtable(); | |||||
private Hashtable inheritedProperties = new Hashtable(); | |||||
/** | |||||
* Default constructor. | |||||
*/ | |||||
protected PropertyHelper() { | protected PropertyHelper() { | ||||
} | } | ||||
// -------------------- Hook management -------------------- | // -------------------- Hook management -------------------- | ||||
public void setProject(Project p ) { | |||||
this.project=p; | |||||
/** | |||||
* Set the project for which this helper is performing property resolution | |||||
* | |||||
* @param p the projetc instance. | |||||
*/ | |||||
public void setProject(Project p) { | |||||
this.project = p; | |||||
} | } | ||||
/** There are 2 ways to hook into property handling: | /** There are 2 ways to hook into property handling: | ||||
* - you can replace the main PropertyHelper. The replacement is required | * - you can replace the main PropertyHelper. The replacement is required | ||||
* to support the same semantics ( of course :-) | |||||
* to support the same semantics (of course :-) | |||||
* | * | ||||
* - you can chain a property helper capable of storing some properties. | * - you can chain a property helper capable of storing some properties. | ||||
* Again, you are required to respect the immutability semantics ( at | |||||
* least for non-dynamic properties ) | |||||
* Again, you are required to respect the immutability semantics (at | |||||
* least for non-dynamic properties) | |||||
* | * | ||||
* @param next | |||||
* @param next the next property helper in the chain. | |||||
*/ | */ | ||||
public void setNext( PropertyHelper next ) { | |||||
this.next=next; | |||||
public void setNext(PropertyHelper next) { | |||||
this.next = next; | |||||
} | } | ||||
/** | |||||
* Get the next property helper in the chain. | |||||
* | |||||
* @return the next proprty helper. | |||||
*/ | |||||
public PropertyHelper getNext() { | public PropertyHelper getNext() { | ||||
return next; | return next; | ||||
} | } | ||||
/** Factory method to create a property processor. | |||||
* Users can provide their own or replace it using "ant.PropertyHelper" | |||||
* reference. User tasks can also add themself to the chain, and provide | |||||
* dynamic properties. | |||||
/** | |||||
* Factory method to create a property processor. | |||||
* Users can provide their own or replace it using "ant.PropertyHelper" | |||||
* reference. User tasks can also add themself to the chain, and provide | |||||
* dynamic properties. | |||||
* | |||||
* @param project the project fro which the property helper is required. | |||||
* | |||||
* @return the project's property helper. | |||||
*/ | */ | ||||
public static PropertyHelper getPropertyHelper(Project project) { | public static PropertyHelper getPropertyHelper(Project project) { | ||||
PropertyHelper ph=(PropertyHelper)project.getReference( "ant.PropertyHelper" ); | |||||
if( ph!=null ) return ph; | |||||
ph=new PropertyHelper(); | |||||
ph.setProject( project ); | |||||
PropertyHelper helper | |||||
= (PropertyHelper) project.getReference("ant.PropertyHelper"); | |||||
if (helper != null) { | |||||
return helper; | |||||
} | |||||
helper = new PropertyHelper(); | |||||
helper.setProject(project); | |||||
project.addReference( "ant.PropertyHelper",ph ); | |||||
return ph; | |||||
project.addReference("ant.PropertyHelper", helper); | |||||
return helper; | |||||
} | } | ||||
// -------------------- Methods to override -------------------- | // -------------------- Methods to override -------------------- | ||||
@@ -161,19 +184,18 @@ public class PropertyHelper { | |||||
* @param value The new value of the property. | * @param value The new value of the property. | ||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
* @return true if this helper has stored the property, false if it | * @return true if this helper has stored the property, false if it | ||||
* couldn't. Each helper should delegate to the next one ( unless it | |||||
* has a good reason not to ). | |||||
* couldn't. Each helper should delegate to the next one (unless it | |||||
* has a good reason not to). | |||||
*/ | */ | ||||
public boolean setPropertyHook(String ns, String name, | public boolean setPropertyHook(String ns, String name, | ||||
Object value, | Object value, | ||||
boolean inherited, boolean user, | boolean inherited, boolean user, | ||||
boolean isNew) | |||||
{ | |||||
if( getNext()!=null ) { | |||||
boolean subst=getNext().setPropertyHook(ns, name, value, | |||||
boolean isNew) { | |||||
if (getNext() != null) { | |||||
boolean subst = getNext().setPropertyHook(ns, name, value, | |||||
inherited, user, isNew); | inherited, user, isNew); | ||||
// If next has handled the property | // If next has handled the property | ||||
if( subst ) { | |||||
if (subst) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -189,15 +211,19 @@ public class PropertyHelper { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public Object getPropertyHook(String ns, String name, boolean user) { | public Object getPropertyHook(String ns, String name, boolean user) { | ||||
if( getNext() != null ) { | |||||
Object o=getNext().getPropertyHook(ns, name, user); | |||||
if( o!= null ) return o; | |||||
if (getNext() != null) { | |||||
Object o = getNext().getPropertyHook(ns, name, user); | |||||
if (o != null) { | |||||
return o; | |||||
} | |||||
} | } | ||||
// Experimental/Testing, will be removed | // Experimental/Testing, will be removed | ||||
if( name.startsWith( "toString:" )) { | |||||
name=name.substring( "toString:".length()); | |||||
Object v=project.getReference( name ); | |||||
if( v==null ) return null; | |||||
if (name.startsWith("toString:")) { | |||||
name = name.substring("toString:".length()); | |||||
Object v = project.getReference(name); | |||||
if (v == null) { | |||||
return null; | |||||
} | |||||
return v.toString(); | return v.toString(); | ||||
} | } | ||||
@@ -207,9 +233,9 @@ public class PropertyHelper { | |||||
// -------------------- Optional methods -------------------- | // -------------------- Optional methods -------------------- | ||||
// You can override those methods if you want to optimize or | // You can override those methods if you want to optimize or | ||||
// do advanced things ( like support a special syntax ). | |||||
// do advanced things (like support a special syntax). | |||||
// The methods do not chain - you should use them when embedding ant | // The methods do not chain - you should use them when embedding ant | ||||
// ( by replacing the main helper ) | |||||
// (by replacing the main helper) | |||||
/** | /** | ||||
* Parses a string containing <code>${xxx}</code> style property | * Parses a string containing <code>${xxx}</code> style property | ||||
@@ -232,8 +258,7 @@ public class PropertyHelper { | |||||
*/ | */ | ||||
public void parsePropertyString(String value, Vector fragments, | public void parsePropertyString(String value, Vector fragments, | ||||
Vector propertyRefs) | Vector propertyRefs) | ||||
throws BuildException | |||||
{ | |||||
throws BuildException { | |||||
parsePropertyStringDefault(value, fragments, propertyRefs); | parsePropertyStringDefault(value, fragments, propertyRefs); | ||||
} | } | ||||
@@ -256,8 +281,7 @@ public class PropertyHelper { | |||||
*/ | */ | ||||
public String replaceProperties(String ns, String value, | public String replaceProperties(String ns, String value, | ||||
Hashtable keys) | Hashtable keys) | ||||
throws BuildException | |||||
{ | |||||
throws BuildException { | |||||
if (value == null) { | if (value == null) { | ||||
return null; | return null; | ||||
} | } | ||||
@@ -274,22 +298,22 @@ public class PropertyHelper { | |||||
String fragment = (String) i.nextElement(); | String fragment = (String) i.nextElement(); | ||||
if (fragment == null) { | if (fragment == null) { | ||||
String propertyName = (String) j.nextElement(); | String propertyName = (String) j.nextElement(); | ||||
Object replacement=null; | |||||
Object replacement = null; | |||||
// try to get it from the project or keys | // try to get it from the project or keys | ||||
// Backward compatibility | // Backward compatibility | ||||
if( keys!=null ) { | |||||
replacement=keys.get(propertyName); | |||||
if (keys != null) { | |||||
replacement = keys.get(propertyName); | |||||
} | } | ||||
if( replacement==null ) { | |||||
replacement=getProperty(ns, propertyName); | |||||
if (replacement == null) { | |||||
replacement = getProperty(ns, propertyName); | |||||
} | } | ||||
if (replacement == null ) { | |||||
if (replacement == null) { | |||||
project.log("Property ${" + propertyName | project.log("Property ${" + propertyName | ||||
+ "} has not been set", Project.MSG_VERBOSE); | + "} has not been set", Project.MSG_VERBOSE); | ||||
} | } | ||||
fragment = (replacement!=null) | |||||
fragment = (replacement != null) | |||||
? replacement.toString() | ? replacement.toString() | ||||
: "${" + propertyName + "}"; | : "${" + propertyName + "}"; | ||||
} | } | ||||
@@ -309,19 +333,18 @@ public class PropertyHelper { | |||||
* added. | * added. | ||||
*/ | */ | ||||
public synchronized boolean setProperty(String ns, String name, | public synchronized boolean setProperty(String ns, String name, | ||||
Object value, boolean verbose) | |||||
{ | |||||
// user ( CLI ) properties take precedence | |||||
Object value, boolean verbose) { | |||||
// user (CLI) properties take precedence | |||||
if (null != userProperties.get(name)) { | if (null != userProperties.get(name)) { | ||||
if( verbose ) { | |||||
if (verbose) { | |||||
project.log("Override ignored for user property " + name, | project.log("Override ignored for user property " + name, | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
boolean done=this.setPropertyHook(ns, name, value, false, false, false); | |||||
if( done ) { | |||||
boolean done = setPropertyHook(ns, name, value, false, false, false); | |||||
if (done) { | |||||
return true; | return true; | ||||
} | } | ||||
@@ -330,9 +353,9 @@ public class PropertyHelper { | |||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
if( verbose ) { | |||||
project.log("Setting project property: " + name + " -> " + | |||||
value, Project.MSG_DEBUG); | |||||
if (verbose) { | |||||
project.log("Setting project property: " + name + " -> " | |||||
+ value, Project.MSG_DEBUG); | |||||
} | } | ||||
properties.put(name, value); | properties.put(name, value); | ||||
return true; | return true; | ||||
@@ -350,22 +373,21 @@ public class PropertyHelper { | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public synchronized void setNewProperty(String ns, String name, | public synchronized void setNewProperty(String ns, String name, | ||||
Object value) | |||||
{ | |||||
Object value) { | |||||
if (null != properties.get(name)) { | if (null != properties.get(name)) { | ||||
project.log("Override ignored for property " + name, | project.log("Override ignored for property " + name, | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
return; | return; | ||||
} | } | ||||
boolean done=this.setPropertyHook(ns, name, value, false, true, false); | |||||
if( done ) { | |||||
boolean done = setPropertyHook(ns, name, value, false, true, false); | |||||
if (done) { | |||||
return; | return; | ||||
} | } | ||||
project.log("Setting project property: " + name + " -> " + | |||||
value, Project.MSG_DEBUG); | |||||
if( name!= null && value!=null ) { | |||||
project.log("Setting project property: " + name + " -> " | |||||
+ value, Project.MSG_DEBUG); | |||||
if (name != null && value != null) { | |||||
properties.put(name, value); | properties.put(name, value); | ||||
} | } | ||||
} | } | ||||
@@ -379,14 +401,13 @@ public class PropertyHelper { | |||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
*/ | */ | ||||
public synchronized void setUserProperty(String ns, String name, | public synchronized void setUserProperty(String ns, String name, | ||||
Object value) | |||||
{ | |||||
project.log("Setting ro project property: " + name + " -> " + | |||||
value, Project.MSG_DEBUG); | |||||
Object value) { | |||||
project.log("Setting ro project property: " + name + " -> " | |||||
+ value, Project.MSG_DEBUG); | |||||
userProperties.put(name, value); | userProperties.put(name, value); | ||||
boolean done=this.setPropertyHook(ns, name, value, false, false, true); | |||||
if( done ) { | |||||
boolean done = setPropertyHook(ns, name, value, false, false, true); | |||||
if (done) { | |||||
return; | return; | ||||
} | } | ||||
properties.put(name, value); | properties.put(name, value); | ||||
@@ -404,16 +425,15 @@ public class PropertyHelper { | |||||
* Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
*/ | */ | ||||
public synchronized void setInheritedProperty(String ns, String name, | public synchronized void setInheritedProperty(String ns, String name, | ||||
Object value) | |||||
{ | |||||
Object value) { | |||||
inheritedProperties.put(name, value); | inheritedProperties.put(name, value); | ||||
project.log("Setting ro project property: " + name + " -> " + | |||||
value, Project.MSG_DEBUG); | |||||
project.log("Setting ro project property: " + name + " -> " | |||||
+ value, Project.MSG_DEBUG); | |||||
userProperties.put(name, value); | userProperties.put(name, value); | ||||
boolean done=this.setPropertyHook(ns, name, value, true, false, false); | |||||
if( done ) { | |||||
boolean done = setPropertyHook(ns, name, value, true, false, false); | |||||
if (done) { | |||||
return; | return; | ||||
} | } | ||||
properties.put(name, value); | properties.put(name, value); | ||||
@@ -436,8 +456,8 @@ public class PropertyHelper { | |||||
return null; | return null; | ||||
} | } | ||||
Object o=getPropertyHook(ns, name, false); | |||||
if( o!= null ) { | |||||
Object o = getPropertyHook(ns, name, false); | |||||
if (o != null) { | |||||
return o; | return o; | ||||
} | } | ||||
@@ -456,8 +476,8 @@ public class PropertyHelper { | |||||
if (name == null) { | if (name == null) { | ||||
return null; | return null; | ||||
} | } | ||||
Object o=getPropertyHook(ns, name, true); | |||||
if( o!= null ) { | |||||
Object o = getPropertyHook(ns, name, true); | |||||
if (o != null) { | |||||
return o; | return o; | ||||
} | } | ||||
return userProperties.get(name); | return userProperties.get(name); | ||||
@@ -466,7 +486,7 @@ public class PropertyHelper { | |||||
// -------------------- Access to property tables -------------------- | // -------------------- Access to property tables -------------------- | ||||
// This is used to support ant call and similar tasks. It should be | // This is used to support ant call and similar tasks. It should be | ||||
// deprecated, it is possible to use a better ( more efficient ) | |||||
// deprecated, it is possible to use a better (more efficient) | |||||
// mechanism to preserve the context. | // mechanism to preserve the context. | ||||
// TODO: do we need to delegate ? | // TODO: do we need to delegate ? | ||||
@@ -559,16 +579,15 @@ public class PropertyHelper { | |||||
// -------------------- Property parsing -------------------- | // -------------------- Property parsing -------------------- | ||||
// Moved from ProjectHelper. You can override the static method - | // Moved from ProjectHelper. You can override the static method - | ||||
// this is used for backward compatibility ( for code that calls | |||||
// the parse method in ProjectHelper ). | |||||
// this is used for backward compatibility (for code that calls | |||||
// the parse method in ProjectHelper). | |||||
/** Default parsing method. It is here only to support backward compat | /** Default parsing method. It is here only to support backward compat | ||||
* for the static ProjectHelper.parsePropertyString(). | * for the static ProjectHelper.parsePropertyString(). | ||||
*/ | */ | ||||
static void parsePropertyStringDefault(String value, Vector fragments, | static void parsePropertyStringDefault(String value, Vector fragments, | ||||
Vector propertyRefs) | Vector propertyRefs) | ||||
throws BuildException | |||||
{ | |||||
throws BuildException { | |||||
int prev = 0; | int prev = 0; | ||||
int pos; | int pos; | ||||
//search for the next instance of $ from the 'prev' position | //search for the next instance of $ from the 'prev' position | ||||
@@ -57,7 +57,13 @@ package org.apache.tools.ant.listener; | |||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
import org.apache.commons.logging.LogConfigurationException; | import org.apache.commons.logging.LogConfigurationException; | ||||
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.BuildListener; | |||||
import org.apache.tools.ant.BuildLogger; | |||||
import org.apache.tools.ant.BuildEvent; | |||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | |||||
import org.apache.tools.ant.UnknownElement; | |||||
import java.io.PrintStream; | import java.io.PrintStream; | ||||
@@ -74,7 +80,7 @@ import java.io.PrintStream; | |||||
* | * | ||||
* In all target and project names we replace "." and " " with "-". | * In all target and project names we replace "." and " " with "-". | ||||
* | * | ||||
* TODO: we should use the advanced context logging features ( and expose them | |||||
* TODO: we should use the advanced context logging features (and expose them | |||||
* in c-l first :-) | * in c-l first :-) | ||||
* TODO: this is _very_ inefficient. Switching the out and tracking the logs | * TODO: this is _very_ inefficient. Switching the out and tracking the logs | ||||
* can be optimized a lot - but may require few more changes to the core. | * can be optimized a lot - but may require few more changes to the core. | ||||
@@ -96,18 +102,18 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
public CommonsLoggingListener() { | public CommonsLoggingListener() { | ||||
} | } | ||||
private Log getLog( String cat, String suffix ) { | |||||
if( suffix != null ) { | |||||
suffix=suffix.replace('.', '-'); | |||||
suffix=suffix.replace(' ', '-'); | |||||
cat=cat + "." + suffix; | |||||
private Log getLog(String cat, String suffix) { | |||||
if (suffix != null) { | |||||
suffix = suffix.replace('.', '-'); | |||||
suffix = suffix.replace(' ', '-'); | |||||
cat = cat + "." + suffix; | |||||
} | } | ||||
PrintStream tmpOut=System.out; | |||||
PrintStream tmpErr=System.err; | |||||
System.setOut( out ); | |||||
System.setErr( err ); | |||||
PrintStream tmpOut = System.out; | |||||
PrintStream tmpErr = System.err; | |||||
System.setOut(out); | |||||
System.setErr(err); | |||||
if( ! initialized ) { | |||||
if (!initialized) { | |||||
try { | try { | ||||
logFactory = LogFactory.getFactory(); | logFactory = LogFactory.getFactory(); | ||||
} catch (LogConfigurationException e) { | } catch (LogConfigurationException e) { | ||||
@@ -117,9 +123,9 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
} | } | ||||
initialized = true; | initialized = true; | ||||
Log log=logFactory.getInstance(cat); | |||||
System.setOut( tmpOut ); | |||||
System.setErr( tmpErr ); | |||||
Log log = logFactory.getInstance(cat); | |||||
System.setOut(tmpOut); | |||||
System.setErr(tmpErr); | |||||
return log; | return log; | ||||
} | } | ||||
@@ -127,11 +133,11 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
* @see BuildListener#buildStarted | * @see BuildListener#buildStarted | ||||
*/ | */ | ||||
public void buildStarted(BuildEvent event) { | public void buildStarted(BuildEvent event) { | ||||
String categoryString= "org.apache.tools.ant.Project"; | |||||
Log log=getLog(categoryString, null); | |||||
String categoryString = "org.apache.tools.ant.Project"; | |||||
Log log = getLog(categoryString, null); | |||||
if (initialized) { | if (initialized) { | ||||
realLog( log, "Build started.", Project.MSG_INFO, null); | |||||
realLog(log, "Build started.", Project.MSG_INFO, null); | |||||
} | } | ||||
} | } | ||||
@@ -140,13 +146,13 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
*/ | */ | ||||
public void buildFinished(BuildEvent event) { | public void buildFinished(BuildEvent event) { | ||||
if (initialized) { | if (initialized) { | ||||
String categoryString= "org.apache.tools.ant.Project"; | |||||
Log log=getLog(categoryString, event.getProject().getName()); | |||||
String categoryString = "org.apache.tools.ant.Project"; | |||||
Log log = getLog(categoryString, event.getProject().getName()); | |||||
if (event.getException() == null) { | if (event.getException() == null) { | ||||
realLog( log, "Build finished.", Project.MSG_INFO, null); | |||||
realLog(log, "Build finished.", Project.MSG_INFO, null); | |||||
} else { | } else { | ||||
realLog( log, "Build finished with error.", Project.MSG_ERR, | |||||
realLog(log, "Build finished with error.", Project.MSG_ERR, | |||||
event.getException()); | event.getException()); | ||||
} | } | ||||
} | } | ||||
@@ -158,10 +164,10 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
public void targetStarted(BuildEvent event) { | public void targetStarted(BuildEvent event) { | ||||
if (initialized) { | if (initialized) { | ||||
Log log = getLog("org.apache.tools.ant.Target", | Log log = getLog("org.apache.tools.ant.Target", | ||||
event.getTarget().getName() ); | |||||
event.getTarget().getName()); | |||||
// Since task log category includes target, we don't really | // Since task log category includes target, we don't really | ||||
// need this message | // need this message | ||||
realLog( log, "Start: " + event.getTarget().getName(), | |||||
realLog(log, "Start: " + event.getTarget().getName(), | |||||
Project.MSG_DEBUG, null); | Project.MSG_DEBUG, null); | ||||
} | } | ||||
} | } | ||||
@@ -173,7 +179,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
if (initialized) { | if (initialized) { | ||||
String targetName = event.getTarget().getName(); | String targetName = event.getTarget().getName(); | ||||
Log log = getLog("org.apache.tools.ant.Target", | Log log = getLog("org.apache.tools.ant.Target", | ||||
event.getTarget().getName() ); | |||||
event.getTarget().getName()); | |||||
if (event.getException() == null) { | if (event.getException() == null) { | ||||
realLog(log, "Target end: " + targetName, Project.MSG_DEBUG, null); | realLog(log, "Target end: " + targetName, Project.MSG_DEBUG, null); | ||||
} else { | } else { | ||||
@@ -190,16 +196,16 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
public void taskStarted(BuildEvent event) { | public void taskStarted(BuildEvent event) { | ||||
if (initialized) { | if (initialized) { | ||||
Task task = event.getTask(); | Task task = event.getTask(); | ||||
Object real=task; | |||||
if( task instanceof UnknownElement ) { | |||||
Object realObj=((UnknownElement)task).getTask(); | |||||
if( realObj!=null ) { | |||||
real=realObj; | |||||
Object real = task; | |||||
if (task instanceof UnknownElement) { | |||||
Object realObj = ((UnknownElement) task).getTask(); | |||||
if (realObj != null) { | |||||
real = realObj; | |||||
} | } | ||||
} | } | ||||
Log log = getLog(real.getClass().getName(), null); | Log log = getLog(real.getClass().getName(), null); | ||||
if( log.isTraceEnabled()) { | |||||
realLog( log, "Task \"" + task.getTaskName() + "\" started ", | |||||
if (log.isTraceEnabled()) { | |||||
realLog(log, "Task \"" + task.getTaskName() + "\" started ", | |||||
Project.MSG_VERBOSE, null); | Project.MSG_VERBOSE, null); | ||||
} | } | ||||
} | } | ||||
@@ -211,21 +217,21 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
public void taskFinished(BuildEvent event) { | public void taskFinished(BuildEvent event) { | ||||
if (initialized) { | if (initialized) { | ||||
Task task = event.getTask(); | Task task = event.getTask(); | ||||
Object real=task; | |||||
if( task instanceof UnknownElement ) { | |||||
Object realObj=((UnknownElement)task).getTask(); | |||||
if( realObj!=null ) { | |||||
real=realObj; | |||||
Object real = task; | |||||
if (task instanceof UnknownElement) { | |||||
Object realObj = ((UnknownElement) task).getTask(); | |||||
if (realObj != null) { | |||||
real = realObj; | |||||
} | } | ||||
} | } | ||||
Log log = getLog(real.getClass().getName(), null); | Log log = getLog(real.getClass().getName(), null); | ||||
if (event.getException() == null) { | if (event.getException() == null) { | ||||
if( log.isTraceEnabled() ) { | |||||
realLog( log, "Task \"" + task.getTaskName() + "\" finished.", | |||||
if (log.isTraceEnabled()) { | |||||
realLog(log, "Task \"" + task.getTaskName() + "\" finished.", | |||||
Project.MSG_VERBOSE, null); | Project.MSG_VERBOSE, null); | ||||
} | } | ||||
} else { | } else { | ||||
realLog( log, "Task \"" + task.getTaskName() | |||||
realLog(log, "Task \"" + task.getTaskName() | |||||
+ "\" finished with error.", Project.MSG_ERR, | + "\" finished with error.", Project.MSG_ERR, | ||||
event.getException()); | event.getException()); | ||||
} | } | ||||
@@ -239,63 +245,62 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
public void messageLogged(BuildEvent event) { | public void messageLogged(BuildEvent event) { | ||||
if (initialized) { | if (initialized) { | ||||
Object categoryObject = event.getTask(); | Object categoryObject = event.getTask(); | ||||
String categoryString=null; | |||||
String categoryDetail=null; | |||||
String categoryString = null; | |||||
String categoryDetail = null; | |||||
if (categoryObject == null) { | if (categoryObject == null) { | ||||
categoryObject = event.getTarget(); | categoryObject = event.getTarget(); | ||||
if (categoryObject == null) { | if (categoryObject == null) { | ||||
categoryObject = event.getProject(); | categoryObject = event.getProject(); | ||||
categoryString="org.apache.tools.ant.Project"; | |||||
categoryDetail=event.getProject().getName(); | |||||
categoryString = "org.apache.tools.ant.Project"; | |||||
categoryDetail = event.getProject().getName(); | |||||
} else { | } else { | ||||
categoryString= "org.apache.tools.ant.Target"; | |||||
categoryDetail=event.getTarget().getName(); | |||||
categoryString = "org.apache.tools.ant.Target"; | |||||
categoryDetail = event.getTarget().getName(); | |||||
} | } | ||||
} else { | } else { | ||||
// It's a task - append the target | // It's a task - append the target | ||||
if( event.getTarget() != null ) { | |||||
categoryString=categoryObject.getClass().getName(); | |||||
categoryDetail=event.getTarget().getName(); | |||||
if (event.getTarget() != null) { | |||||
categoryString = categoryObject.getClass().getName(); | |||||
categoryDetail = event.getTarget().getName(); | |||||
} else { | } else { | ||||
categoryString=categoryObject.getClass().getName(); | |||||
categoryString = categoryObject.getClass().getName(); | |||||
} | } | ||||
} | } | ||||
Log log = getLog(categoryString, categoryDetail); | Log log = getLog(categoryString, categoryDetail); | ||||
int priority=event.getPriority(); | |||||
String message=event.getMessage(); | |||||
realLog( log, message, priority , null); | |||||
int priority = event.getPriority(); | |||||
String message = event.getMessage(); | |||||
realLog(log, message, priority , null); | |||||
} | } | ||||
} | } | ||||
private void realLog( Log log, String message, int priority, Throwable t ) | |||||
{ | |||||
PrintStream tmpOut=System.out; | |||||
PrintStream tmpErr=System.err; | |||||
System.setOut( out ); | |||||
System.setErr( err ); | |||||
private void realLog(Log log, String message, int priority, Throwable t) { | |||||
PrintStream tmpOut = System.out; | |||||
PrintStream tmpErr = System.err; | |||||
System.setOut(out); | |||||
System.setErr(err); | |||||
switch (priority) { | switch (priority) { | ||||
case Project.MSG_ERR: | case Project.MSG_ERR: | ||||
if( t==null ) { | |||||
if (t == null) { | |||||
log.error(message); | log.error(message); | ||||
} else { | } else { | ||||
log.error( message,t ); | |||||
log.error(message, t); | |||||
} | } | ||||
break; | break; | ||||
case Project.MSG_WARN: | case Project.MSG_WARN: | ||||
if( t==null ) { | |||||
if (t == null) { | |||||
log.warn(message); | log.warn(message); | ||||
} else { | } else { | ||||
log.warn( message,t ); | |||||
log.warn(message, t); | |||||
} | } | ||||
break; | break; | ||||
case Project.MSG_INFO: | case Project.MSG_INFO: | ||||
if( t==null ) { | |||||
if (t == null) { | |||||
log.info(message); | log.info(message); | ||||
} else { | } else { | ||||
log.info( message,t ); | |||||
log.info(message, t); | |||||
} | } | ||||
break; | break; | ||||
case Project.MSG_VERBOSE: | case Project.MSG_VERBOSE: | ||||
@@ -308,8 +313,8 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
log.error(message); | log.error(message); | ||||
break; | break; | ||||
} | } | ||||
System.setOut( tmpOut ); | |||||
System.setErr( tmpErr ); | |||||
System.setOut(tmpOut); | |||||
System.setErr(tmpErr); | |||||
} | } | ||||
PrintStream out; | PrintStream out; | ||||
@@ -328,7 +333,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { | |||||
} | } | ||||
public void setErrorPrintStream(PrintStream err) { | public void setErrorPrintStream(PrintStream err) { | ||||
this.err=err; | |||||
this.err = err; | |||||
} | } | ||||
} | } |
@@ -353,6 +353,7 @@ public abstract class Definer extends Task { | |||||
try { | try { | ||||
is.close(); | is.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
// ignore | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -61,6 +61,9 @@ package org.apache.tools.ant.taskdefs.optional.ccm; | |||||
*/ | */ | ||||
public class CCMCheckout extends CCMCheck { | public class CCMCheckout extends CCMCheck { | ||||
/** | |||||
* default constructor | |||||
*/ | |||||
public CCMCheckout() { | public CCMCheckout() { | ||||
super(); | super(); | ||||
setCcmAction(COMMAND_CHECKOUT); | setCcmAction(COMMAND_CHECKOUT); | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -71,6 +71,9 @@ import org.apache.tools.ant.util.depend.AbstractAnalyzer; | |||||
* @author Conor MacNeill | * @author Conor MacNeill | ||||
*/ | */ | ||||
public class AntAnalyzer extends AbstractAnalyzer { | public class AntAnalyzer extends AbstractAnalyzer { | ||||
/** | |||||
* Default constructor | |||||
*/ | |||||
public AntAnalyzer() { | public AntAnalyzer() { | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -138,7 +138,7 @@ public abstract class ConstantPoolEntry { | |||||
* be read. | * be read. | ||||
* @return the appropriate ConstantPoolEntry subclass representing the | * @return the appropriate ConstantPoolEntry subclass representing the | ||||
* constant pool entry from the stream. | * constant pool entry from the stream. | ||||
* @exception IOException if the constant pool entry cannot be read | |||||
* @exception IOException if the constant pool entry cannot be read | |||||
* from the stream | * from the stream | ||||
*/ | */ | ||||
public static ConstantPoolEntry readEntry(DataInputStream cpStream) | public static ConstantPoolEntry readEntry(DataInputStream cpStream) | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -63,7 +63,7 @@ import java.io.IOException; | |||||
* @author Conor MacNeill | * @author Conor MacNeill | ||||
*/ | */ | ||||
public class DoubleCPInfo extends ConstantCPInfo { | public class DoubleCPInfo extends ConstantCPInfo { | ||||
/** | |||||
/** | |||||
* Constructor | * Constructor | ||||
*/ | */ | ||||
public DoubleCPInfo() { | public DoubleCPInfo() { | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -89,7 +89,7 @@ public class StringCPInfo extends ConstantCPInfo { | |||||
* @return the string representation of this constant pool entry. | * @return the string representation of this constant pool entry. | ||||
*/ | */ | ||||
public String toString() { | public String toString() { | ||||
return "String Constant Pool Entry for " | |||||
return "String Constant Pool Entry for " | |||||
+ getValue() + "[" + index + "]"; | + getValue() + "[" + index + "]"; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -66,38 +66,35 @@ import org.apache.tools.ant.Task; | |||||
* @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
* @ant.task name="jarlib-available" | * @ant.task name="jarlib-available" | ||||
*/ | */ | ||||
public class JarLibAvailableTask | |||||
extends Task | |||||
{ | |||||
public class JarLibAvailableTask extends Task { | |||||
/** | /** | ||||
* The library to display information about. | * The library to display information about. | ||||
*/ | */ | ||||
private File m_file; | |||||
private File libraryFile; | |||||
/** | /** | ||||
* Filesets specifying all the librarys | * Filesets specifying all the librarys | ||||
* to display information about. | * to display information about. | ||||
*/ | */ | ||||
private final Vector m_extensionSets = new Vector(); | |||||
private final Vector extensionFileSets = new Vector(); | |||||
/** | /** | ||||
* The name of the property to set if extension is available. | * The name of the property to set if extension is available. | ||||
*/ | */ | ||||
private String m_property; | |||||
private String propertyName; | |||||
/** | /** | ||||
* The extension that is required. | * The extension that is required. | ||||
*/ | */ | ||||
private ExtensionAdapter m_extension; | |||||
private ExtensionAdapter requiredExtension; | |||||
/** | /** | ||||
* The name of property to set if extensions are available. | * The name of property to set if extensions are available. | ||||
* | * | ||||
* @param property The name of property to set if extensions is available. | * @param property The name of property to set if extensions is available. | ||||
*/ | */ | ||||
public void setProperty( final String property ) | |||||
{ | |||||
m_property = property; | |||||
public void setProperty(final String property) { | |||||
this.propertyName = property; | |||||
} | } | ||||
/** | /** | ||||
@@ -105,9 +102,8 @@ public class JarLibAvailableTask | |||||
* | * | ||||
* @param file The jar library to check. | * @param file The jar library to check. | ||||
*/ | */ | ||||
public void setFile( final File file ) | |||||
{ | |||||
m_file = file; | |||||
public void setFile(final File file) { | |||||
this.libraryFile = file; | |||||
} | } | ||||
/** | /** | ||||
@@ -115,15 +111,13 @@ public class JarLibAvailableTask | |||||
* | * | ||||
* @param extension Set the Extension looking for. | * @param extension Set the Extension looking for. | ||||
*/ | */ | ||||
public void addConfiguredExtension( final ExtensionAdapter extension ) | |||||
{ | |||||
if( null != m_extension ) | |||||
{ | |||||
final String message = "Can not specify extension to " + | |||||
"search for multiple times."; | |||||
throw new BuildException( message ); | |||||
public void addConfiguredExtension(final ExtensionAdapter extension) { | |||||
if (null != requiredExtension) { | |||||
final String message = "Can not specify extension to " | |||||
+ "search for multiple times."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
m_extension = extension; | |||||
requiredExtension = extension; | |||||
} | } | ||||
/** | /** | ||||
@@ -131,47 +125,42 @@ public class JarLibAvailableTask | |||||
* | * | ||||
* @param extensionSet a set of extensions to search in. | * @param extensionSet a set of extensions to search in. | ||||
*/ | */ | ||||
public void addConfiguredExtensionSet( final ExtensionSet extensionSet ) | |||||
{ | |||||
m_extensionSets.addElement( extensionSet ); | |||||
public void addConfiguredExtensionSet(final ExtensionSet extensionSet) { | |||||
extensionFileSets.addElement(extensionSet); | |||||
} | } | ||||
public void execute() | |||||
throws BuildException | |||||
{ | |||||
/** | |||||
* Execute the task. | |||||
* | |||||
* @throws BuildException if somethign goes wrong. | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
validate(); | validate(); | ||||
final Extension test = m_extension.toExtension(); | |||||
final Extension test = requiredExtension.toExtension(); | |||||
// Check if list of files to check has been specified | // Check if list of files to check has been specified | ||||
if( !m_extensionSets.isEmpty() ) | |||||
{ | |||||
final Iterator iterator = m_extensionSets.iterator(); | |||||
while( iterator.hasNext() ) | |||||
{ | |||||
final ExtensionSet extensionSet = (ExtensionSet)iterator.next(); | |||||
if (!extensionFileSets.isEmpty()) { | |||||
final Iterator iterator = extensionFileSets.iterator(); | |||||
while (iterator.hasNext()) { | |||||
final ExtensionSet extensionSet | |||||
= (ExtensionSet) iterator.next(); | |||||
final Extension[] extensions = | final Extension[] extensions = | ||||
extensionSet.toExtensions( getProject() ); | |||||
for( int i = 0; i < extensions.length; i++ ) | |||||
{ | |||||
extensionSet.toExtensions(getProject()); | |||||
for (int i = 0; i < extensions.length; i++) { | |||||
final Extension extension = extensions[ i ]; | final Extension extension = extensions[ i ]; | ||||
if( extension.isCompatibleWith( test ) ) | |||||
{ | |||||
getProject().setNewProperty( m_property, "true" ); | |||||
if (extension.isCompatibleWith(test)) { | |||||
getProject().setNewProperty(propertyName, "true"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
else | |||||
{ | |||||
final Manifest manifest = ExtensionUtil.getManifest( m_file ); | |||||
final Extension[] extensions = Extension.getAvailable( manifest ); | |||||
for( int i = 0; i < extensions.length; i++ ) | |||||
{ | |||||
} else { | |||||
final Manifest manifest = ExtensionUtil.getManifest(libraryFile); | |||||
final Extension[] extensions = Extension.getAvailable(manifest); | |||||
for (int i = 0; i < extensions.length; i++) { | |||||
final Extension extension = extensions[ i ]; | final Extension extension = extensions[ i ]; | ||||
if( extension.isCompatibleWith( test ) ) | |||||
{ | |||||
getProject().setNewProperty( m_property, "true" ); | |||||
if (extension.isCompatibleWith(test)) { | |||||
getProject().setNewProperty(propertyName, "true"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -182,29 +171,23 @@ public class JarLibAvailableTask | |||||
* | * | ||||
* @throws BuildException if invalid parameters found | * @throws BuildException if invalid parameters found | ||||
*/ | */ | ||||
private void validate() | |||||
throws BuildException | |||||
{ | |||||
if( null == m_extension ) | |||||
{ | |||||
private void validate() throws BuildException { | |||||
if (null == requiredExtension) { | |||||
final String message = "Extension element must be specified."; | final String message = "Extension element must be specified."; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( null == m_file && m_extensionSets.isEmpty() ) | |||||
{ | |||||
if (null == libraryFile && extensionFileSets.isEmpty()) { | |||||
final String message = "File attribute not specified."; | final String message = "File attribute not specified."; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( null != m_file && !m_file.exists() ) | |||||
{ | |||||
final String message = "File '" + m_file + "' does not exist."; | |||||
throw new BuildException( message ); | |||||
if (null != libraryFile && !libraryFile.exists()) { | |||||
final String message = "File '" + libraryFile + "' does not exist."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( null != m_file && !m_file.isFile() ) | |||||
{ | |||||
final String message = "\'" + m_file + "\' is not a file."; | |||||
throw new BuildException( message ); | |||||
if (null != libraryFile && !libraryFile.isFile()) { | |||||
final String message = "\'" + libraryFile + "\' is not a file."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -75,28 +75,25 @@ import org.apache.tools.ant.types.FileSet; | |||||
* @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
* @ant.task name="jarlib-display" | * @ant.task name="jarlib-display" | ||||
*/ | */ | ||||
public class JarLibDisplayTask | |||||
extends Task | |||||
{ | |||||
public class JarLibDisplayTask extends Task { | |||||
/** | /** | ||||
* The library to display information about. | * The library to display information about. | ||||
*/ | */ | ||||
private File m_file; | |||||
private File libraryFile; | |||||
/** | /** | ||||
* Filesets specifying all the librarys | * Filesets specifying all the librarys | ||||
* to display information about. | * to display information about. | ||||
*/ | */ | ||||
private final Vector m_filesets = new Vector(); | |||||
private final Vector libraryFileSets = new Vector(); | |||||
/** | /** | ||||
* The JAR library to display information for. | * The JAR library to display information for. | ||||
* | * | ||||
* @param file The jar library to display information for. | * @param file The jar library to display information for. | ||||
*/ | */ | ||||
public void setFile( final File file ) | |||||
{ | |||||
m_file = file; | |||||
public void setFile(final File file) { | |||||
this.libraryFile = file; | |||||
} | } | ||||
/** | /** | ||||
@@ -104,37 +101,35 @@ public class JarLibDisplayTask | |||||
* | * | ||||
* @param fileSet a set of files about which library data will be displayed. | * @param fileSet a set of files about which library data will be displayed. | ||||
*/ | */ | ||||
public void addFileset( final FileSet fileSet ) | |||||
{ | |||||
m_filesets.addElement( fileSet ); | |||||
public void addFileset(final FileSet fileSet) { | |||||
libraryFileSets.addElement(fileSet); | |||||
} | } | ||||
public void execute() | |||||
throws BuildException | |||||
{ | |||||
/** | |||||
* Execute the task. | |||||
* | |||||
* @throws BuildException if the task fails. | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
validate(); | validate(); | ||||
final LibraryDisplayer displayer = new LibraryDisplayer(); | final LibraryDisplayer displayer = new LibraryDisplayer(); | ||||
// Check if list of files to check has been specified | // Check if list of files to check has been specified | ||||
if( !m_filesets.isEmpty() ) | |||||
{ | |||||
final Iterator iterator = m_filesets.iterator(); | |||||
while( iterator.hasNext() ) | |||||
{ | |||||
final FileSet fileSet = (FileSet)iterator.next(); | |||||
final DirectoryScanner scanner = fileSet.getDirectoryScanner( getProject() ); | |||||
if (!libraryFileSets.isEmpty()) { | |||||
final Iterator iterator = libraryFileSets.iterator(); | |||||
while (iterator.hasNext()) { | |||||
final FileSet fileSet = (FileSet) iterator.next(); | |||||
final DirectoryScanner scanner | |||||
= fileSet.getDirectoryScanner(getProject()); | |||||
final File basedir = scanner.getBasedir(); | final File basedir = scanner.getBasedir(); | ||||
final String[] files = scanner.getIncludedFiles(); | final String[] files = scanner.getIncludedFiles(); | ||||
for( int i = 0; i < files.length; i++ ) | |||||
{ | |||||
final File file = new File( basedir, files[ i ] ); | |||||
displayer.displayLibrary( file ); | |||||
for (int i = 0; i < files.length; i++) { | |||||
final File file = new File(basedir, files[ i ]); | |||||
displayer.displayLibrary(file); | |||||
} | } | ||||
} | } | ||||
} | |||||
else | |||||
{ | |||||
displayer.displayLibrary( m_file ); | |||||
} else { | |||||
displayer.displayLibrary(libraryFile); | |||||
} | } | ||||
} | } | ||||
@@ -143,23 +138,18 @@ public class JarLibDisplayTask | |||||
* | * | ||||
* @throws BuildException if invalid parameters found | * @throws BuildException if invalid parameters found | ||||
*/ | */ | ||||
private void validate() | |||||
throws BuildException | |||||
{ | |||||
if( null == m_file && m_filesets.isEmpty() ) | |||||
{ | |||||
private void validate() throws BuildException { | |||||
if (null == libraryFile && libraryFileSets.isEmpty()) { | |||||
final String message = "File attribute not specified."; | final String message = "File attribute not specified."; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( null != m_file && !m_file.exists() ) | |||||
{ | |||||
final String message = "File '" + m_file + "' does not exist."; | |||||
throw new BuildException( message ); | |||||
if (null != libraryFile && !libraryFile.exists()) { | |||||
final String message = "File '" + libraryFile + "' does not exist."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( null != m_file && !m_file.isFile() ) | |||||
{ | |||||
final String message = "\'" + m_file + "\' is not a file."; | |||||
throw new BuildException( message ); | |||||
if (null != libraryFile && !libraryFile.isFile()) { | |||||
final String message = "\'" + libraryFile + "\' is not a file."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -80,9 +80,7 @@ import org.apache.tools.ant.Task; | |||||
* @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
* @ant.task name="jarlib-manifest" | * @ant.task name="jarlib-manifest" | ||||
*/ | */ | ||||
public final class JarLibManifestTask | |||||
extends Task | |||||
{ | |||||
public final class JarLibManifestTask extends Task { | |||||
/** | /** | ||||
* Version of manifest spec that task generates. | * Version of manifest spec that task generates. | ||||
*/ | */ | ||||
@@ -96,58 +94,56 @@ public final class JarLibManifestTask | |||||
/** | /** | ||||
* The library to display information about. | * The library to display information about. | ||||
*/ | */ | ||||
private File m_destfile; | |||||
private File destFile; | |||||
/** | /** | ||||
* The extension supported by this library (if any). | * The extension supported by this library (if any). | ||||
*/ | */ | ||||
private Extension m_extension; | |||||
private Extension extension; | |||||
/** | /** | ||||
* ExtensionAdapter objects representing | * ExtensionAdapter objects representing | ||||
* dependencies required by library. | * dependencies required by library. | ||||
*/ | */ | ||||
private final ArrayList m_dependencies = new ArrayList(); | |||||
private final ArrayList dependencies = new ArrayList(); | |||||
/** | /** | ||||
* ExtensionAdapter objects representing optional | * ExtensionAdapter objects representing optional | ||||
* dependencies required by library. | * dependencies required by library. | ||||
*/ | */ | ||||
private final ArrayList m_optionals = new ArrayList(); | |||||
private final ArrayList optionals = new ArrayList(); | |||||
/** | /** | ||||
* Extra attributes the user specifies for main section | * Extra attributes the user specifies for main section | ||||
* in manifest. | * in manifest. | ||||
*/ | */ | ||||
private final ArrayList m_extraAttributes = new ArrayList(); | |||||
private final ArrayList extraAttributes = new ArrayList(); | |||||
/** | /** | ||||
* The location where generated manifest is placed. | * The location where generated manifest is placed. | ||||
* | * | ||||
* @param destfile The location where generated manifest is placed. | |||||
* @param destFile The location where generated manifest is placed. | |||||
*/ | */ | ||||
public void setDestfile( final File destfile ) | |||||
{ | |||||
m_destfile = destfile; | |||||
public void setDestfile(final File destFile) { | |||||
this.destFile = destFile; | |||||
} | } | ||||
/** | /** | ||||
* Adds an extension that this library implements. | * Adds an extension that this library implements. | ||||
* | * | ||||
* @param extensionAdapter an extension that this library implements. | * @param extensionAdapter an extension that this library implements. | ||||
* | |||||
* @throws BuildException if there is multiple extensions detected | |||||
* in the library. | |||||
*/ | */ | ||||
public void addConfiguredExtension( final ExtensionAdapter extensionAdapter ) | |||||
throws BuildException | |||||
{ | |||||
if( null != m_extension ) | |||||
{ | |||||
public void addConfiguredExtension(final ExtensionAdapter extensionAdapter) | |||||
throws BuildException { | |||||
if (null != extension) { | |||||
final String message = | final String message = | ||||
"Can not have multiple extensions defined in one library."; | "Can not have multiple extensions defined in one library."; | ||||
throw new BuildException( message ); | |||||
} | |||||
else | |||||
{ | |||||
m_extension = extensionAdapter.toExtension(); | |||||
throw new BuildException(message); | |||||
} else { | |||||
extension = extensionAdapter.toExtension(); | |||||
} | } | ||||
} | } | ||||
@@ -156,9 +152,8 @@ public final class JarLibManifestTask | |||||
* | * | ||||
* @param extensionSet a set of extensions that this library requires. | * @param extensionSet a set of extensions that this library requires. | ||||
*/ | */ | ||||
public void addConfiguredDepends( final ExtensionSet extensionSet ) | |||||
{ | |||||
m_dependencies.add( extensionSet ); | |||||
public void addConfiguredDepends(final ExtensionSet extensionSet) { | |||||
dependencies.add(extensionSet); | |||||
} | } | ||||
/** | /** | ||||
@@ -166,9 +161,8 @@ public final class JarLibManifestTask | |||||
* | * | ||||
* @param extensionSet a set of extensions that this library optionally requires. | * @param extensionSet a set of extensions that this library optionally requires. | ||||
*/ | */ | ||||
public void addConfiguredOptions( final ExtensionSet extensionSet ) | |||||
{ | |||||
m_optionals.add( extensionSet ); | |||||
public void addConfiguredOptions(final ExtensionSet extensionSet) { | |||||
optionals.add(extensionSet); | |||||
} | } | ||||
/** | /** | ||||
@@ -176,56 +170,54 @@ public final class JarLibManifestTask | |||||
* | * | ||||
* @param attribute an attribute that is to be put in main section of manifest. | * @param attribute an attribute that is to be put in main section of manifest. | ||||
*/ | */ | ||||
public void addConfiguredAttribute( final ExtraAttribute attribute ) | |||||
{ | |||||
m_extraAttributes.add( attribute ); | |||||
public void addConfiguredAttribute(final ExtraAttribute attribute) { | |||||
extraAttributes.add(attribute); | |||||
} | } | ||||
public void execute() | |||||
throws BuildException | |||||
{ | |||||
/** | |||||
* Execute the task. | |||||
* | |||||
* @throws BuildException if the task fails. | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
validate(); | validate(); | ||||
final Manifest manifest = new Manifest(); | final Manifest manifest = new Manifest(); | ||||
final Attributes attributes = manifest.getMainAttributes(); | final Attributes attributes = manifest.getMainAttributes(); | ||||
attributes.put( Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION ); | |||||
final String createdBy = "Apache Ant " + getProject().getProperty( "ant.version" ); | |||||
attributes.putValue( CREATED_BY, createdBy ); | |||||
attributes.put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION); | |||||
final String createdBy = "Apache Ant " + getProject().getProperty("ant.version"); | |||||
attributes.putValue(CREATED_BY, createdBy); | |||||
appendExtraAttributes( attributes ); | |||||
appendExtraAttributes(attributes); | |||||
if( null != m_extension ) | |||||
{ | |||||
Extension.addExtension( m_extension, attributes ); | |||||
if (null != extension) { | |||||
Extension.addExtension(extension, attributes); | |||||
} | } | ||||
//Add all the dependency data to manifest for dependencies | //Add all the dependency data to manifest for dependencies | ||||
final ArrayList depends = toExtensions( m_dependencies ); | |||||
appendExtensionList( attributes, | |||||
final ArrayList depends = toExtensions(dependencies); | |||||
appendExtensionList(attributes, | |||||
Extension.EXTENSION_LIST, | Extension.EXTENSION_LIST, | ||||
"lib", | "lib", | ||||
depends.size() ); | |||||
appendLibraryList( attributes, "lib", depends ); | |||||
depends.size()); | |||||
appendLibraryList(attributes, "lib", depends); | |||||
//Add all the dependency data to manifest for "optional" | //Add all the dependency data to manifest for "optional" | ||||
//dependencies | //dependencies | ||||
final ArrayList option = toExtensions( m_optionals ); | |||||
appendExtensionList( attributes, | |||||
final ArrayList option = toExtensions(optionals); | |||||
appendExtensionList(attributes, | |||||
Extension.OPTIONAL_EXTENSION_LIST, | Extension.OPTIONAL_EXTENSION_LIST, | ||||
"opt", | "opt", | ||||
option.size() ); | |||||
appendLibraryList( attributes, "opt", option ); | |||||
option.size()); | |||||
appendLibraryList(attributes, "opt", option); | |||||
try | |||||
{ | |||||
final String message = "Generating manifest " + m_destfile.getAbsoluteFile(); | |||||
log( message, Project.MSG_INFO ); | |||||
writeManifest( manifest ); | |||||
} | |||||
catch( final IOException ioe ) | |||||
{ | |||||
throw new BuildException( ioe.getMessage(), ioe ); | |||||
try { | |||||
final String message = "Generating manifest " + destFile.getAbsoluteFile(); | |||||
log(message, Project.MSG_INFO); | |||||
writeManifest(manifest); | |||||
} catch (final IOException ioe) { | |||||
throw new BuildException(ioe.getMessage(), ioe); | |||||
} | } | ||||
} | } | ||||
@@ -234,18 +226,14 @@ public final class JarLibManifestTask | |||||
* | * | ||||
* @throws BuildException if invalid parameters found | * @throws BuildException if invalid parameters found | ||||
*/ | */ | ||||
private void validate() | |||||
throws BuildException | |||||
{ | |||||
if( null == m_destfile ) | |||||
{ | |||||
private void validate() throws BuildException { | |||||
if (null == destFile) { | |||||
final String message = "Destfile attribute not specified."; | final String message = "Destfile attribute not specified."; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( m_destfile.exists() && !m_destfile.isFile() ) | |||||
{ | |||||
final String message = m_destfile + " is not a file."; | |||||
throw new BuildException( message ); | |||||
if (destFile.exists() && !destFile.isFile()) { | |||||
final String message = destFile + " is not a file."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
} | } | ||||
@@ -255,15 +243,13 @@ public final class JarLibManifestTask | |||||
* @param attributes the manifest section to write | * @param attributes the manifest section to write | ||||
* attributes to | * attributes to | ||||
*/ | */ | ||||
private void appendExtraAttributes( final Attributes attributes ) | |||||
{ | |||||
final Iterator iterator = m_extraAttributes.iterator(); | |||||
while( iterator.hasNext() ) | |||||
{ | |||||
private void appendExtraAttributes(final Attributes attributes) { | |||||
final Iterator iterator = extraAttributes.iterator(); | |||||
while (iterator.hasNext()) { | |||||
final ExtraAttribute attribute = | final ExtraAttribute attribute = | ||||
(ExtraAttribute)iterator.next(); | |||||
attributes.putValue( attribute.getName(), | |||||
attribute.getValue() ); | |||||
(ExtraAttribute) iterator.next(); | |||||
attributes.putValue(attribute.getName(), | |||||
attribute.getValue()); | |||||
} | } | ||||
} | } | ||||
@@ -273,26 +259,19 @@ public final class JarLibManifestTask | |||||
* @param manifest the manifest | * @param manifest the manifest | ||||
* @throws IOException if error writing file | * @throws IOException if error writing file | ||||
*/ | */ | ||||
private void writeManifest( final Manifest manifest ) | |||||
throws IOException | |||||
{ | |||||
private void writeManifest(final Manifest manifest) | |||||
throws IOException { | |||||
FileOutputStream output = null; | FileOutputStream output = null; | ||||
try | |||||
{ | |||||
output = new FileOutputStream( m_destfile ); | |||||
manifest.write( output ); | |||||
try { | |||||
output = new FileOutputStream(destFile); | |||||
manifest.write(output); | |||||
output.flush(); | output.flush(); | ||||
} | |||||
finally | |||||
{ | |||||
if( null != output ) | |||||
{ | |||||
try | |||||
{ | |||||
} finally { | |||||
if (null != output) { | |||||
try { | |||||
output.close(); | output.close(); | ||||
} | |||||
catch( IOException e ) | |||||
{ | |||||
} catch (IOException e) { | |||||
// ignore | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -309,17 +288,15 @@ public final class JarLibManifestTask | |||||
* @param extensions the list of extensions | * @param extensions the list of extensions | ||||
* @throws BuildException if an error occurs | * @throws BuildException if an error occurs | ||||
*/ | */ | ||||
private void appendLibraryList( final Attributes attributes, | |||||
private void appendLibraryList(final Attributes attributes, | |||||
final String listPrefix, | final String listPrefix, | ||||
final ArrayList extensions ) | |||||
throws BuildException | |||||
{ | |||||
final ArrayList extensions) | |||||
throws BuildException { | |||||
final int size = extensions.size(); | final int size = extensions.size(); | ||||
for( int i = 0; i < size; i++ ) | |||||
{ | |||||
final Extension extension = (Extension)extensions.get( i ); | |||||
for (int i = 0; i < size; i++) { | |||||
final Extension extension = (Extension) extensions.get(i); | |||||
final String prefix = listPrefix + i + "-"; | final String prefix = listPrefix + i + "-"; | ||||
Extension.addExtension( extension, prefix, attributes ); | |||||
Extension.addExtension(extension, prefix, attributes); | |||||
} | } | ||||
} | } | ||||
@@ -334,21 +311,19 @@ public final class JarLibManifestTask | |||||
* @param attributes the attributes to add key-value to | * @param attributes the attributes to add key-value to | ||||
* @param extensionKey the key to use | * @param extensionKey the key to use | ||||
*/ | */ | ||||
private void appendExtensionList( final Attributes attributes, | |||||
private void appendExtensionList(final Attributes attributes, | |||||
final Attributes.Name extensionKey, | final Attributes.Name extensionKey, | ||||
final String listPrefix, | final String listPrefix, | ||||
final int size ) | |||||
{ | |||||
final int size) { | |||||
final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
for( int i = 0; i < size; i++ ) | |||||
{ | |||||
sb.append( listPrefix + i ); | |||||
sb.append( ' ' ); | |||||
for (int i = 0; i < size; i++) { | |||||
sb.append(listPrefix + i); | |||||
sb.append(' '); | |||||
} | } | ||||
//add in something like | //add in something like | ||||
//"Extension-List: javahelp java3d" | //"Extension-List: javahelp java3d" | ||||
attributes.put( extensionKey, sb.toString() ); | |||||
attributes.put(extensionKey, sb.toString()); | |||||
} | } | ||||
/** | /** | ||||
@@ -357,19 +332,16 @@ public final class JarLibManifestTask | |||||
* @param extensionSets the list of ExtensionSets to add to list | * @param extensionSets the list of ExtensionSets to add to list | ||||
* @throws BuildException if an error occurs | * @throws BuildException if an error occurs | ||||
*/ | */ | ||||
private ArrayList toExtensions( final ArrayList extensionSets ) | |||||
throws BuildException | |||||
{ | |||||
private ArrayList toExtensions(final ArrayList extensionSets) | |||||
throws BuildException { | |||||
final ArrayList results = new ArrayList(); | final ArrayList results = new ArrayList(); | ||||
final int size = extensionSets.size(); | final int size = extensionSets.size(); | ||||
for( int i = 0; i < size; i++ ) | |||||
{ | |||||
final ExtensionSet set = (ExtensionSet)extensionSets.get( i ); | |||||
final Extension[] extensions = set.toExtensions( getProject() ); | |||||
for( int j = 0; j < extensions.length; j++ ) | |||||
{ | |||||
results.add( extensions[ j ] ); | |||||
for (int i = 0; i < size; i++) { | |||||
final ExtensionSet set = (ExtensionSet) extensionSets.get(i); | |||||
final Extension[] extensions = set.toExtensions(getProject()); | |||||
for (int j = 0; j < extensions.length; j++) { | |||||
results.add(extensions[ j ]); | |||||
} | } | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -71,24 +71,22 @@ import org.apache.tools.ant.taskdefs.optional.extension.resolvers.URLResolver; | |||||
* @author <a href="mailto:jeff@socialchange.net.au">Jeff Turner</a> | * @author <a href="mailto:jeff@socialchange.net.au">Jeff Turner</a> | ||||
* @ant.task name="jarlib-resolve" | * @ant.task name="jarlib-resolve" | ||||
*/ | */ | ||||
public class JarLibResolveTask | |||||
extends Task | |||||
{ | |||||
public class JarLibResolveTask extends Task { | |||||
/** | /** | ||||
* The name of the property in which the location of | * The name of the property in which the location of | ||||
* library is stored. | * library is stored. | ||||
*/ | */ | ||||
private String m_property; | |||||
private String propertyName; | |||||
/** | /** | ||||
* The extension that is required. | * The extension that is required. | ||||
*/ | */ | ||||
private Extension m_extension; | |||||
private Extension requiredExtension; | |||||
/** | /** | ||||
* The set of resolvers to use to attempt to locate library. | * The set of resolvers to use to attempt to locate library. | ||||
*/ | */ | ||||
private final ArrayList m_resolvers = new ArrayList(); | |||||
private final ArrayList resolvers = new ArrayList(); | |||||
/** | /** | ||||
* Flag to indicate that you should check that | * Flag to indicate that you should check that | ||||
@@ -96,14 +94,14 @@ public class JarLibResolveTask | |||||
* extension and if they don't then raise | * extension and if they don't then raise | ||||
* an exception. | * an exception. | ||||
*/ | */ | ||||
private boolean m_checkExtension = true; | |||||
private boolean checkExtension = true; | |||||
/** | /** | ||||
* Flag indicating whether or not you should | * Flag indicating whether or not you should | ||||
* throw a BuildException if you cannot resolve | * throw a BuildException if you cannot resolve | ||||
* library. | * library. | ||||
*/ | */ | ||||
private boolean m_failOnError = true; | |||||
private boolean failOnError = true; | |||||
/** | /** | ||||
* The name of the property in which the location of | * The name of the property in which the location of | ||||
@@ -112,52 +110,56 @@ public class JarLibResolveTask | |||||
* @param property The name of the property in which the location of | * @param property The name of the property in which the location of | ||||
* library is stored. | * library is stored. | ||||
*/ | */ | ||||
public void setProperty( final String property ) | |||||
{ | |||||
m_property = property; | |||||
public void setProperty(final String property) { | |||||
this.propertyName = property; | |||||
} | } | ||||
/** | /** | ||||
* If true, libraries returned by nested resolvers should be | |||||
* checked to see if they supply extension. | |||||
* Check nested libraries for extensions | |||||
* | |||||
* @param checkExtension if true, libraries returned by nested | |||||
* resolvers should be checked to see if they supply extension. | |||||
*/ | */ | ||||
public void setCheckExtension( final boolean checkExtension ) | |||||
{ | |||||
m_checkExtension = checkExtension; | |||||
public void setCheckExtension(final boolean checkExtension) { | |||||
this.checkExtension = checkExtension; | |||||
} | } | ||||
/** | /** | ||||
* If true, failure to locate library should fail build. | |||||
* Set whether to fail if error. | |||||
* | |||||
* @param failOnError if true, failure to locate library should fail build. | |||||
*/ | */ | ||||
public void setFailOnError( final boolean failOnError ) | |||||
{ | |||||
m_failOnError = failOnError; | |||||
public void setFailOnError(final boolean failOnError) { | |||||
this.failOnError = failOnError; | |||||
} | } | ||||
/** | /** | ||||
* Adds location resolver to look for a library in a location | * Adds location resolver to look for a library in a location | ||||
* relative to project directory. | * relative to project directory. | ||||
* | |||||
* @param location the resolver location to search. | |||||
*/ | */ | ||||
public void addConfiguredLocation( final LocationResolver location ) | |||||
{ | |||||
m_resolvers.add( location ); | |||||
public void addConfiguredLocation(final LocationResolver location) { | |||||
resolvers.add(location); | |||||
} | } | ||||
/** | /** | ||||
* Adds a URL resolver to download a library from a URL | * Adds a URL resolver to download a library from a URL | ||||
* to a local file. | * to a local file. | ||||
* | |||||
* @param url the URL resolver from which to download the library | |||||
*/ | */ | ||||
public void addConfiguredUrl( final URLResolver url ) | |||||
{ | |||||
m_resolvers.add( url ); | |||||
public void addConfiguredUrl(final URLResolver url) { | |||||
resolvers.add(url); | |||||
} | } | ||||
/** | /** | ||||
* Adds Ant resolver to run an Ant build file to generate a library. | * Adds Ant resolver to run an Ant build file to generate a library. | ||||
* | |||||
* @param ant the AntResolver to generate the library. | |||||
*/ | */ | ||||
public void addConfiguredAnt( final AntResolver ant ) | |||||
{ | |||||
m_resolvers.add( ant ); | |||||
public void addConfiguredAnt(final AntResolver ant) { | |||||
resolvers.add(ant); | |||||
} | } | ||||
/** | /** | ||||
@@ -165,74 +167,63 @@ public class JarLibResolveTask | |||||
* | * | ||||
* @param extension Set the Extension looking for. | * @param extension Set the Extension looking for. | ||||
*/ | */ | ||||
public void addConfiguredExtension( final ExtensionAdapter extension ) | |||||
{ | |||||
if( null != m_extension ) | |||||
{ | |||||
final String message = "Can not specify extension to " + | |||||
"resolve multiple times."; | |||||
throw new BuildException( message ); | |||||
public void addConfiguredExtension(final ExtensionAdapter extension) { | |||||
if (null != requiredExtension) { | |||||
final String message = "Can not specify extension to " | |||||
+ "resolve multiple times."; | |||||
throw new BuildException(message); | |||||
} | } | ||||
m_extension = extension.toExtension(); | |||||
requiredExtension = extension.toExtension(); | |||||
} | } | ||||
public void execute() | |||||
throws BuildException | |||||
{ | |||||
/** | |||||
* Execute the task. | |||||
* | |||||
* @throws BuildException if the task fails. | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
validate(); | validate(); | ||||
getProject().log( "Resolving extension: " + m_extension, | |||||
Project.MSG_VERBOSE ); | |||||
getProject().log("Resolving extension: " + requiredExtension, | |||||
Project.MSG_VERBOSE); | |||||
String candidate = | String candidate = | ||||
getProject().getProperty( m_property ); | |||||
getProject().getProperty(propertyName); | |||||
if( null != candidate ) | |||||
{ | |||||
if (null != candidate) { | |||||
final String message = "Property Already set to: " + candidate; | final String message = "Property Already set to: " + candidate; | ||||
if( m_failOnError ) | |||||
{ | |||||
throw new BuildException( message ); | |||||
} | |||||
else | |||||
{ | |||||
getProject().log( message, Project.MSG_ERR ); | |||||
if (failOnError) { | |||||
throw new BuildException(message); | |||||
} else { | |||||
getProject().log(message, Project.MSG_ERR); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
final int size = m_resolvers.size(); | |||||
for( int i = 0; i < size; i++ ) | |||||
{ | |||||
final int size = resolvers.size(); | |||||
for (int i = 0; i < size; i++) { | |||||
final ExtensionResolver resolver = | final ExtensionResolver resolver = | ||||
(ExtensionResolver)m_resolvers.get( i ); | |||||
(ExtensionResolver) resolvers.get(i); | |||||
getProject().log( "Searching for extension using Resolver:" + resolver, | |||||
Project.MSG_VERBOSE ); | |||||
getProject().log("Searching for extension using Resolver:" + resolver, | |||||
Project.MSG_VERBOSE); | |||||
try | |||||
{ | |||||
try { | |||||
final File file = | final File file = | ||||
resolver.resolve( m_extension, getProject() ); | |||||
try | |||||
{ | |||||
checkExtension( file ); | |||||
resolver.resolve(requiredExtension, getProject()); | |||||
try { | |||||
checkExtension(file); | |||||
return; | return; | ||||
} catch (final BuildException be) { | |||||
final String message = "File " + file + " returned by " | |||||
+ "resolver failed to satisfy extension due to: " | |||||
+ be.getMessage(); | |||||
getProject().log(message, Project.MSG_WARN); | |||||
} | } | ||||
catch( final BuildException be ) | |||||
{ | |||||
final String message = | |||||
"File " + file + " returned by resolver failed " + | |||||
"to satisfy extension due to: " + be.getMessage(); | |||||
getProject().log( message, Project.MSG_WARN ); | |||||
} | |||||
} | |||||
catch( final BuildException be ) | |||||
{ | |||||
final String message = | |||||
"Failed to resolve extension to file " + | |||||
"using resolver " + resolver + " due to: " + be; | |||||
getProject().log( message, Project.MSG_WARN ); | |||||
} catch (final BuildException be) { | |||||
final String message = "Failed to resolve extension to file " | |||||
+ "using resolver " + resolver + " due to: " + be; | |||||
getProject().log(message, Project.MSG_WARN); | |||||
} | } | ||||
} | } | ||||
@@ -241,20 +232,16 @@ public class JarLibResolveTask | |||||
/** | /** | ||||
* Utility method that will throw a {@link BuildException} | * Utility method that will throw a {@link BuildException} | ||||
* if {@link #m_failOnError} is true else it just displays | |||||
* if {@link #failOnError} is true else it just displays | |||||
* a warning. | * a warning. | ||||
*/ | */ | ||||
private void missingExtension() | |||||
{ | |||||
private void missingExtension() { | |||||
final String message = | final String message = | ||||
"Unable to resolve extension to a file"; | "Unable to resolve extension to a file"; | ||||
if( m_failOnError ) | |||||
{ | |||||
throw new BuildException( message ); | |||||
} | |||||
else | |||||
{ | |||||
getProject().log( message, Project.MSG_ERR ); | |||||
if (failOnError) { | |||||
throw new BuildException(message); | |||||
} else { | |||||
getProject().log(message, Project.MSG_ERR); | |||||
} | } | ||||
} | } | ||||
@@ -266,54 +253,44 @@ public class JarLibResolveTask | |||||
* @param file the candidate library | * @param file the candidate library | ||||
* @throws BuildException if library does not satisfy extension | * @throws BuildException if library does not satisfy extension | ||||
*/ | */ | ||||
private void checkExtension( final File file ) | |||||
{ | |||||
if( !file.exists() ) | |||||
{ | |||||
private void checkExtension(final File file) { | |||||
if (!file.exists()) { | |||||
final String message = | final String message = | ||||
"File " + file + " does not exist"; | "File " + file + " does not exist"; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( !file.isFile() ) | |||||
{ | |||||
if (!file.isFile()) { | |||||
final String message = | final String message = | ||||
"File " + file + " is not a file"; | "File " + file + " is not a file"; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( !m_checkExtension ) | |||||
{ | |||||
final String message = "Setting property to " + | |||||
file + " without verifying library satisfies extension"; | |||||
getProject().log( message, Project.MSG_VERBOSE ); | |||||
setLibraryProperty( file ); | |||||
} | |||||
else | |||||
{ | |||||
getProject().log( "Checking file " + file + | |||||
" to see if it satisfies extension", | |||||
Project.MSG_VERBOSE ); | |||||
if (!checkExtension) { | |||||
final String message = "Setting property to " + file | |||||
+ " without verifying library satisfies extension"; | |||||
getProject().log(message, Project.MSG_VERBOSE); | |||||
setLibraryProperty(file); | |||||
} else { | |||||
getProject().log("Checking file " + file | |||||
+ " to see if it satisfies extension", Project.MSG_VERBOSE); | |||||
final Manifest manifest = | final Manifest manifest = | ||||
ExtensionUtil.getManifest( file ); | |||||
ExtensionUtil.getManifest(file); | |||||
final Extension[] extensions = | final Extension[] extensions = | ||||
Extension.getAvailable( manifest ); | |||||
for( int i = 0; i < extensions.length; i++ ) | |||||
{ | |||||
Extension.getAvailable(manifest); | |||||
for (int i = 0; i < extensions.length; i++) { | |||||
final Extension extension = extensions[ i ]; | final Extension extension = extensions[ i ]; | ||||
if( extension.isCompatibleWith( m_extension ) ) | |||||
{ | |||||
setLibraryProperty( file ); | |||||
if (extension.isCompatibleWith(requiredExtension)) { | |||||
setLibraryProperty(file); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
getProject().log( "File " + file + " skipped as it " + | |||||
"does not satisfy extension", | |||||
Project.MSG_VERBOSE ); | |||||
getProject().log("File " + file + " skipped as it " | |||||
+ "does not satisfy extension", Project.MSG_VERBOSE); | |||||
final String message = | final String message = | ||||
"File " + file + " does not satisfy extension"; | "File " + file + " does not satisfy extension"; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
} | } | ||||
@@ -324,10 +301,9 @@ public class JarLibResolveTask | |||||
* | * | ||||
* @param file the library | * @param file the library | ||||
*/ | */ | ||||
private void setLibraryProperty( final File file ) | |||||
{ | |||||
getProject().setNewProperty( m_property, | |||||
file.getAbsolutePath() ); | |||||
private void setLibraryProperty(final File file) { | |||||
getProject().setNewProperty(propertyName, | |||||
file.getAbsolutePath()); | |||||
} | } | ||||
/** | /** | ||||
@@ -335,19 +311,15 @@ public class JarLibResolveTask | |||||
* | * | ||||
* @throws BuildException if invalid parameters found | * @throws BuildException if invalid parameters found | ||||
*/ | */ | ||||
private void validate() | |||||
throws BuildException | |||||
{ | |||||
if( null == m_property ) | |||||
{ | |||||
private void validate() throws BuildException { | |||||
if (null == propertyName) { | |||||
final String message = "Property attribute must be specified."; | final String message = "Property attribute must be specified."; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
if( null == m_extension ) | |||||
{ | |||||
if (null == requiredExtension) { | |||||
final String message = "Extension element must be specified."; | final String message = "Extension element must be specified."; | ||||
throw new BuildException( message ); | |||||
throw new BuildException(message); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -72,6 +72,11 @@ import org.apache.tools.ant.BuildException; | |||||
*/ | */ | ||||
public class P4Have extends P4Base { | public class P4Have extends P4Base { | ||||
/** | |||||
* Execute the Perforce <code>have</code> command. | |||||
* | |||||
* @throws BuildException if the command cannot be executed. | |||||
*/ | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
execP4Command("have " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this)); | execP4Command("have " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this)); | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -116,7 +116,7 @@ public class Chgrp extends AbstractAccessTask { | |||||
* @param e User supplied executable that we won't accept. | * @param e User supplied executable that we won't accept. | ||||
*/ | */ | ||||
public void setExecutable(String e) { | public void setExecutable(String e) { | ||||
throw new BuildException(taskType | |||||
throw new BuildException(taskType | |||||
+ " doesn\'t support the executable" | + " doesn\'t support the executable" | ||||
+ " attribute", getLocation()); | + " attribute", getLocation()); | ||||
} | } | ||||
@@ -138,7 +138,7 @@ public class MSVSSCHECKIN extends MSVSS { | |||||
* | * | ||||
* @param response The auto response value. | * @param response The auto response value. | ||||
*/ | */ | ||||
public void setAutoresponse(String response){ | |||||
public void setAutoresponse(String response) { | |||||
super.setInternalAutoResponse(response); | super.setInternalAutoResponse(response); | ||||
} | } | ||||
@@ -141,7 +141,7 @@ public class MSVSSLABEL extends MSVSS { | |||||
* | * | ||||
* @param response The auto response value. | * @param response The auto response value. | ||||
*/ | */ | ||||
public void setAutoresponse(String response){ | |||||
public void setAutoresponse(String response) { | |||||
super.setInternalAutoResponse(response); | super.setInternalAutoResponse(response); | ||||
} | } | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -59,5 +59,10 @@ package org.apache.tools.ant.types; | |||||
* @author Magesh Umasankar | * @author Magesh Umasankar | ||||
*/ | */ | ||||
public interface Parameterizable { | public interface Parameterizable { | ||||
/** | |||||
* Set the parameters | |||||
* | |||||
* @param parameters an array of name/type/value parameters. | |||||
*/ | |||||
void setParameters(Parameter[] parameters); | void setParameters(Parameter[] parameters); | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -84,7 +84,7 @@ public class ResourceLocation { | |||||
/** | /** | ||||
* name of the catalog entry type, as per OASIS spec. | * name of the catalog entry type, as per OASIS spec. | ||||
*/ | */ | ||||
protected String name = null; | |||||
private String name = null; | |||||
/** publicId of the dtd/entity. */ | /** publicId of the dtd/entity. */ | ||||
private String publicId = null; | private String publicId = null; | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -72,6 +72,9 @@ public class AndSelector extends BaseSelectorContainer { | |||||
public AndSelector() { | public AndSelector() { | ||||
} | } | ||||
/** | |||||
* @return a string representation of the selector | |||||
*/ | |||||
public String toString() { | public String toString() { | ||||
StringBuffer buf = new StringBuffer(); | StringBuffer buf = new StringBuffer(); | ||||
if (hasSelectors()) { | if (hasSelectors()) { | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -78,7 +78,7 @@ public interface FileSelector { | |||||
* @return whether the file should be selected or not | * @return whether the file should be selected or not | ||||
* @exception BuildException if the selector was not configured correctly | * @exception BuildException if the selector was not configured correctly | ||||
*/ | */ | ||||
public boolean isSelected(File basedir, String filename, File file) | |||||
boolean isSelected(File basedir, String filename, File file) | |||||
throws BuildException; | throws BuildException; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -73,6 +73,9 @@ public class NoneSelector extends BaseSelectorContainer { | |||||
public NoneSelector() { | public NoneSelector() { | ||||
} | } | ||||
/** | |||||
* @return a string representation of the selector | |||||
*/ | |||||
public String toString() { | public String toString() { | ||||
StringBuffer buf = new StringBuffer(); | StringBuffer buf = new StringBuffer(); | ||||
if (hasSelectors()) { | if (hasSelectors()) { | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -72,6 +72,9 @@ public class NotSelector extends NoneSelector { | |||||
public NotSelector() { | public NotSelector() { | ||||
} | } | ||||
/** | |||||
* @return a string representation of the selector | |||||
*/ | |||||
public String toString() { | public String toString() { | ||||
StringBuffer buf = new StringBuffer(); | StringBuffer buf = new StringBuffer(); | ||||
if (hasSelectors()) { | if (hasSelectors()) { | ||||
@@ -88,8 +91,8 @@ public class NotSelector extends NoneSelector { | |||||
*/ | */ | ||||
public void verifySettings() { | public void verifySettings() { | ||||
if (selectorCount() != 1) { | if (selectorCount() != 1) { | ||||
setError("One and only one selector is allowed within the " + | |||||
"<not> tag"); | |||||
setError("One and only one selector is allowed within the " | |||||
+ "<not> tag"); | |||||
} | } | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -72,6 +72,9 @@ public class OrSelector extends BaseSelectorContainer { | |||||
public OrSelector() { | public OrSelector() { | ||||
} | } | ||||
/** | |||||
* @return a string representation of the selector | |||||
*/ | |||||
public String toString() { | public String toString() { | ||||
StringBuffer buf = new StringBuffer(); | StringBuffer buf = new StringBuffer(); | ||||
if (hasSelectors()) { | if (hasSelectors()) { | ||||
@@ -165,9 +165,15 @@ public class FileUtils { | |||||
* Convienence method to copy a file from a source to a destination. | * Convienence method to copy a file from a source to a destination. | ||||
* No filtering is performed. | * No filtering is performed. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(String sourceFile, String destFile) throws IOException { | |||||
public void copyFile(String sourceFile, String destFile) | |||||
throws IOException { | |||||
copyFile(new File(sourceFile), new File(destFile), null, false, false); | copyFile(new File(sourceFile), new File(destFile), null, false, false); | ||||
} | } | ||||
@@ -175,11 +181,19 @@ public class FileUtils { | |||||
* Convienence method to copy a file from a source to a destination | * Convienence method to copy a file from a source to a destination | ||||
* specifying if token filtering must be used. | * specifying if token filtering must be used. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters) | |||||
public void copyFile(String sourceFile, String destFile, | |||||
FilterSetCollection filters) | |||||
throws IOException { | throws IOException { | ||||
copyFile(new File(sourceFile), new File(destFile), filters, false, false); | |||||
copyFile(new File(sourceFile), new File(destFile), filters, | |||||
false, false); | |||||
} | } | ||||
/** | /** | ||||
@@ -187,7 +201,15 @@ public class FileUtils { | |||||
* destination specifying if token filtering must be used and if | * destination specifying if token filtering must be used and if | ||||
* source files may overwrite newer destination files. | * source files may overwrite newer destination files. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, | public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, | ||||
boolean overwrite) throws IOException { | boolean overwrite) throws IOException { | ||||
@@ -202,7 +224,18 @@ public class FileUtils { | |||||
* last modified time of <code>destFile</code> file should be made equal | * last modified time of <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, | public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, | ||||
boolean overwrite, boolean preserveLastModified) | boolean overwrite, boolean preserveLastModified) | ||||
@@ -218,9 +251,21 @@ public class FileUtils { | |||||
* last modified time of <code>destFile</code> file should be made equal | * last modified time of <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* @param encoding the encoding used to read and write the files. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
* | * | ||||
* @since 1.14, Ant 1.5 | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public void copyFile(String sourceFile, String destFile, | public void copyFile(String sourceFile, String destFile, | ||||
FilterSetCollection filters, boolean overwrite, | FilterSetCollection filters, boolean overwrite, | ||||
@@ -238,9 +283,23 @@ public class FileUtils { | |||||
* <code>destFile</code> file should be made equal | * <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param filterChains filterChains to apply during the copy. | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* @param encoding the encoding used to read and write the files. | |||||
* @param project the project instance | |||||
* | |||||
* @throws IOException if the copying fails | |||||
* | * | ||||
* @since 1.15, Ant 1.5 | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public void copyFile(String sourceFile, String destFile, | public void copyFile(String sourceFile, String destFile, | ||||
FilterSetCollection filters, Vector filterChains, | FilterSetCollection filters, Vector filterChains, | ||||
@@ -260,7 +319,22 @@ public class FileUtils { | |||||
* <code>destFile</code> file should be made equal | * <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile Name of file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile Name of file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param filterChains filterChains to apply during the copy. | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* @param inputEncoding the encoding used to read the files. | |||||
* @param outputEncoding the encoding used to write the files. | |||||
* @param project the project instance | |||||
* | |||||
* @throws IOException if the copying fails | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
@@ -279,7 +353,12 @@ public class FileUtils { | |||||
* Convienence method to copy a file from a source to a destination. | * Convienence method to copy a file from a source to a destination. | ||||
* No filtering is performed. | * No filtering is performed. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile) throws IOException { | public void copyFile(File sourceFile, File destFile) throws IOException { | ||||
copyFile(sourceFile, destFile, null, false, false); | copyFile(sourceFile, destFile, null, false, false); | ||||
@@ -289,7 +368,13 @@ public class FileUtils { | |||||
* Convienence method to copy a file from a source to a destination | * Convienence method to copy a file from a source to a destination | ||||
* specifying if token filtering must be used. | * specifying if token filtering must be used. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters) | public void copyFile(File sourceFile, File destFile, FilterSetCollection filters) | ||||
throws IOException { | throws IOException { | ||||
@@ -301,7 +386,15 @@ public class FileUtils { | |||||
* destination specifying if token filtering must be used and if | * destination specifying if token filtering must be used and if | ||||
* source files may overwrite newer destination files. | * source files may overwrite newer destination files. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, | public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, | ||||
boolean overwrite) throws IOException { | boolean overwrite) throws IOException { | ||||
@@ -315,7 +408,18 @@ public class FileUtils { | |||||
* last modified time of <code>destFile</code> file should be made equal | * last modified time of <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, | public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, | ||||
boolean overwrite, boolean preserveLastModified) | boolean overwrite, boolean preserveLastModified) | ||||
@@ -332,9 +436,21 @@ public class FileUtils { | |||||
* equal to the last modified time of <code>sourceFile</code> and | * equal to the last modified time of <code>sourceFile</code> and | ||||
* which character encoding to assume. | * which character encoding to assume. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* @param encoding the encoding used to read and write the files. | |||||
* | |||||
* @throws IOException if the copying fails | |||||
* | * | ||||
* @since 1.14, Ant 1.5 | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile, | public void copyFile(File sourceFile, File destFile, | ||||
FilterSetCollection filters, boolean overwrite, | FilterSetCollection filters, boolean overwrite, | ||||
@@ -352,9 +468,23 @@ public class FileUtils { | |||||
* <code>destFile</code> file should be made equal | * <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param filterChains filterChains to apply during the copy. | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* @param encoding the encoding used to read and write the files. | |||||
* @param project the project instance | |||||
* | * | ||||
* @since 1.15, Ant 1.5 | |||||
* @throws IOException if the copying fails | |||||
* | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile, | public void copyFile(File sourceFile, File destFile, | ||||
FilterSetCollection filters, Vector filterChains, | FilterSetCollection filters, Vector filterChains, | ||||
@@ -373,9 +503,25 @@ public class FileUtils { | |||||
* <code>destFile</code> file should be made equal | * <code>destFile</code> file should be made equal | ||||
* to the last modified time of <code>sourceFile</code>. | * to the last modified time of <code>sourceFile</code>. | ||||
* | * | ||||
* @throws IOException | |||||
* @param sourceFile the file to copy from. | |||||
* Must not be <code>null</code>. | |||||
* @param destFile the file to copy to. | |||||
* Must not be <code>null</code>. | |||||
* @param filters the collection of filters to apply to this copy | |||||
* @param filterChains filterChains to apply during the copy. | |||||
* @param overwrite Whether or not the destination file should be | |||||
* overwritten if it already exists. | |||||
* @param preserveLastModified Whether or not the last modified time of | |||||
* the resulting file should be set to that | |||||
* of the source file. | |||||
* @param inputEncoding the encoding used to read the files. | |||||
* @param outputEncoding the encoding used to write the files. | |||||
* @param project the project instance | |||||
* | * | ||||
* @since 1.15, Ant 1.6 | |||||
* | |||||
* @throws IOException if the copying fails | |||||
* | |||||
* @since Ant 1.6 | |||||
*/ | */ | ||||
public void copyFile(File sourceFile, File destFile, | public void copyFile(File sourceFile, File destFile, | ||||
FilterSetCollection filters, Vector filterChains, | FilterSetCollection filters, Vector filterChains, | ||||
@@ -384,8 +530,8 @@ public class FileUtils { | |||||
Project project) | Project project) | ||||
throws IOException { | throws IOException { | ||||
if (overwrite || !destFile.exists() || | |||||
destFile.lastModified() < sourceFile.lastModified()) { | |||||
if (overwrite || !destFile.exists() | |||||
|| destFile.lastModified() < sourceFile.lastModified()) { | |||||
if (destFile.exists() && destFile.isFile()) { | if (destFile.exists() && destFile.isFile()) { | ||||
destFile.delete(); | destFile.delete(); | ||||
@@ -411,19 +557,19 @@ public class FileUtils { | |||||
if (inputEncoding == null) { | if (inputEncoding == null) { | ||||
in = new BufferedReader(new FileReader(sourceFile)); | in = new BufferedReader(new FileReader(sourceFile)); | ||||
} else { | } else { | ||||
in = | |||||
new BufferedReader(new InputStreamReader( | |||||
new FileInputStream(sourceFile), | |||||
inputEncoding)); | |||||
InputStreamReader isr | |||||
= new InputStreamReader(new FileInputStream(sourceFile), | |||||
inputEncoding); | |||||
in = new BufferedReader(isr); | |||||
} | } | ||||
if (outputEncoding == null) { | if (outputEncoding == null) { | ||||
out = new BufferedWriter(new FileWriter(destFile)); | out = new BufferedWriter(new FileWriter(destFile)); | ||||
} else { | } else { | ||||
out = | |||||
new BufferedWriter(new OutputStreamWriter( | |||||
new FileOutputStream(destFile), | |||||
outputEncoding)); | |||||
OutputStreamWriter osw | |||||
= new OutputStreamWriter(new FileOutputStream(destFile), | |||||
outputEncoding); | |||||
out = new BufferedWriter(osw); | |||||
} | } | ||||
if (filterChainsAvailable) { | if (filterChainsAvailable) { | ||||
@@ -442,7 +588,8 @@ public class FileUtils { | |||||
String line = lineTokenizer.getToken(in); | String line = lineTokenizer.getToken(in); | ||||
while (line != null) { | while (line != null) { | ||||
if (line.length() == 0) { | if (line.length() == 0) { | ||||
// this should not happen, because the lines are returned with the end of line delimiter | |||||
// this should not happen, because the lines are | |||||
// returned with the end of line delimiter | |||||
out.newLine(); | out.newLine(); | ||||
} else { | } else { | ||||
newline = filters.replaceTokens(line); | newline = filters.replaceTokens(line); | ||||
@@ -495,7 +642,7 @@ public class FileUtils { | |||||
Reader rdr = crh.getAssembledReader(); | Reader rdr = crh.getAssembledReader(); | ||||
in = new BufferedReader(rdr); | in = new BufferedReader(rdr); | ||||
} | } | ||||
char buffer[] = new char[1024*8]; | |||||
char[] buffer = new char[1024 * 8]; | |||||
while (true) { | while (true) { | ||||
int nRead = in.read(buffer, 0, buffer.length); | int nRead = in.read(buffer, 0, buffer.length); | ||||
if (nRead == -1) { | if (nRead == -1) { | ||||
@@ -542,6 +689,8 @@ public class FileUtils { | |||||
/** | /** | ||||
* see whether we have a setLastModified method in File and return it. | * see whether we have a setLastModified method in File and return it. | ||||
* | |||||
* @return a method to setLastModified. | |||||
*/ | */ | ||||
protected final Method getSetLastModified() { | protected final Method getSetLastModified() { | ||||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | ||||
@@ -564,8 +713,14 @@ public class FileUtils { | |||||
/** | /** | ||||
* Calls File.setLastModified(long time) in a Java 1.1 compatible way. | * Calls File.setLastModified(long time) in a Java 1.1 compatible way. | ||||
* | |||||
* @param file the file whose modified time is to be set | |||||
* @param time the time to which the last modified time is to be set. | |||||
* | |||||
* @throws BuildException if the time cannot be set. | |||||
*/ | */ | ||||
public void setFileLastModified(File file, long time) throws BuildException { | |||||
public void setFileLastModified(File file, long time) | |||||
throws BuildException { | |||||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | ||||
return; | return; | ||||
} | } | ||||
@@ -665,6 +820,9 @@ public class FileUtils { | |||||
* \ as the separator.</li> | * \ as the separator.</li> | ||||
* </ul> | * </ul> | ||||
* | * | ||||
* @param path the path to be normalized | |||||
* @param the normalized version of the path. | |||||
* | |||||
* @throws java.lang.NullPointerException if the file path is | * @throws java.lang.NullPointerException if the file path is | ||||
* equal to null. | * equal to null. | ||||
*/ | */ | ||||
@@ -678,10 +836,10 @@ public class FileUtils { | |||||
int colon = path.indexOf(":"); | int colon = path.indexOf(":"); | ||||
if (!onNetWare) { | if (!onNetWare) { | ||||
if (!path.startsWith(File.separator) && | |||||
!(path.length() >= 2 && | |||||
Character.isLetter(path.charAt(0)) && | |||||
colon == 1)) { | |||||
if (!path.startsWith(File.separator) | |||||
&& !(path.length() >= 2 | |||||
&& Character.isLetter(path.charAt(0)) | |||||
&& colon == 1)) { | |||||
String msg = path + " is not an absolute path"; | String msg = path + " is not an absolute path"; | ||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
@@ -696,11 +854,10 @@ public class FileUtils { | |||||
boolean dosWithDrive = false; | boolean dosWithDrive = false; | ||||
String root = null; | String root = null; | ||||
// Eliminate consecutive slashes after the drive spec | // Eliminate consecutive slashes after the drive spec | ||||
if ((!onNetWare && | |||||
path.length() >= 2 && | |||||
Character.isLetter(path.charAt(0)) && | |||||
path.charAt(1) == ':') || | |||||
(onNetWare && colon > -1)) { | |||||
if ((!onNetWare && path.length() >= 2 | |||||
&& Character.isLetter(path.charAt(0)) | |||||
&& path.charAt(1) == ':') | |||||
|| (onNetWare && colon > -1)) { | |||||
dosWithDrive = true; | dosWithDrive = true; | ||||
@@ -792,6 +949,7 @@ public class FileUtils { | |||||
* current working directory will be assumed if this parameter is | * current working directory will be assumed if this parameter is | ||||
* null. | * null. | ||||
* | * | ||||
* @return a File reference to the new temporary file. | |||||
* @since ant 1.5 | * @since ant 1.5 | ||||
*/ | */ | ||||
public File createTempFile(String prefix, String suffix, File parentDir) { | public File createTempFile(String prefix, String suffix, File parentDir) { | ||||
@@ -820,6 +978,13 @@ public class FileUtils { | |||||
* buffers followed by long comparisions apart from the final 1-7 | * buffers followed by long comparisions apart from the final 1-7 | ||||
* bytes.</p> | * bytes.</p> | ||||
* | * | ||||
* @param f1 the file whose content is to be compared. | |||||
* @param f2 the other file whose content is to be compared. | |||||
* | |||||
* @return true if the content of the files is the same. | |||||
* | |||||
* @throws IOException if the files cannot be read. | |||||
* | |||||
* @since 1.9 | * @since 1.9 | ||||
*/ | */ | ||||
public boolean contentEquals(File f1, File f2) throws IOException { | public boolean contentEquals(File f1, File f2) throws IOException { | ||||
@@ -885,6 +1050,10 @@ public class FileUtils { | |||||
/** | /** | ||||
* Emulation of File.getParentFile for JDK 1.1 | * Emulation of File.getParentFile for JDK 1.1 | ||||
* | * | ||||
* | |||||
* @param f the file whose parent is required. | |||||
* @return the given file's parent, or null if the file does not have a | |||||
* parent. | |||||
* @since 1.10 | * @since 1.10 | ||||
*/ | */ | ||||
public File getParentFile(File f) { | public File getParentFile(File f) { | ||||
@@ -899,6 +1068,11 @@ public class FileUtils { | |||||
/** | /** | ||||
* Read from reader till EOF | * Read from reader till EOF | ||||
* @param rdr the reader from which to read. | |||||
* @return the contents read out of the given reader | |||||
* | |||||
* @throws IOException if the contents could not be read out from the | |||||
* reader. | |||||
*/ | */ | ||||
public static final String readFully(Reader rdr) throws IOException { | public static final String readFully(Reader rdr) throws IOException { | ||||
return readFully(rdr, 8192); | return readFully(rdr, 8192); | ||||
@@ -906,8 +1080,17 @@ public class FileUtils { | |||||
/** | /** | ||||
* Read from reader till EOF | * Read from reader till EOF | ||||
* | |||||
* @param rdr the reader from which to read. | |||||
* @param bufferSize the buffer size to use when reading | |||||
* | |||||
* @return the contents read out of the given reader | |||||
* | |||||
* @throws IOException if the contents could not be read out from the | |||||
* reader. | |||||
*/ | */ | ||||
public static final String readFully(Reader rdr, int bufferSize) throws IOException { | |||||
public static final String readFully(Reader rdr, int bufferSize) | |||||
throws IOException { | |||||
if (bufferSize <= 0) { | if (bufferSize <= 0) { | ||||
throw new IllegalArgumentException("Buffer size must be greater " | throw new IllegalArgumentException("Buffer size must be greater " | ||||
+ "than 0"); | + "than 0"); | ||||
@@ -939,7 +1122,9 @@ public class FileUtils { | |||||
* <p>This method does <strong>not</strong> guarantee that the | * <p>This method does <strong>not</strong> guarantee that the | ||||
* operation is atomic.</p> | * operation is atomic.</p> | ||||
* | * | ||||
* @since 1.21, Ant 1.5 | |||||
* @param f the file to be created | |||||
* @return true if the file did not exist already. | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public boolean createNewFile(File f) throws IOException { | public boolean createNewFile(File f) throws IOException { | ||||
if (f != null) { | if (f != null) { | ||||
@@ -972,6 +1157,7 @@ public class FileUtils { | |||||
* @param parent the parent directory of the file to test | * @param parent the parent directory of the file to test | ||||
* @param name the name of the file to test. | * @param name the name of the file to test. | ||||
* | * | ||||
* @return true if the file is a symbolic link. | |||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public boolean isSymbolicLink(File parent, String name) | public boolean isSymbolicLink(File parent, String name) | ||||
@@ -1018,6 +1204,8 @@ public class FileUtils { | |||||
* | * | ||||
* <p>This code doesn't handle non-ASCII characters properly.</p> | * <p>This code doesn't handle non-ASCII characters properly.</p> | ||||
* | * | ||||
* @param path the path in the local file system | |||||
* @return the URI version of the local path. | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public String toURI(String path) { | public String toURI(String path) { | ||||
@@ -1065,6 +1253,8 @@ public class FileUtils { | |||||
* <p>Swallows '%' that are not followed by two characters, | * <p>Swallows '%' that are not followed by two characters, | ||||
* doesn't deal with non-ASCII characters.</p> | * doesn't deal with non-ASCII characters.</p> | ||||
* | * | ||||
* @param uri the URI designating a file in the local filesystem. | |||||
* @return the local file system path for the file. | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public String fromURI(String uri) { | public String fromURI(String uri) { | ||||
@@ -1119,6 +1309,11 @@ public class FileUtils { | |||||
* the absolute paths and "normalize" the filenames | * the absolute paths and "normalize" the filenames | ||||
* before comparing them.</p> | * before comparing them.</p> | ||||
* | * | ||||
* @param f1 the file whose name is to be compared. | |||||
* @param f2 the other file whose name is to be compared. | |||||
* | |||||
* @return true if the file are for the same file. | |||||
* | |||||
* @since Ant 1.5.3 | * @since Ant 1.5.3 | ||||
*/ | */ | ||||
public boolean fileNameEquals(File f1, File f2) { | public boolean fileNameEquals(File f1, File f2) { | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -65,6 +65,10 @@ package org.apache.tools.ant.util; | |||||
*/ | */ | ||||
public interface TimeoutObserver { | public interface TimeoutObserver { | ||||
/** | |||||
* Called when the watchdow times out. | |||||
* | |||||
* @param w the watchdog that timed out. | |||||
*/ | |||||
void timeoutOccured(Watchdog w); | void timeoutOccured(Watchdog w); | ||||
} | } |