PAJES 3.0.21

org.pajes.html
Class PajeResource

java.lang.Object
  extended by org.pajes.html.PajeResource

public class PajeResource
extends java.lang.Object

A PajeResource identifies a collection of resources within a ServletContext that are mapped to a path that contains a variable component.

For example, a system may implement the display of different HTML documents based upon a customer ID. If the document names are all identical, but are identified by a different path that includes the customer ID, the PajeResource would be created as follows:

 PajeResource res;
 res = new PajeResource(context, "/templates/customer/{0}/details.html");
 

See Also:
PajeFactory

Constructor Summary
PajeResource(javax.servlet.ServletContext context, java.lang.String pathPattern)
          Creates an PajeResource identifies a resource or a collection of resources within a ServletContext that are mapped to a path pattern.
 
Method Summary
 java.lang.String getPath(java.lang.String[] arguments)
          Returns the path of this PajeResource when the specified parameters have been substituted into the path pattern.
 java.lang.String getPathPattern()
          Returns the String pattern passed to the constructor.
 java.net.URL getResource(java.lang.String[] arguments)
          Returns a URL to the resource that is mapped to the path of this PajeResource when the specified parameters have been substituted into the path pattern.
 javax.servlet.ServletContext getServletContext()
          Returns the servlet context that was specifed on the constructor.
 java.lang.String toString()
          Returns a String representation of this resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PajeResource

public PajeResource(javax.servlet.ServletContext context,
                    java.lang.String pathPattern)
Creates an PajeResource identifies a resource or a collection of resources within a ServletContext that are mapped to a path pattern.

The path pattern is of the form:

 pathPattern := "/" string ( "{" variablePathElement "}" string )*
 variablePathElement := argument
 

After the variable elements are substituted into the path pattern, it will be passed to ServletContext.getResource, and therefore must commence with a "/".

The string elements of the pattern are the fixed elements of the path.

The argument is a number from 0 to 9, which corresponds to the arguments presented in an array to be substituted into the pattern.

Note that the variablePathElement is optional - a path may be defined with no variable elements, and therefore represents a single resource. in this case, it is valid to pass null as the arguments parameter to the getPath(java.lang.String[]) and getResource(java.lang.String[]) methods.

Parameters:
context - the servlet context which will be requested to return the resource after the variable elements have been substituted in.
pathPattern - the path pattern as described above.
Method Detail

getPath

public java.lang.String getPath(java.lang.String[] arguments)
Returns the path of this PajeResource when the specified parameters have been substituted into the path pattern.

Parameters:
arguments - the array of arguments that will be substituted into the path pattern to give a path.
Returns:
the String path.

getPathPattern

public java.lang.String getPathPattern()
Returns the String pattern passed to the constructor.

Returns:
the path pattern.

getResource

public java.net.URL getResource(java.lang.String[] arguments)
                         throws java.net.MalformedURLException
Returns a URL to the resource that is mapped to the path of this PajeResource when the specified parameters have been substituted into the path pattern.

If the resource begins with a "/", it is interpreted as relative to the current context root and ServletContext.getResource will be used to retrieve the URL. Otherwise the request will be passed to the ClassLoader to search its own and the system class path.

Parameters:
arguments - the array of arguments that will be substituted into the path pattern to give a path.
Returns:
the resource located at the named path, or null if there is no resource at that path.
Throws:
java.net.MalformedURLException - if the resulting path, after substituting the supplied arguments, is not in the correct form.

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns the servlet context that was specifed on the constructor.

Returns:
the ServletContext.

toString

public java.lang.String toString()
Returns a String representation of this resource.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this resource.

PAJES 3.0.21

Copyright © 1998-2007 Viridian Pty Limited. All Rights Reserved.