com.scooterframework.web.route
Class Resource

java.lang.Object
  extended by com.scooterframework.web.route.Resource

public class Resource
extends java.lang.Object

Resource class


Field Summary
protected  java.lang.String actionAlias
           
protected  java.lang.String add
           
protected  java.lang.String collection
           
protected  java.lang.String controller
           
protected  java.lang.String controllerClass
           
protected  java.lang.String except
           
protected  java.lang.String member
           
protected  java.lang.String name
           
protected  java.lang.String namespace
           
protected  java.lang.String only
           
protected  java.lang.String parents
           
protected  java.lang.String pathAlias
           
protected  java.lang.String pathPrefix
           
static int PLURAL
          Constant which indicates that this is a plural resource.
protected  java.lang.String requirements
           
static int SINGLE
          Constant which indicates that this is a single resource.
protected  java.lang.String singular
           
protected  int type
           
 
Constructor Summary
Resource(java.lang.String name, boolean noRoutes)
          Creates a resource instance, but uses noRoute parameter to indicate if routes of the resource are allowed to be created.
Resource(java.lang.String name, int type)
          Creates a resource instance of either single or plural type.
Resource(java.lang.String name, int type, java.util.Properties p)
          Creates a resource instance of either single or plural type with a specific property p.
 
Method Summary
protected  void createRoutes()
           
 java.lang.String getActionAlias()
           
 java.lang.String getAdd()
           
 java.lang.String getCollection()
           
 java.lang.String getController()
           
 java.lang.String getControllerClass()
           
 java.lang.String getExcept()
           
 java.lang.String getMember()
           
 java.lang.String getModel()
           
 java.lang.String getName()
           
 java.lang.String getNamespace()
           
static java.lang.String getNesteeIdFormat(Resource resource)
          Returns a format string for resource id.
 java.lang.String getOnly()
           
 java.lang.String getParents()
           
 java.lang.String getPathAlias()
           
 java.lang.String getPathPrefix()
           
 java.lang.String getRequirements()
           
 RestRoute getRestRoute(java.lang.String action, java.lang.String target)
          Returns a rest route of the underlying resource.
 java.util.List<RestRoute> getRoutes()
           
 java.lang.String getScreenURL(java.util.Map<java.lang.String,java.lang.String> fieldValues)
          Returns url string.
 java.lang.String getScreenURLPattern()
           
 java.lang.String getSingular()
           
 int getType()
           
 java.lang.String getUnprifixedURL()
           
 boolean isSingle()
           
 boolean isStrictParent()
           
protected  void populateProperties(java.util.Properties p)
           
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLURAL

public static final int PLURAL
Constant which indicates that this is a plural resource.

See Also:
Constant Field Values

SINGLE

public static final int SINGLE
Constant which indicates that this is a single resource.

See Also:
Constant Field Values

name

protected java.lang.String name

type

protected int type

controller

protected java.lang.String controller

controllerClass

protected java.lang.String controllerClass

singular

protected java.lang.String singular

namespace

protected java.lang.String namespace

pathPrefix

protected java.lang.String pathPrefix

pathAlias

protected java.lang.String pathAlias

actionAlias

protected java.lang.String actionAlias

only

protected java.lang.String only

except

protected java.lang.String except

member

protected java.lang.String member

collection

protected java.lang.String collection

add

protected java.lang.String add

requirements

protected java.lang.String requirements

parents

protected java.lang.String parents
Constructor Detail

Resource

public Resource(java.lang.String name,
                int type)
Creates a resource instance of either single or plural type.

Parameters:
name - Name of the resource
type - Either SINGLE or PLURAL

Resource

public Resource(java.lang.String name,
                boolean noRoutes)
Creates a resource instance, but uses noRoute parameter to indicate if routes of the resource are allowed to be created.

Parameters:
name - Name of the resource
noRoutes - True if no routes are allowed to create

Resource

public Resource(java.lang.String name,
                int type,
                java.util.Properties p)
Creates a resource instance of either single or plural type with a specific property p.

Parameters:
name - Name of the resource
type - Either SINGLE or PLURAL
p - properties of the resource
Method Detail

getName

public java.lang.String getName()

getType

public int getType()

isSingle

public boolean isSingle()

getController

public java.lang.String getController()

getControllerClass

public java.lang.String getControllerClass()

getSingular

public java.lang.String getSingular()

getNamespace

public java.lang.String getNamespace()

getPathPrefix

public java.lang.String getPathPrefix()

getPathAlias

public java.lang.String getPathAlias()

getUnprifixedURL

public java.lang.String getUnprifixedURL()

getScreenURLPattern

public java.lang.String getScreenURLPattern()

getScreenURL

public java.lang.String getScreenURL(java.util.Map<java.lang.String,java.lang.String> fieldValues)
Returns url string.

Parameters:
fieldValues - name/value pairs to be used to resolve dynamic url.
Returns:
a url

getActionAlias

public java.lang.String getActionAlias()

getOnly

public java.lang.String getOnly()

getExcept

public java.lang.String getExcept()

getMember

public java.lang.String getMember()

getCollection

public java.lang.String getCollection()

getAdd

public java.lang.String getAdd()

getRequirements

public java.lang.String getRequirements()

getParents

public java.lang.String getParents()

isStrictParent

public boolean isStrictParent()

getModel

public java.lang.String getModel()

getRoutes

public java.util.List<RestRoute> getRoutes()

getRestRoute

public RestRoute getRestRoute(java.lang.String action,
                              java.lang.String target)
Returns a rest route of the underlying resource. The target must a model name if a member route is desired, or a resource name if a collection route is wanted.

Parameters:
action - action name
target - target name
Returns:
resource

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
String

getNesteeIdFormat

public static java.lang.String getNesteeIdFormat(Resource resource)
Returns a format string for resource id. For example, for a resource named "users", the resource id is "user_id";

Parameters:
resource - a resource
Returns:
a format string for resource id

populateProperties

protected void populateProperties(java.util.Properties p)

createRoutes

protected void createRoutes()