org.apache.struts.config
Class ActionConfigMatcher

java.lang.Object
  extended by org.apache.struts.config.ActionConfigMatcher
All Implemented Interfaces:
java.io.Serializable

public class ActionConfigMatcher
extends java.lang.Object
implements java.io.Serializable

Matches paths against pre-compiled wildcard expressions pulled from action configs. It uses the wildcard matcher from the Apache Cocoon project. Patterns will be matched in the order they exist in the Struts config file. The last match wins, so more specific patterns should be defined after less specific patterns.

Since:
Struts 1.2
See Also:
Serialized Form

Constructor Summary
ActionConfigMatcher(ActionConfig[] configs)
           Finds and precompiles the wildcard patterns from the ActionConfig "path" attributes.
 
Method Summary
protected  ActionConfig convertActionConfig(java.lang.String path, ActionConfig orig, java.util.Map vars)
           Clones the ActionConfig and its children, replacing various properties with the values of the wildcard-matched strings.
protected  java.lang.String convertParam(java.lang.String val, java.util.Map vars)
           Inserts into a value wildcard-matched strings where specified.
 ActionConfig match(java.lang.String path)
           Matches the path against the compiled wildcard patterns.
protected  void replaceProperties(java.util.Properties orig, java.util.Properties props, java.util.Map vars)
           Replaces placeholders from one Properties values set to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionConfigMatcher

public ActionConfigMatcher(ActionConfig[] configs)

Finds and precompiles the wildcard patterns from the ActionConfig "path" attributes. ActionConfig's will be evaluated in the order they exist in the Struts config file. Only paths that actually contain a wildcard will be compiled.

Parameters:
configs - An array of ActionConfig's to process
Method Detail

match

public ActionConfig match(java.lang.String path)

Matches the path against the compiled wildcard patterns.

Parameters:
path - The portion of the request URI for selecting a config.
Returns:
The action config if matched, else null

convertActionConfig

protected ActionConfig convertActionConfig(java.lang.String path,
                                           ActionConfig orig,
                                           java.util.Map vars)

Clones the ActionConfig and its children, replacing various properties with the values of the wildcard-matched strings.

Parameters:
path - The requested path
orig - The original ActionConfig
vars - A Map of wildcard-matched strings
Returns:
A cloned ActionConfig with appropriate properties replaced with wildcard-matched values

replaceProperties

protected void replaceProperties(java.util.Properties orig,
                                 java.util.Properties props,
                                 java.util.Map vars)

Replaces placeholders from one Properties values set to another.

Parameters:
orig - The original properties set with placehold values
props - The target properties to store the processed values
vars - A Map of wildcard-matched strings

convertParam

protected java.lang.String convertParam(java.lang.String val,
                                        java.util.Map vars)

Inserts into a value wildcard-matched strings where specified.

Parameters:
val - The value to convert
vars - A Map of wildcard-matched strings
Returns:
The new value


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.