org.omnifaces.util
Class ResourcePaths

java.lang.Object
  extended by org.omnifaces.util.ResourcePaths

public final class ResourcePaths
extends java.lang.Object

Utility class for working with (Servlet) resource paths, providing methods to handle their prefixes, extensions etc.

Since:
1.4
Author:
Arjan Tijms

Method Summary
static java.util.Set<java.lang.String> filterExtension(java.util.Set<java.lang.String> resources)
          Filters away every resource in the given set that has an extension.
static java.lang.String getExtension(java.lang.String resource)
          Gets the extension of a resource if any.
static boolean isDirectory(java.lang.String resourcePath)
          Checks if the given resource path obtained from ServletContext.getResourcePaths(String) represents a directory.
static boolean isExtensionless(java.lang.String viewId)
           
static java.lang.String stripExtension(java.lang.String resource)
          Strips the extension from a resource if any.
static java.lang.String stripPrefixPath(java.lang.String prefix, java.lang.String resource)
          Strips the special 'faces-views' prefix path from the resource if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isDirectory

public static boolean isDirectory(java.lang.String resourcePath)
Checks if the given resource path obtained from ServletContext.getResourcePaths(String) represents a directory.

Parameters:
resourcePath - the resource path to check
Returns:
true if the resource path represents a directory, false otherwise

stripPrefixPath

public static java.lang.String stripPrefixPath(java.lang.String prefix,
                                               java.lang.String resource)
Strips the special 'faces-views' prefix path from the resource if any.

Parameters:
resource -
Returns:
the resource without the special prefix path, or as-is if it didn't start with this prefix.

stripExtension

public static java.lang.String stripExtension(java.lang.String resource)
Strips the extension from a resource if any. This extension is defined as everything after the last occurrence of a period, including the period itself. E.g. input "index.xhtml" will return "index".

Parameters:
resource -
Returns:
the resource without its extension, of as-is if it doesn't have an extension.

getExtension

public static java.lang.String getExtension(java.lang.String resource)
Gets the extension of a resource if any. This extension is defined as everything after the last occurrence of a period, including the period itself. E.g. input "index.xhtml" will return ".xhtml'.

Parameters:
resource -
Returns:
the extension of the resource, or null if it doesn't have an extension.

isExtensionless

public static boolean isExtensionless(java.lang.String viewId)

filterExtension

public static java.util.Set<java.lang.String> filterExtension(java.util.Set<java.lang.String> resources)
Filters away every resource in the given set that has an extension.

Parameters:
resources - A set of resources to be filtered
Returns:
A set where no resource has an extension. May be empty, but never null.