org.zkoss.web.util.resource
Class ResourceCaches

java.lang.Object
  extended by org.zkoss.web.util.resource.ResourceCaches

public class ResourceCaches
extends java.lang.Object

Utilities to load (and parse) the servlet resource.

Usage 1:

  1. Use getContent(javax.servlet.ServletContext, java.lang.String) to load the resource into a String-type content.

Usage 2:

  1. Implements a loader by extending from ResourceLoader.
  2. Creates a resource cache (ResourceCache) by use of the loader in the previous step.
  3. Invoke get(org.zkoss.util.resource.ResourceCache, javax.servlet.ServletContext, java.lang.String, java.lang.Object) to load the resource.

Usage 2 has better performance because you need to parse the content only once. Usage 1 is simple if you don't pase it into any intermediate format.

Author:
tomyeh

Constructor Summary
ResourceCaches()
           
 
Method Summary
static java.lang.Object get(ResourceCache cache, javax.servlet.ServletContext ctx, java.lang.String path, java.lang.Object extra)
          Loads, parses and returns the resource of the specified URI, or null if not found.
static java.lang.String getContent(javax.servlet.ServletContext ctx, java.lang.String path)
          Returns the content of the specified path, or null if not found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceCaches

public ResourceCaches()
Method Detail

get

public static final java.lang.Object get(ResourceCache cache,
                                         javax.servlet.ServletContext ctx,
                                         java.lang.String path,
                                         java.lang.Object extra)
Loads, parses and returns the resource of the specified URI, or null if not found. The parser is defined by the loader defined in ResourceCache.

If you don't need to parse the content, you might use getContent(javax.servlet.ServletContext, java.lang.String)

Parameters:
cache - the resource cache. Note: its loader must extend from ResourceLoader.
path - the URI path
extra - the extra parameter that will be passed to ResourceLoader.parse(String,File,Object) and ResourceLoader.parse(String,URL,Object)

getContent

public static final java.lang.String getContent(javax.servlet.ServletContext ctx,
                                                java.lang.String path)
Returns the content of the specified path, or null if not found.

The content is returned directly as a string without any parsing.

Note: the encoding is assumed to be "UTF-8".

Parameters:
path - the URI path


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo