Browse Source

Bring condition into line with Ant2 thinking - make it check the value of condition - not just for its existance

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270825 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
c9e46c0f28
1 changed files with 21 additions and 18 deletions
  1. +21
    -18
      proposal/myrmidon/src/java/org/apache/myrmidon/framework/Condition.java

+ 21
- 18
proposal/myrmidon/src/java/org/apache/myrmidon/framework/Condition.java View File

@@ -9,11 +9,10 @@ package org.apache.myrmidon.framework;

import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.property.PropertyException;
import org.apache.avalon.excalibur.property.PropertyUtil;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;

/**
* Class representing a condition.
@@ -45,35 +44,39 @@ public class Condition
return m_isIfCondition;
}

public boolean evaluate( final Context context )
public boolean evaluate( final TaskContext context )
throws ContextException
{
boolean result = false;

try
{
final Object resolved =
PropertyUtil.resolveProperty( getCondition(), context, false );

final Object resolved = context.resolveValue( getCondition() );
if( null != resolved )
{
final Object object = context.get( resolved );
//TODO: Do more than just check for presence????????????

//true as object present
result = true;
final String string = object.toString();
if( null == string || string.equals( "false" ) )
{
result = false;
}
else
{
result = true;
}
}
}
catch( final ContextException ce )
catch( final TaskException te )
{
result = false;
}
catch( final PropertyException pe )
{
final String message = REZ.getString( "condition.no-resolve.error", m_condition );
throw new ContextException( message, pe );
}

/*
catch( final PropertyException pe )
{
final String message = REZ.getString( "condition.no-resolve.error", m_condition );
throw new ContextException( message, pe );
}
*/
if( !m_isIfCondition )
{
result = !result;


Loading…
Cancel
Save