org.apache.wiki.ui
Class AbstractCommand

java.lang.Object
  extended by org.apache.wiki.ui.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
GroupCommand, PageCommand, RedirectCommand, WikiCommand

public abstract class AbstractCommand
extends Object
implements Command

Abstract, immutable Command implementation class. All of the fields in this class are final. This class is thread-safe.

Since:
2.4.22

Constructor Summary
protected AbstractCommand(String requestContext, String urlPattern, String contentTemplate, Object target)
          Constructs a new Command with a specified wiki context, URL pattern, content template and target.
 
Method Summary
static Command[] allCommands()
          Returns a defensively-created array of all static Commands.
 String getContentTemplate()
          Returns the content template associated with a Command, such as PreferencesContent.jsp.
 String getJSP()
          Returns the JSP associated with the Command.
protected  String getJSPFriendlyName()
          Returns the "friendly name" for this command's JSP, namely a beatified version of the JSP's name without the .jsp suffix.
abstract  String getName()
          Returns the human-friendly name for this command.
 String getRequestContext()
          Returns the request context associated with this Command.
 Object getTarget()
          Returns the target associated with a Command, if it was created with one.
 String getURLPattern()
          Returns the URL pattern associated with this Command.
abstract  Command targetedCommand(Object target)
          Creates and returns a targeted Command by combining a target, such as a WikiPage or GroupPrincipal into the existing Command.
 String toString()
          Returns a String representation of the Command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.wiki.ui.Command
requiredPermission
 

Constructor Detail

AbstractCommand

protected AbstractCommand(String requestContext,
                          String urlPattern,
                          String contentTemplate,
                          Object target)
Constructs a new Command with a specified wiki context, URL pattern, content template and target. The URL pattern is used to derive the JSP; if it is a "local" JSP (that is, it does not contain the http:// or https:// prefixes), then the JSP will be a cleansed version of the URL pattern; symbols (such as %u) will removed. If it the supplied URL pattern points to a non-local destination, the JSP will be set to the value supplied, unmodified.

Parameters:
requestContext - the request context
urlPattern - the URL pattern
contentTemplate - the content template; may be null
target - the target of the command, such as a WikiPage; may be null
Throws:
IllegalArgumentException - if the request content or URL pattern is null
Method Detail

allCommands

public static final Command[] allCommands()
Returns a defensively-created array of all static Commands.

Returns:
the array of commands

targetedCommand

public abstract Command targetedCommand(Object target)
Description copied from interface: Command
Creates and returns a targeted Command by combining a target, such as a WikiPage or GroupPrincipal into the existing Command. Subclasses should check to make sure the supplied target object is of the correct type. This method is guaranteed to return a non-null Command (unless the target is an incorrect type).

Specified by:
targetedCommand in interface Command
Parameters:
target - the object to combine, such as a GroupPrincipal or WikiPage
Returns:
the new, targeted Command
See Also:
Command.targetedCommand(Object)

getContentTemplate

public final String getContentTemplate()
Description copied from interface: Command
Returns the content template associated with a Command, such as PreferencesContent.jsp. For Commands that are not page-related, this method will always return null. Calling methods should always check to see if the result of this method is null.

Specified by:
getContentTemplate in interface Command
Returns:
the content template
See Also:
Command.getContentTemplate()

getJSP

public final String getJSP()
Description copied from interface: Command
Returns the JSP associated with the Command. The JSP is a "local" JSP within the JSPWiki webapp; it is not a general HTTP URL. If it exists, the JSP will be expressed relative to the webapp root, without a leading slash. This method is guaranteed to return a non-null result, although in some cases the result may be an empty string.

Specified by:
getJSP in interface Command
Returns:
the JSP or url associated with the wiki command
See Also:
Command.getJSP()

getName

public abstract String getName()
Description copied from interface: Command
Returns the human-friendly name for this command.

Specified by:
getName in interface Command
Returns:
the name
See Also:
Command.getName()

getRequestContext

public final String getRequestContext()
Description copied from interface: Command
Returns the request context associated with this Command. This method is guaranteed to return a non-null String.

Specified by:
getRequestContext in interface Command
Returns:
the request context
See Also:
Command.getRequestContext()

getTarget

public final Object getTarget()
Description copied from interface: Command
Returns the target associated with a Command, if it was created with one. Commands created with Command.targetedCommand(Object) will always return a non-null object. Calling methods should always check to see if the result of this method is null.

Specified by:
getTarget in interface Command
Returns:
the wiki page
See Also:
Command.getTarget()

getURLPattern

public final String getURLPattern()
Description copied from interface: Command
Returns the URL pattern associated with this Command. This method is guaranteed to return a non-null String.

Specified by:
getURLPattern in interface Command
Returns:
the URL pattern
See Also:
Command.getURLPattern()

getJSPFriendlyName

protected final String getJSPFriendlyName()
Returns the "friendly name" for this command's JSP, namely a beatified version of the JSP's name without the .jsp suffix.

Returns:
the friendly name

toString

public final String toString()
Returns a String representation of the Command.

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.