Browse Source

value -> name to conform with ant1

add utility method to evaluate name of pattern


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

+ 32
- 11
proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java View File

@@ -9,7 +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.framework.context.ContextException;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.ant.Project;

/**
* Basic data type for holding patterns.
@@ -22,7 +25,7 @@ public class Pattern
private final static Resources REZ =
ResourceManager.getPackageResources( Pattern.class );

private String m_value;
private String m_name;
private Condition m_condition;

/**
@@ -30,9 +33,9 @@ public class Pattern
*
* @return the value of pattern
*/
public String getValue()
public String getName()
{
return m_value;
return m_name;
}

/**
@@ -46,14 +49,13 @@ public class Pattern
}

/**
* Setter method for value of pattern.
* Conforms to setter patterns
* Setter method for name of pattern.
*
* @param value the value
* @param name the name
*/
public void setValue( final String value )
public void setName( final String name )
{
m_value = value;
m_name = name;
}

/**
@@ -82,11 +84,30 @@ public class Pattern
m_condition = new Condition( false, condition );
}

public String evaluateName( final TaskContext context )
{
try
{
final boolean result = getCondition().evaluate( context );
if( result )
{
return getName();
}
}
catch( final ContextException ce )
{
//ignore for the moment
}
return null;
}


public String toString()
{
String result = "Pattern['" + m_value + "',";
if( null != m_condition ) {
result = result + m_condition;
String result = "Pattern['" + m_name + "',";
if( null != m_condition )
{
result = result + m_condition;
}
return result + "]";
}


Loading…
Cancel
Save