org.apache.openjpa.persistence.jest
Class AbstractCommand

java.lang.Object
  extended by org.apache.openjpa.persistence.jest.AbstractCommand
All Implemented Interfaces:
JESTCommand
Direct Known Subclasses:
DomainCommand, FindCommand, PropertiesCommand, QueryCommand

abstract class AbstractCommand
extends Object
implements JESTCommand

The abstract base class for all commands available to JEST.

Author:
Pinaki Poddar

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.openjpa.persistence.jest.JESTCommand
JESTCommand.Format
 
Field Summary
protected  JPAServletContext _ctx
           
protected  ObjectFormatter<?> _formatter
           
protected static Localizer _loc
           
static Collection<String> EMPTY_LIST
           
static char EQUAL
           
static String PATH_SEPARATOR
           
 
Constructor Summary
protected AbstractCommand(JPAServletContext ctx)
           
 
Method Summary
protected  void debug(HttpServletRequest request, HttpServletResponse response, JPAServletContext ctx)
           
 String getArgument(String key)
          Get the value of this command's argument of the given name.
 Map<String,String> getArguments()
          Get this command's arguments.
protected  JESTCommand.Format getDefaultFormat()
           
 JPAServletContext getExecutionContext()
          Get the execution context of this command.
 String getMandatoryArgument(String key)
           
protected  Collection<String> getMandatoryArguments()
          Gets the mandatory arguments.
protected  int getMaximumArguments()
          Gets the maximum number of arguments excluding the mandatory arguments.
protected  int getMinimumArguments()
          Gets the minimum number of arguments excluding the mandatory arguments.
 ObjectFormatter<?> getObjectFormatter()
           
 String getQualifier(String key)
          Get the value of this command's qualifier of the given name.
 Map<String,String> getQualifiers()
          Get this command's qualifiers.
protected  Collection<String> getValidQualifiers()
          Gets the valid qualifiers.
 boolean hasArgument(String key)
          Affirm this command contains an argument of the given name.
 boolean hasQualifier(String key)
          Affirm this command contains an qualifier of the given name.
protected  boolean isBooleanQualifier(String key)
           
 void parse()
          Parses HTTP Request for the qualifier and argument of a command.
protected  void popFetchPlan(boolean finder)
           
protected  void pushFetchPlan(Object target)
           
protected  List<OpenJPAStateManager> toStateManager(Collection<?> objects)
           
protected  OpenJPAStateManager toStateManager(Object obj)
           
protected  void validate()
          Called post-parse to validate this command has requisite qualifiers and arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.persistence.jest.JESTCommand
process
 

Field Detail

EQUAL

public static final char EQUAL
See Also:
Constant Field Values

PATH_SEPARATOR

public static final String PATH_SEPARATOR
See Also:
Constant Field Values

EMPTY_LIST

public static final Collection<String> EMPTY_LIST

_formatter

protected ObjectFormatter<?> _formatter

_ctx

protected final JPAServletContext _ctx

_loc

protected static Localizer _loc
Constructor Detail

AbstractCommand

protected AbstractCommand(JPAServletContext ctx)
Method Detail

getExecutionContext

public JPAServletContext getExecutionContext()
Description copied from interface: JESTCommand
Get the execution context of this command.

Specified by:
getExecutionContext in interface JESTCommand
Returns:
the execution context. never null.

getMandatoryArgument

public String getMandatoryArgument(String key)

getArgument

public String getArgument(String key)
Description copied from interface: JESTCommand
Get the value of this command's argument of the given name.

Specified by:
getArgument in interface JESTCommand
Returns:
null if the argument does not exist.

hasArgument

public boolean hasArgument(String key)
Description copied from interface: JESTCommand
Affirm this command contains an argument of the given name.

Specified by:
hasArgument in interface JESTCommand

getArguments

public Map<String,String> getArguments()
Description copied from interface: JESTCommand
Get this command's arguments.

Specified by:
getArguments in interface JESTCommand

getQualifier

public String getQualifier(String key)
Description copied from interface: JESTCommand
Get the value of this command's qualifier of the given name.

Specified by:
getQualifier in interface JESTCommand
Returns:
null if the qualifier does not exist.

hasQualifier

public boolean hasQualifier(String key)
Description copied from interface: JESTCommand
Affirm this command contains an qualifier of the given name.

Specified by:
hasQualifier in interface JESTCommand

isBooleanQualifier

protected boolean isBooleanQualifier(String key)

getQualifiers

public Map<String,String> getQualifiers()
Description copied from interface: JESTCommand
Get this command's qualifiers.

Specified by:
getQualifiers in interface JESTCommand

parse

public void parse()
           throws ProcessingException
Parses HTTP Request for the qualifier and argument of a command.
Each servlet path segment, except the first (which is the command name itself), is a qualifier. Each qualifier can be either a key or a key-value pair separated by a = sign.
Each request parameter key-value pair is an argument. A concrete command may specify mandatory arguments (e.g. type must be mandatory argument for find command, or q for query. The mandatory arguments, if any, are not captured in the argument list.
The qualifiers and arguments are immutable after parse.

Specified by:
parse in interface JESTCommand
Throws:
ProcessingException

getMandatoryArguments

protected Collection<String> getMandatoryArguments()
Gets the mandatory arguments.

Returns:
empty list by default.

getMinimumArguments

protected int getMinimumArguments()
Gets the minimum number of arguments excluding the mandatory arguments.

Returns:
zero by default.

getMaximumArguments

protected int getMaximumArguments()
Gets the maximum number of arguments excluding the mandatory arguments.

Returns:
Integer.MAX_VALUE by default.

getDefaultFormat

protected JESTCommand.Format getDefaultFormat()

getValidQualifiers

protected Collection<String> getValidQualifiers()
Gets the valid qualifiers.

Returns:
empty list by default.

validate

protected void validate()
Called post-parse to validate this command has requisite qualifiers and arguments.


getObjectFormatter

public ObjectFormatter<?> getObjectFormatter()

toStateManager

protected OpenJPAStateManager toStateManager(Object obj)

toStateManager

protected List<OpenJPAStateManager> toStateManager(Collection<?> objects)

pushFetchPlan

protected void pushFetchPlan(Object target)

popFetchPlan

protected void popFetchPlan(boolean finder)

debug

protected void debug(HttpServletRequest request,
                     HttpServletResponse response,
                     JPAServletContext ctx)
              throws IOException
Throws:
IOException


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.