org.milyn.cdr
Class ProfileTargetingExpression

java.lang.Object
  extended by org.milyn.cdr.ProfileTargetingExpression

public class ProfileTargetingExpression
extends Object

Represents a single parsed profile targeting expression.

The target-profile attribute can contain multiple comma seperated "profile targeting expressions" i.e. a list of them. See SmooksResourceConfiguration docs. This class represents a single expression within a list of expressions.

So, a single expression is composed of 1 or more "expression tokens" seperated by "AND". The expression arg to the constructor will be in one of the following forms:

  1. "profileX" i.e. a single entity.
  2. "profileX AND profileY" i.e. a compound entity.
  3. "profileX AND not:profileY" i.e. a compound entity.
Note, we only supports "AND" operations between the tokens, but a token can be negated by prefixing it with "not:".

See ProfileTargetingExpression.ExpressionToken.

Author:
tfennelly

Nested Class Summary
 class ProfileTargetingExpression.ExpressionToken
          Profile targeting expression token.
 
Constructor Summary
ProfileTargetingExpression(String expression)
           
 
Method Summary
 String getExpression()
          Get the expression used to construct this instance.
 ProfileTargetingExpression.ExpressionToken[] getExpressionTokens()
          Get the list of ProfileTargetingExpression.ExpressionTokens parsed out of the expression used to construct this instance.
 double getSpecificity(ProfileSet profileSet)
          Get the specificity of this expression with respect to the supplied profile set.
 boolean isMatch(ProfileSet profileSet)
          Does this expression match one of the profiles in the supplied profile set.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProfileTargetingExpression

public ProfileTargetingExpression(String expression)
Method Detail

isMatch

public boolean isMatch(ProfileSet profileSet)
Does this expression match one of the profiles in the supplied profile set.

Parameters:
profileSet - Profile set.
Returns:
True if this expression matches one of the profiles in the supplied profile set, otherwise false.

getSpecificity

public double getSpecificity(ProfileSet profileSet)
Get the specificity of this expression with respect to the supplied profile set.

Iterates over this expressions list of ProfileTargetingExpression.ExpressionTokens calling ProfileTargetingExpression.ExpressionToken.getSpecificity(org.milyn.profile.ProfileSet) and adds up their specificities.

Parameters:
profileSet - Evaluation Profile Set.
Returns:
Specificity value of the expression for the supplied profile set.

getExpression

public String getExpression()
Get the expression used to construct this instance.

Returns:
The expression string for this instance.

getExpressionTokens

public ProfileTargetingExpression.ExpressionToken[] getExpressionTokens()
Get the list of ProfileTargetingExpression.ExpressionTokens parsed out of the expression used to construct this instance.

Returns:
The list of ProfileTargetingExpression.ExpressionTokens.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008. All Rights Reserved.