Java Doc for CommandResolver.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.ui 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ecyrd.jspwiki.ui.CommandResolver

CommandResolver
final public class CommandResolver (Code)

Resolves special pages, JSPs and Commands on behalf of a WikiEngine. CommandResolver will automatically resolve page names with singular/plural variants. It can also detect the correct Command based on parameters supplied in an HTTP request, or due to the JSP being accessed.

CommandResolver's static CommandResolver.findCommand(String) method is the simplest method; it looks up and returns the Command matching a supplied wiki context. For example, looking up the request context view returns PageCommand.VIEW . Use this method to obtain static Command instances that aren't targeted at a particular page or group.

For more complex lookups in which the caller supplies an HTTP request, CommandResolver.findCommand(HttpServletRequest,String) will look up and return the correct Command. The String parameter defaultContext supplies the request context to use if it cannot be detected. However, note that the default wiki context may be over-ridden if the request was for a "special page."

For example, suppose the WikiEngine's properties specify a special page called UserPrefs that redirects to UserPreferences.jsp. The ordinary lookup method using a supplied context view would return PageCommand.VIEW . But the method, when passed the same context (view) and an HTTP request containing the page parameter value UserPrefs, will instead return WikiCommand.PREFS .


author:
   Andrew Jaquith
since:
   2.4.22



Constructor Summary
public  CommandResolver(WikiEngine engine, Properties properties)
     Constructs a CommandResolver for a given WikiEngine.

Method Summary
final protected  CommandextractCommandFromPath(HttpServletRequest request)
     Extracts a Command based on the JSP path of an HTTP request.
final protected  StringextractPageFromParameter(String requestContext, HttpServletRequest request)
     Determines the correct wiki page based on a supplied request context and HTTP request.
public static  CommandfindCommand(String context)
     Attempts to locate a wiki command for a supplied request context. The resolution technique is simple: we examine the list of Commands returned by AbstractCommand.allCommands and return the one whose requestContext matches the supplied context.
final public  CommandfindCommand(HttpServletRequest request, String defaultContext)
    

Attempts to locate a Command for a supplied wiki context and HTTP request, incorporating the correct WikiPage into the command if reqiured. This method will first determine what page the user requested by delegating to CommandResolver.extractPageFromParameter(String,HttpServletRequest) .

final public  StringgetFinalPageName(String page)
    

Returns the correct page name, or null, if no such page can be found. Aliases are considered.

In some cases, page names can refer to other pages.

final public  StringgetSpecialPageReference(String page)
    

If the page is a special page, this method returns a direct URL to that page; otherwise, it returns null.

Special pages are non-existant references to other pages.

final protected  WikiPageresolvePage(HttpServletRequest request, String page)
     Looks up and returns the correct, versioned WikiPage based on a supplied page name and optional version parameter passed in an HTTP request.
final protected  booleansimplePageExists(String page)
     Determines whether a "page" exists by examining the list of special pages and querying the page manager.


Constructor Detail
CommandResolver
public CommandResolver(WikiEngine engine, Properties properties)(Code)
Constructs a CommandResolver for a given WikiEngine. This constructor will extract the special page references for this wiki and store them in a cache used for resolution.
Parameters:
  engine - the wiki engine
Parameters:
  properties - the properties used to initialize the wiki




Method Detail
extractCommandFromPath
final protected Command extractCommandFromPath(HttpServletRequest request)(Code)
Extracts a Command based on the JSP path of an HTTP request. If the JSP requested matches a Command's getJSP() value, that Command is returned.
Parameters:
  request - the HTTP request the resolved Command, or null if not found



extractPageFromParameter
final protected String extractPageFromParameter(String requestContext, HttpServletRequest request)(Code)
Determines the correct wiki page based on a supplied request context and HTTP request. This method attempts to determine the page requested by a user, taking into acccount special pages. The resolution algorithm will:
  • Extract the page name from the URL according to the rules for the current URLConstructor . If a page name was passed in the request, return the correct name after taking into account potential plural matches.
  • If the extracted page name is null, attempt to see if a "special page" was intended by examining the servlet path. For example, the request path "/UserPreferences.jsp" will resolve to "UserPreferences."
  • If neither of these methods work, this method returns null

Parameters:
  requestContext - the request context
Parameters:
  request - the HTTP request the resolved page name



findCommand
public static Command findCommand(String context)(Code)
Attempts to locate a wiki command for a supplied request context. The resolution technique is simple: we examine the list of Commands returned by AbstractCommand.allCommands and return the one whose requestContext matches the supplied context. If the supplied context does not resolve to a known Command, this method throws an IllegalArgumentException .
Parameters:
  context - the request context the resolved context



findCommand
final public Command findCommand(HttpServletRequest request, String defaultContext)(Code)

Attempts to locate a Command for a supplied wiki context and HTTP request, incorporating the correct WikiPage into the command if reqiured. This method will first determine what page the user requested by delegating to CommandResolver.extractPageFromParameter(String,HttpServletRequest) . If this page equates to a special page, we return the Command corresponding to that page. Otherwise, this method simply returns the Command for the supplied request context.

The reason this method attempts to resolve against special pages is because some of them resolve to contexts that may be different from the one supplied. For example, a VIEW request context for the special page "UserPreferences" should return a PREFS context instead.

When the caller supplies a request context and HTTP request that specifies an actual wiki page (rather than a special page), this method will return a "targeted" Command that includes the resolved WikiPage as the target. (See CommandResolver.resolvePage(HttpServletRequest,String) for the resolution algorithm). Specifically, the Command will return a non-null value for its AbstractCommand.getTarget method.

Note: if this method determines that the Command is the VIEW PageCommand, then the Command returned will always be targeted to the front page.


Parameters:
  request - the HTTP request; if null, delegatesto CommandResolver.findCommand(String)
Parameters:
  defaultContext - the request context to use by default the resolved wiki command



getFinalPageName
final public String getFinalPageName(String page) throws ProviderException(Code)

Returns the correct page name, or null, if no such page can be found. Aliases are considered.

In some cases, page names can refer to other pages. For example, when you have matchEnglishPlurals set, then a page name "Foobars" will be transformed into "Foobar", should a page "Foobars" not exist, but the page "Foobar" would. This method gives you the correct page name to refer to.

This facility can also be used to rewrite any page name, for example, by using aliases. It can also be used to check the existence of any page.


since:
   2.4.20
Parameters:
  page - the page name. The rewritten page name, or null, if the page does not exist.
throws:
  ProviderException - if the underlyng page provider that locates pagesthrows an exception



getSpecialPageReference
final public String getSpecialPageReference(String page)(Code)

If the page is a special page, this method returns a direct URL to that page; otherwise, it returns null.

Special pages are non-existant references to other pages. For example, you could define a special page reference "RecentChanges" which would always be redirected to "RecentChanges.jsp" instead of trying to find a Wiki page called "RecentChanges".


Parameters:
  page - the page name ro search for the URL of the special page, if the supplied page is one, or null



resolvePage
final protected WikiPage resolvePage(HttpServletRequest request, String page)(Code)
Looks up and returns the correct, versioned WikiPage based on a supplied page name and optional version parameter passed in an HTTP request. If the version parameter does not exist in the request, the latest version is returned.
Parameters:
  request - the HTTP request
Parameters:
  page - the name of the page to look up; this page must exist the wiki page



simplePageExists
final protected boolean simplePageExists(String page) throws ProviderException(Code)
Determines whether a "page" exists by examining the list of special pages and querying the page manager.
Parameters:
  page - the page to seek true if the page exists, falseotherwise
throws:
  ProviderException - if the underlyng page provider that locates pagesthrows an exception



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.