public class ProfileTargetingExpression.ExpressionToken extends Object
| Modifier and Type | Method and 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() |
public String getToken()
public boolean isNegated()
public boolean isWildcard()
public boolean isMatch(ProfileSet profileSet)
profileSet - Profile set.public double getSpecificity(ProfileSet profileSet)
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;
}
profileSet - Profile set.Copyright © 2020. All rights reserved.