|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.controller.UrlBindingFactory
public class UrlBindingFactory
Provides access to UrlBinding
objects. Bindings are used in two contexts:
UrlBinding
,
UrlBindingParameter
Constructor Summary | |
---|---|
protected |
UrlBindingFactory()
Don't want the constructor to be public |
Method Summary | |
---|---|
void |
addBinding(Class<? extends ActionBean> beanType,
UrlBinding binding)
Map an ActionBean to a URL. |
protected void |
cachePath(String path,
UrlBinding binding)
Map a path directly to a binding. |
protected void |
cachePrefix(String prefix,
UrlBinding binding)
Add a binding to the set of bindings associated with a prefix. |
Collection<Class<? extends ActionBean>> |
getActionBeanClasses()
Get all the classes implementing ActionBean |
UrlBinding |
getBinding(HttpServletRequest request)
Examines a servlet request and returns the associated binding, if any. |
UrlBinding |
getBinding(String uri)
Examines a URI (as returned by HttpUtil.getRequestedPath(HttpServletRequest) ) and
returns the associated binding, if any. |
UrlBinding |
getBindingPrototype(Class<? extends ActionBean> type)
Get the UrlBinding prototype associated with the given ActionBean type. |
UrlBinding |
getBindingPrototype(HttpServletRequest request)
Examines a servlet request and returns the associated binding prototype, if any. |
UrlBinding |
getBindingPrototype(String uri)
Examines a URI (as returned by HttpUtil.getRequestedPath(HttpServletRequest) ) and
returns the associated binding prototype, if any. |
protected Set<String> |
getCachedPaths(UrlBinding binding)
Get a list of the request paths that will be wired directly to an ActionBean. |
protected Set<String> |
getCachedPrefixes(UrlBinding binding)
Get a list of the request path prefixes that could map to an ActionBean. |
static UrlBindingFactory |
getInstance()
Get the singleton instance. |
HashMap<String,Class<? extends ActionBean>> |
getPathMap()
Get all the ActionBean s classes that have been found. |
static UrlBinding |
parseUrlBinding(Class<? extends ActionBean> beanType)
Look for a binding pattern for the given ActionBean class, specified by the
UrlBinding annotation. |
static UrlBinding |
parseUrlBinding(Class<? extends ActionBean> beanType,
String pattern)
Parse the binding pattern and create a UrlBinding object for the ActionBean
class. |
static UrlBindingParameter |
parseUrlBindingParameter(Class<? extends ActionBean> beanClass,
String string)
Parses a parameter specification into name and default value and returns a UrlBindingParameter with the corresponding name and default value properties set
accordingly. |
void |
removeBinding(Class<? extends ActionBean> beanType)
Removes an ActionBean 's URL binding. |
String |
toString()
|
protected String |
trimContextPath(HttpServletRequest request)
Deprecated. Use HttpUtil.getRequestedPath(HttpServletRequest) instead. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected UrlBindingFactory()
Method Detail |
---|
public static UrlBindingFactory getInstance()
public Collection<Class<? extends ActionBean>> getActionBeanClasses()
ActionBean
public UrlBinding getBindingPrototype(Class<? extends ActionBean> type)
UrlBinding
prototype associated with the given ActionBean
type. This
method may return null if no binding is associated with the given type.
type
- a class that implements ActionBean
public UrlBinding getBindingPrototype(String uri)
HttpUtil.getRequestedPath(HttpServletRequest)
) and
returns the associated binding prototype, if any. No attempt is made to extract parameter
values from the URI. This is intended as a fast means to get static information associated
with a given request URI.
uri
- a request URI
public UrlBinding getBindingPrototype(HttpServletRequest request)
request
- a servlet request
public UrlBinding getBinding(String uri)
HttpUtil.getRequestedPath(HttpServletRequest)
) and
returns the associated binding, if any. Parameters will be extracted from the URI, and the
UrlBindingParameter
objects returned by UrlBinding.getParameters()
will
contain the values that are present in the URI.
uri
- a request URI
public UrlBinding getBinding(HttpServletRequest request)
UrlBindingParameter
objects returned by
UrlBinding.getParameters()
will contain the values that are present in the request.
request
- a servlet request
public HashMap<String,Class<? extends ActionBean>> getPathMap()
ActionBean
s classes that have been found.
ActionBean
classespublic void addBinding(Class<? extends ActionBean> beanType, UrlBinding binding)
ActionBean
to a URL.
beanType
- the ActionBean
classbinding
- the URL bindingpublic void removeBinding(Class<? extends ActionBean> beanType)
ActionBean
's URL binding.
beanType
- the ActionBean
classprotected Set<String> getCachedPaths(UrlBinding binding)
protected Set<String> getCachedPrefixes(UrlBinding binding)
protected void cachePath(String path, UrlBinding binding)
path
- The path to cachebinding
- The binding to which the path should mapprotected void cachePrefix(String prefix, UrlBinding binding)
prefix
- The prefix to cachebinding
- The binding to map to the prefixpublic static UrlBinding parseUrlBinding(Class<? extends ActionBean> beanType)
ActionBean
class, specified by the
UrlBinding
annotation. If the annotation is found,
create and return a UrlBinding
object for the class. Otherwise, return null.
beanType
- The ActionBean
type whose binding is to be parsed
UrlBinding
if one is specified, or null if not.
ParseException
- If the pattern cannot be parsedpublic static UrlBinding parseUrlBinding(Class<? extends ActionBean> beanType, String pattern)
UrlBinding
object for the ActionBean
class. If pattern is null or zero-length, then return null.
beanType
- The ActionBean
type to be mapped to the pattern.pattern
- The URL binding pattern to parse.
UrlBinding
or null if the pattern is null or zero-length
ParseException
- If the pattern cannot be parsedpublic static UrlBindingParameter parseUrlBindingParameter(Class<? extends ActionBean> beanClass, String string)
UrlBindingParameter
with the corresponding name and default value properties set
accordingly.
beanClass
- the bean class to which the binding appliesstring
- the parameter string
ParseException
- if the pattern cannot be parsed@Deprecated protected String trimContextPath(HttpServletRequest request)
HttpUtil.getRequestedPath(HttpServletRequest)
instead.
request
with the context path trimmed from the
beginning. I.e., the request URI relative to the context.
request
- a servlet request
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |