ro.isdc.wro.model.group
Class DefaultGroupExtractor

java.lang.Object
  extended by ro.isdc.wro.model.group.DefaultGroupExtractor
All Implemented Interfaces:
GroupExtractor

public class DefaultGroupExtractor
extends Object
implements GroupExtractor

Default implementation capable of extracting a single group from the request.

Author:
Alex Objelean

Field Summary
static String ATTR_INCLUDE_PATH
          The name of the attribute where the servlet path is stored when requestDispatcher.include is called.
static String PARAM_MINIMIZE
          The name of the parameter used to decide if the group must be minimized.
 
Constructor Summary
DefaultGroupExtractor()
           
 
Method Summary
 String encodeGroupUrl(String groupName, ResourceType resourceType, boolean minimize)
          This method is a opposite of the other 3 methods.
 String getGroupName(javax.servlet.http.HttpServletRequest request)
          Retrieves a set of group names from supplied uri.
 ResourceType getResourceType(javax.servlet.http.HttpServletRequest request)
          Extracts the resource type, by parsing the uri & finds the extension.
 boolean isMinimized(javax.servlet.http.HttpServletRequest request)
          The minimization is can be switched off only in debug mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_INCLUDE_PATH

public static final String ATTR_INCLUDE_PATH
The name of the attribute where the servlet path is stored when requestDispatcher.include is called.

See Also:
Constant Field Values

PARAM_MINIMIZE

public static final String PARAM_MINIMIZE
The name of the parameter used to decide if the group must be minimized.

See Also:
Constant Field Values
Constructor Detail

DefaultGroupExtractor

public DefaultGroupExtractor()
Method Detail

getGroupName

public String getGroupName(javax.servlet.http.HttpServletRequest request)
Retrieves a set of group names from supplied uri.

Specified by:
getGroupName in interface GroupExtractor
Parameters:
request - to check.
Returns:
found group name. If no group is found, null is returned.

getResourceType

public ResourceType getResourceType(javax.servlet.http.HttpServletRequest request)
Extracts the resource type, by parsing the uri & finds the extension. If extension is valid ('css' or 'js'), returns corresponding ResourceType, otherwise throws exception.

Valid examples of uri are: /context/somePath/test.js or /context/somePath/test.css

Specified by:
getResourceType in interface GroupExtractor
Parameters:
request - to check.
Returns:
requested ResourceType.

encodeGroupUrl

public String encodeGroupUrl(String groupName,
                             ResourceType resourceType,
                             boolean minimize)
This method is a opposite of the other 3 methods. Instead of decoding, it encodes groupName, resourceType and minimize option into url. It should not return entire url, but only the last part.

Specified by:
encodeGroupUrl in interface GroupExtractor
Returns:
a part of the url path which encodes the groupName, resourceType and minimize option.

isMinimized

public boolean isMinimized(javax.servlet.http.HttpServletRequest request)
The minimization is can be switched off only in debug mode.

Specified by:
isMinimized in interface GroupExtractor
Parameters:
request - HttpServletRequest object.
Returns:
false if the request contains parameter PARAM_MINIMIZE with value false, otherwise returns true.


Copyright © 2008-2013. All Rights Reserved.