* @return
* @throws IOException
* @throws Exception
*/
public Match match(String targetUserAgent, Match match) throws IOException {
MatchState state;
if (userAgentCache != null && targetUserAgent != null) {
state = userAgentCache.tryGetValue(targetUserAgent);
if (state == null) {
// The user agent has not been checked previously. Therefore perform
// the match and store the results in the cache.
match = matchNoCache(targetUserAgent, match);
// Record the match state in the cache for next time.
state = match.new MatchState(match);
userAgentCache.setActive(targetUserAgent, state);
} else {
// The state of a previous match exists so the match should
// be configured based on the results of the previous state.
match.setState(state);