Class DefaultProfileTargetingExpression.ExpressionToken
- java.lang.Object
-
- org.smooks.engine.resource.config.DefaultProfileTargetingExpression.ExpressionToken
-
- Enclosing class:
- DefaultProfileTargetingExpression
protected static class DefaultProfileTargetingExpression.ExpressionToken extends Object
Profile targeting expression token.- Author:
- tfennelly
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getSpecificity(ProfileSet profileSet)
Get the specificity of this token with respect to the supplied device.String
getToken()
Get the token value (profile).boolean
isMatch(ProfileSet profileSet)
Is the profile specified in this token is a member of the supplied profile set.boolean
isNegated()
Is this token negated.boolean
isWildcard()
Is the token a wildcard token.String
toString()
-
-
-
Method Detail
-
getToken
public String getToken()
Get the token value (profile).- Returns:
- The profile specified in this token.
-
isNegated
public boolean isNegated()
Is this token negated. Is the token prefixed with "not:".- Returns:
- True if the token is negated, otherwise false.
-
isWildcard
public boolean isWildcard()
Is the token a wildcard token. Is the token equal to "*".- Returns:
- True if the token is a wildcard token, otherwise false.
-
isMatch
public boolean isMatch(ProfileSet profileSet)
Is the profile specified in this token is a member of the supplied profile set.- Parameters:
profileSet
- Profile set.- Returns:
- True if the profile specified in this token is a member of the supplied profile set, otherwise false.
-
getSpecificity
public double getSpecificity(ProfileSet profileSet)
Get the specificity of this token with respect to the supplied device. The following outlines the algorithm:if(isNegated()) { if(profileSet.getBaseProfile().equals(expressionToken)) { return 0; } else if(profileSet.isMember(expressionToken)) { return 0; } else if(isWildcard()) { return 0; } return 1; } else { // Is the "expressionToken" referencing the base profile, a sub-profile, // or is it a wildcard token. Profile profile = profileSet.getProfile(expressionToken); if(profileSet.getBaseProfile().equalsIgnoreCase(expressionToken)) { return 100; } else if(profile != null) { // If it's a HTTP "Accept" header media profile, multiple // the specificity by the media qvalue. See the // HttpAcceptHeaderProfile javadocs. if(profile instanceof HttpAcceptHeaderProfile) { return (10 * ((HttpAcceptHeaderProfile)profile).getParamNumeric("q", 1)); } else { return 10; } } else if(isWildcard()) { return 5; } return 0; }
- Parameters:
profileSet
- Profile set.- Returns:
- Specificity value for the token.
-
-