@@ -30,33 +30,28 @@ import org.apache.tools.ant.types.Reference;
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @author <a href="mailto:glennm@ca.ibm.com">Glenn McAllister</a>
* @author <a href="mailto:glennm@ca.ibm.com">Glenn McAllister</a>
*/
*/
public class Property extends Task
public class Property
extends Task
{
{
protected Path classpath;
protected String env;
protected File file;
private Path m_ classpath;
private String m_ env;
private File m_ file;
protected String name;
protected Reference ref;
protected String resource;
protected String value;// set read-only properties
public Property()
{
super();
}
private String m_name;
private Reference m_ref;
private String m_resource;
private String m_value;
public void setClasspath( Path classpath )
public void setClasspath( Path classpath )
throws TaskException
throws TaskException
{
{
if( this. classpath == null )
if( m_classpath == null )
{
{
this. classpath = classpath;
m_ classpath = classpath;
}
}
else
else
{
{
this. classpath.append( classpath );
m_ classpath.append( classpath );
}
}
}
}
@@ -68,12 +63,12 @@ public class Property extends Task
public void setEnvironment( String env )
public void setEnvironment( String env )
{
{
this. env = env;
m_ env = env;
}
}
public void setFile( File file )
public void setFile( File file )
{
{
this. file = file;
m_ file = file;
}
}
public void setLocation( File location )
public void setLocation( File location )
@@ -83,129 +78,118 @@ public class Property extends Task
public void setName( String name )
public void setName( String name )
{
{
this. name = name;
m_ name = name;
}
}
public void setRefid( Reference ref )
public void setRefid( Reference ref )
{
{
this. ref = ref;
m_ ref = ref;
}
}
public void setResource( String resource )
public void setResource( String resource )
{
{
this. resource = resource;
m_ resource = resource;
}
}
public void setValue( String value )
public void setValue( String value )
{
{
this. value = value;
m_ value = value;
}
}
public String getEnvironment()
public String getEnvironment()
{
{
return env;
return m_ env;
}
}
public File getFile()
public File getFile()
{
{
return file;
return m_ file;
}
}
public Reference getRefid()
public Reference getRefid()
{
{
return ref;
return m_ ref;
}
}
public String getResource()
public String getResource()
{
{
return resource;
return m_ resource;
}
}
public String getValue()
public String getValue()
{
{
return value;
return m_ value;
}
}
public Path createClasspath()
public Path createClasspath()
throws TaskException
throws TaskException
{
{
if( this. classpath == null )
if( m_ classpath == null )
{
{
this. classpath = new Path();
m_ classpath = new Path();
}
}
return this. classpath.createPath();
return m_ classpath.createPath();
}
}
public void execute()
public void execute()
throws TaskException
throws TaskException
{
{
if( name != null )
if( m_ name != null )
{
{
if( value == null && ref == null )
if( m_ value == null && m_ ref == null )
{
{
throw new TaskException( "You must specify value, location or refid with the name attribute" );
throw new TaskException( "You must specify value, location or refid with the name attribute" );
}
}
}
}
else
else
{
{
if( file == null && resource == null && env == null )
if( m_ file == null && m_ resource == null && m_ env == null )
{
{
throw new TaskException( "You must specify file, resource or environment when not using the name attribute" );
throw new TaskException( "You must specify file, resource or environment when not using the name attribute" );
}
}
}
}
if( ( name != null ) && ( value != null ) )
if( ( m_ name != null ) && ( m_ value != null ) )
{
{
addProperty( name, value );
setProperty( m_name, m_ value );
}
}
if( file != null )
loadFile( file );
if( m_ file != null )
loadFile( m_ file );
if( resource != null )
loadResource( resource );
if( m_ resource != null )
loadResource( m_ resource );
if( env != null )
loadEnvironment( env );
if( m_ env != null )
loadEnvironment( m_ env );
if( ( name != null ) && ( ref != null ) )
if( ( m_ name != null ) && ( m_ ref != null ) )
{
{
Object obj = ref.getReferencedObject( getProject() );
Object obj = m_ ref.getReferencedObject( getProject() );
if( obj != null )
if( obj != null )
{
{
addProperty( name, obj.toString() );
setProperty( m_ name, obj.toString() );
}
}
}
}
}
}
public String toString()
public String toString()
{
{
return value == null ? "" : value;
return m_ value == null ? "" : m_ value;
}
}
protected void addProperties( Properties props )
protected void addProperties( Properties props )
throws TaskException
throws TaskException
{
{
//no longer needs as ant2 properties are completely dynamic
//resolveAllProperties( props );
Enumeration e = props.keys();
while( e.hasMoreElements() )
final Iterator e = props.keySet().iterator();
while( e.hasNext() )
{
{
String name = (String)e.nextElement();
String value = (String)props.getProperty( name );
String v = getProject().replaceProperties( value );
addProperty( name, v );
final String name = (String)e.next();
final String value = (String)props.getProperty( name );
setProperty( name, value );
}
}
}
}
protected void addProperty( String n, String v )
throws TaskException
{
setProperty( n, v );
}
protected void loadEnvironment( String prefix )
protected void loadEnvironment( String prefix )
throws TaskException
throws TaskException
{
{
@@ -288,13 +272,13 @@ public class Property extends Task
ClassLoader cL = null;
ClassLoader cL = null;
InputStream is = null;
InputStream is = null;
if( classpath != null )
if( m_ classpath != null )
{
{
cL = new AntClassLoader( getProject(), classpath );
cL = new AntClassLoader( getProject(), m_ classpath );
}
}
else
else
{
{
cL = this. getClass().getClassLoader();
cL = getClass().getClassLoader();
}
}
if( cL == null )
if( cL == null )