com.sun.rave.web.ui.util
Class IncludeInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.sun.rave.web.ui.util.IncludeInputStream
All Implemented Interfaces:
java.io.Closeable

public class IncludeInputStream
extends java.io.FilterInputStream

This InputStream looks for lines beginning with "#include 'filename'" where filename is the name of a file to include. It replaces the "#include" line with contents of the specified file. Any other line beginning with '#' is illegal.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
IncludeInputStream(java.io.InputStream input)
           Constructor.
 
Method Summary
 int available()
           
protected  java.lang.String convertRelativePath(java.lang.String filename)
           This method converts a context-root relative path to the actual path using the ServletContext or PortletContext.
static void main(java.lang.String[] args)
           Simple test case (requires a test file).
 boolean markSupported()
           
 int read()
           This overriden method implements the include feature.
 int read(byte[] bytes, int off, int len)
           
 
Methods inherited from class java.io.FilterInputStream
close, mark, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IncludeInputStream

public IncludeInputStream(java.io.InputStream input)

Constructor.

Method Detail

read

public int read()
         throws java.io.IOException

This overriden method implements the include feature.

Overrides:
read in class java.io.FilterInputStream
Returns:
The next character.
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.FilterInputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.FilterInputStream

read

public int read(byte[] bytes,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

convertRelativePath

protected java.lang.String convertRelativePath(java.lang.String filename)

This method converts a context-root relative path to the actual path using the ServletContext or PortletContext. This requires the application to be running in a Servlet or Portlet environment... and further requires that it be running in JSF environment (which is used to access the Servlet or Portlet Context).

Parameters:
filename - The relative filename to convert to a full path.
Returns:
The full path based on the app's context root.

main

public static void main(java.lang.String[] args)

Simple test case (requires a test file).