org.utgenome.gwt.utgb.server.util
Class WebApplicationResource

java.lang.Object
  extended by org.utgenome.gwt.utgb.server.util.WebApplicationResource

public class WebApplicationResource
extends Object

Helper class to retrieve web application resources contained in webapp folders (/), /WEB-INF, etc.

Author:
leo

Constructor Summary
WebApplicationResource(javax.servlet.ServletContext context)
           
 
Method Summary
static ArrayList<String> find(javax.servlet.ServletContext context, String basePath, String fileNamePattern, boolean recursive)
          Retrieves web application resources from the ServletContext
 ArrayList<String> find(String basePath, String fileNamePattern, boolean recursive)
          Retrieves web application resources from the ServletContext
static String getContent(javax.servlet.ServletContext context, String path)
           
static File getResoruceFile(javax.servlet.ServletContext context, String path)
           
static BufferedReader openResource(javax.servlet.ServletContext context, String path)
          Gets a BufferedReader of the specified web application resource
 BufferedReader openResource(String path)
          Gets a BufferedReader of the specified web application resource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebApplicationResource

public WebApplicationResource(javax.servlet.ServletContext context)
Method Detail

find

public ArrayList<String> find(String basePath,
                              String fileNamePattern,
                              boolean recursive)
Retrieves web application resources from the ServletContext

Parameters:
basePath - the resource path, which must begin with "/". For example, "/WEB-INF", "/" etc.
fileNamePattern - the file name pattern
recursive - when true, it recursively searches sub folders
Returns:
the list of found resource paths

find

public static ArrayList<String> find(javax.servlet.ServletContext context,
                                     String basePath,
                                     String fileNamePattern,
                                     boolean recursive)
Retrieves web application resources from the ServletContext

Parameters:
context - the servlet context
basePath - the resource path, which must begin with "/". For example, "/WEB-INF", "/" etc.
fileNamePattern - the file name pattern
recursive - when true, it recursively searches sub folders
Returns:
the list of found resource paths

openResource

public static BufferedReader openResource(javax.servlet.ServletContext context,
                                          String path)
                                   throws FileNotFoundException
Gets a BufferedReader of the specified web application resource

Parameters:
context - the servlet context
path - the resource path
Returns:
a BufferedReader of the specified resource
Throws:
FileNotFoundException - when the specified resource is not found

getResoruceFile

public static File getResoruceFile(javax.servlet.ServletContext context,
                                   String path)
Parameters:
context - the servlet context
path - the resource path, which must begin with "/"
Returns:
null if the specified resource is not found

openResource

public BufferedReader openResource(String path)
                            throws FileNotFoundException
Gets a BufferedReader of the specified web application resource

Parameters:
path - the resource path
Returns:
a BufferedReader of the specified resource
Throws:
FileNotFoundException - when the specified resource is not found

getContent

public static String getContent(javax.servlet.ServletContext context,
                                String path)
                         throws IOException
Throws:
IOException


Copyright © 2007-2012 utgenome.org. All Rights Reserved.