Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.commons
Class GrailsResourceUtils

    java.lang.Object
      org.codehaus.groovy.grails.commons.GrailsResourceUtils

    public class GrailsResourceUtils

extends Object

Utility methods for working with Grails resources and URLs that represent artifacts within a Grails application

Since:
  0.2 Created: 20th June 2006
Author:
  Graeme Rocher

Field Summary
`static Pattern[]` | `COMPILER_ROOT_PATTERNS`
`static Pattern` | `DOMAIN_PATH_PATTERN`
`static String` | `GRAILS_APP_DIR` The name of the Grails application directory
`static Pattern` | `GRAILS_RESOURCE_PATTERN_FIFTH_MATCH`
`static Pattern` | `GRAILS_RESOURCE_PATTERN_FIRST_MATCH`
`static Pattern` | `GRAILS_RESOURCE_PATTERN_FOURTH_MATCH`
`static Pattern` | `GRAILS_RESOURCE_PATTERN_SECOND_MATCH`
`static Pattern` | `GRAILS_RESOURCE_PATTERN_SIXTH_MATCH`
`static Pattern` | `GRAILS_RESOURCE_PATTERN_THIRD_MATCH`
`static Pattern[]` | `patterns`
`static Pattern` | `RESOURCE_PATH_PATTERN`
`static Pattern` | `SPRING_SCRIPTS_PATH_PATTERN`
`static String` | `VIEWS_DIR_PATH` The path to the views directory
`static String` | `WEB_APP_DIR` The name of the Web app dir within Grails
`static String` | `WEB_INF` The relative path to the WEB-INF directory

Constructor Summary
`GrailsResourceUtils()`

Method Summary
`static Resource` | `getAppDir(Resource resource)`
`static String` | `getClassName(Resource resource)` Gets the class name of the specified Grails resource
`static String` | `getClassName(String path)` Returns the class name for a Grails resource
`static String` | `getPathFromRoot(String path)` Get the path relative to an artefact folder under grails-app i.e: Input: /usr/joe/project/grails-app/conf/BootStrap.groovy Output: BootStrap.groovy Input: /usr/joe/project/grails-app/domain/com/mystartup/Book.groovy Output: com/mystartup/Book.groovy
`static String` | `getRelativeInsideWebInf(Resource resource)` This method will take a Grails resource (one located inside the grails-app dir) and get its relative path inside the WEB-INF directory when deployed
`static String` | `getStaticResourcePathForResource(Resource resource, String contextPath)` Retrieves the static resource path for the given Grails resource artifact (controller/taglib etc.)
`static Resource` | `getViewsDir(Resource resource)`
`static boolean` | `isDomainClass(URL url)` Checks whether the file referenced by the given url is a domain class
`static boolean` | `isGrailsPath(String path)` Checks whether the specified path is a Grails path
`static boolean` | `isGrailsResource(Resource r)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WEB_INF

    public static final String WEB_INF

  The relative path to the WEB-INF directory

  See Also:
    Constant Field Values

### GRAILS_APP_DIR

    public static final String GRAILS_APP_DIR

  The name of the Grails application directory

  See Also:
    Constant Field Values

### WEB_APP_DIR

    public static final String WEB_APP_DIR

  The name of the Web app dir within Grails

  See Also:
    Constant Field Values

### VIEWS_DIR_PATH

    public static final String VIEWS_DIR_PATH

  The path to the views directory

  See Also:
    Constant Field Values

### DOMAIN_PATH_PATTERN

    public static Pattern DOMAIN_PATH_PATTERN

### RESOURCE_PATH_PATTERN

    public static Pattern RESOURCE_PATH_PATTERN

### SPRING_SCRIPTS_PATH_PATTERN

    public static Pattern SPRING_SCRIPTS_PATH_PATTERN

### COMPILER_ROOT_PATTERNS

    public static Pattern[] COMPILER_ROOT_PATTERNS

### GRAILS_RESOURCE_PATTERN_FIRST_MATCH

    public static final Pattern GRAILS_RESOURCE_PATTERN_FIRST_MATCH

### GRAILS_RESOURCE_PATTERN_SECOND_MATCH

    public static final Pattern GRAILS_RESOURCE_PATTERN_SECOND_MATCH

### GRAILS_RESOURCE_PATTERN_THIRD_MATCH

    public static final Pattern GRAILS_RESOURCE_PATTERN_THIRD_MATCH

### GRAILS_RESOURCE_PATTERN_FOURTH_MATCH

    public static final Pattern GRAILS_RESOURCE_PATTERN_FOURTH_MATCH

### GRAILS_RESOURCE_PATTERN_FIFTH_MATCH

    public static final Pattern GRAILS_RESOURCE_PATTERN_FIFTH_MATCH

### GRAILS_RESOURCE_PATTERN_SIXTH_MATCH

    public static final Pattern GRAILS_RESOURCE_PATTERN_SIXTH_MATCH

### patterns

    public static final Pattern[] patterns

Constructor Detail

### GrailsResourceUtils

    public GrailsResourceUtils()

Method Detail

### isDomainClass

    public static boolean isDomainClass(URL url)

  Checks whether the file referenced by the given url is a domain class

  Parameters:
    `url` - The URL instance
  Returns:
    True if it is a domain class

### getClassName

    public static String getClassName(Resource resource)

  Gets the class name of the specified Grails resource

  Parameters:
    `resource` - The Spring Resource
  Returns:
    The class name or null if the resource is not a Grails class

### getClassName

    public static String getClassName(String path)

  Returns the class name for a Grails resource

  Parameters:
    `path` - The path to check
  Returns:
    The class name or null if it doesn't exist

### isGrailsPath

    public static boolean isGrailsPath(String path)

  Checks whether the specified path is a Grails path

  Parameters:
    `path` - The path to check
  Returns:
    True if it is a Grails path

### isGrailsResource

    public static boolean isGrailsResource(Resource r)

### getViewsDir

    public static Resource getViewsDir(Resource resource)

### getAppDir

    public static Resource getAppDir(Resource resource)

### getRelativeInsideWebInf

    public static String getRelativeInsideWebInf(Resource resource)

  This method will take a Grails resource (one located inside the grails-app dir) and get its relative path inside the WEB-INF directory when deployed

  Parameters:
    `resource` - The Grails resource, which is a file inside the grails-app dir
  Returns:
    The relative URL of the file inside the WEB-INF dir at deployment time or null if it cannot be established

### getStaticResourcePathForResource

    public static String getStaticResourcePathForResource(Resource resource,
                                                          String contextPath)

  Retrieves the static resource path for the given Grails resource artifact (controller/taglib etc.)

  Parameters:
    `resource` - The Resource
    `contextPath` - The additonal context path to prefix
  Returns:
    The resource path

### getPathFromRoot

    public static String getPathFromRoot(String path)

  Get the path relative to an artefact folder under grails-app i.e: Input: /usr/joe/project/grails-app/conf/BootStrap.groovy Output: BootStrap.groovy Input: /usr/joe/project/grails-app/domain/com/mystartup/Book.groovy Output: com/mystartup/Book.groovy

  Parameters:
    `path` - The path to evaluate
  Returns:
    The path relative to the root folder grails-app

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2005-2006 The Grails project