All Packages  This Package  Class Hierarchy  Class Search  Index

Class kh.util.StreamReplacement
java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----java.util.Hashtable
                   |
                   +----kh.util.StreamReplacement

  Summary

public class  StreamReplacement
     extends java.util.Hashtable
{
          // Constructors 1
     public StreamReplacement();

          // Methods 4
     public void addToken(String, Object);
     public int apply(InputStream, OutputStream) throws IOException;
     public int apply(URL, OutputStream) throws IOException;
     public void setDefault(Object);
}

This engine passes an input stream through to an output stream, providing token replacement for a list of $$prefix values. Example usage:

    	StreamReplacement r = new StreamReplacement();
		r.addToken("user", "kevin");
		r.apply(new URL("file:fish.html"),
		        System.out);
	




  Constructors

· StreamReplacement

Summary  |  Top

   public StreamReplacement() 

Default constructor



  Methods

· addToken

Summary  |  Top
   public void addToken(String token, 
                        Object value) 

Adds a token which is a canidate for replacement.

Parameter Description
token the key (without the $$prefix)
value any object which supports the toString method



· apply

Summary  |  Top
   public int apply(InputStream instream, 
                    OutputStream outstream)  throws IOException

Does the actual replacement on a stream

Parameter Description
instream the input
outstream the output

Returns:
the number of replacements performed
Throws: IOException
if there's barfing


· apply

Summary  |  Top
   public int apply(URL inurl, 
                    OutputStream outstream)  throws IOException

Since this class is mostly used for web page token replacement, we provide a version of apply which sprays a given URL through the replacer and sends it to the output stream.

See Also: apply



· setDefault

Summary  |  Top
   public void setDefault(Object value) 

Sets the value which is substituted for undefined tokens. The default is "Undefined".



All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7