org.apache.myfaces.trinidadinternal.skin
Class AgentAtRuleMatcher

java.lang.Object
  extended by org.apache.myfaces.trinidadinternal.skin.AgentAtRuleMatcher

public final class AgentAtRuleMatcher
extends java.lang.Object

Threadsafe immutable class that stores the @agent rule for a particular @agent query string from the skinning css file (e.g., @agent ie and (version:5), ie and (version:6), gecko {}). This class is used to match the current agent against the @agent rule.

See Also:
StyleSheetNode, NameUtils

Nested Class Summary
static class AgentAtRuleMatcher.Match
          Enumeration representing the result of a call to match.
 
Constructor Summary
AgentAtRuleMatcher(java.lang.String queryString)
          Creates an AgentAtRuleMatcher from an @agent query string.
AgentAtRuleMatcher(java.lang.String[] selectors)
          Creates an AgentAtRuleMatcher from a decomposed array of @agent query selectors.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 int hashCode()
           
 java.util.Set<AgentAtRuleMatcher.Match> match(TrinidadAgent agent)
           Called to actually determine if this AgentAtRuleMatcher applies to the current agent.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AgentAtRuleMatcher

public AgentAtRuleMatcher(java.lang.String queryString)
Creates an AgentAtRuleMatcher from an @agent query string. if the @agent rule were @agent ie and (version:8), gecko and (version:1.9) { .foo {background-color:red}} the query string would be "ie and (version:8), gecko and (version:1.9)"

Parameters:
queryString - String containing the query portion of the @agent at-rule

AgentAtRuleMatcher

public AgentAtRuleMatcher(java.lang.String[] selectors)
Creates an AgentAtRuleMatcher from a decomposed array of @agent query selectors. With one array entry for each comma-separated selector. if the @agent rule were @agent ie and (version:8), gecko and (version:1.9) { .foo {background-color:red}} the decomposed selectors would be: selector[0] = "ie and (version:8)"; selector[1] = "gecko and (version:1.9)";

Parameters:
selectors - Array of query selectors with one selector for every or'ed rule
Method Detail

match

public java.util.Set<AgentAtRuleMatcher.Match> match(TrinidadAgent agent)

Called to actually determine if this AgentAtRuleMatcher applies to the current agent. The result is a Set of Match constants indicating how precise the match is. While all anded rules must match for the match to succeed, some callers need information regarding whether the Version information was also necessary in order for the match to succeed. For example, when generating CSS files, the version information is only part of the CSS name if the generated CSS file for the agent contained version-dependent content.

There are three possible return values

  1. An empty Set, indicating no match
  2. A set containing Match.APPLICATION, indicating a match that only needed to match against the agent Application
  3. A set containing both Match.APPLICATION and Match.VERSION, indicating that both the agent Application and its version needed to be matched against

Parameters:
agent - Agent to test for compatibility with
Returns:
the Set of successful matches, if any

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.