bpp
Class BPPFilter

java.lang.Object
  extended bybpp.StageFilter
      extended bybpp.BPPFilter
All Implemented Interfaces:
Filter

public class BPPFilter
extends StageFilter

This is the specific StageFilter for beanshell.

This is a self-deepening filter to recursively preprocess multiple stages of a BPP source file. Such a filter is configured and used by BPP to filter files.

This is a USE ONCE FILTER. The pattern of use is:

In particular, is is quite possible to create a deadlock by attempting to configure the filter after it begins to filter a stream.



The Beanshell Preprocessor
Copyright (C) 2003-2004 Warren D. MacEvoy jr.


Field Summary
static int DEFAULT_MAX_LINE_LENGTH
           
 
Fields inherited from class bpp.StageFilter
lineNumber, maxLineLength, stage
 
Constructor Summary
BPPFilter()
          Use DEFAULT_MAX_LINE_LENGTH for the maximum line length.
BPPFilter(int _maxLineLength)
          This allows for any maximum line length.
 
Method Summary
 java.lang.String[] getArgs()
           
 java.net.URL[] getClassPath()
           
 java.lang.String getDestination()
           
 java.io.PrintStream getErr()
          get the error stream for spawned interpreters (null for default)
 int getLineStage(java.lang.String line)
          Parse line and determine which stage should be in place to interpret it.
 int getMinStage()
           
 bsh.NameSpace getNameSpace()
          get the namespace for spawned interpreters (null for default)
 bsh.Interpreter getParent()
          get the parent for spawned interpreters (null for default)
 java.lang.String getSource()
           
 Filter getStageFilter()
          Produce filter appropriate for a given stage.
 java.util.Map getStageMap()
           
 void setArgs(java.lang.String[] _args)
          Convenience method.
 void setClassPath(java.net.URL[] _classPath)
           
 void setDestination(java.lang.String _destination)
          Convenience method.
 void setErr(java.io.PrintStream _err)
          set the error stream for spawned interpreters (null for default)
 void setMinStage(int _minStage)
          Skip later preprocessing stages.
 void setModeExact()
          Lines that do not begin with a pound(#), quote, (') or double quote("), are subject to some default translation.
 void setModeMagic()
          Lines that do not begin with a pound(#), quote, (') or double quote("), are subject to some default translation.
 void setNameSpace(bsh.NameSpace _nameSpace)
          set the namespace for spawned interpreters (null for default)
 void setParent(bsh.Interpreter _parent)
          set the parent for spawned interpreters (null for default)
 void setSource(java.lang.String _source)
          When new stages are forked, this is the source name given to the beanshell interpreter, with [ depth ] appended, so errors can be conveniently identified.
 void setStageMap(java.util.Map _stageMap)
           
 
Methods inherited from class bpp.StageFilter
filter, getLineNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_LINE_LENGTH

public static final int DEFAULT_MAX_LINE_LENGTH
See Also:
Constant Field Values
Constructor Detail

BPPFilter

public BPPFilter()
Use DEFAULT_MAX_LINE_LENGTH for the maximum line length. This parameter is needed because of the dynamic staging: at any point in processing the stream, the filter may decide to back up one line, introduce a new level of preprocessing, and proceed from that point.


BPPFilter

public BPPFilter(int _maxLineLength)
This allows for any maximum line length.

Method Detail

getErr

public java.io.PrintStream getErr()
get the error stream for spawned interpreters (null for default)


setErr

public void setErr(java.io.PrintStream _err)
set the error stream for spawned interpreters (null for default)


getNameSpace

public bsh.NameSpace getNameSpace()
get the namespace for spawned interpreters (null for default)


setNameSpace

public void setNameSpace(bsh.NameSpace _nameSpace)
set the namespace for spawned interpreters (null for default)


getParent

public bsh.Interpreter getParent()
get the parent for spawned interpreters (null for default)


setParent

public void setParent(bsh.Interpreter _parent)
set the parent for spawned interpreters (null for default)


setSource

public void setSource(java.lang.String _source)
When new stages are forked, this is the source name given to the beanshell interpreter, with [ depth ] appended, so errors can be conveniently identified. Undecorated source name is available as BPP.source in all stages of the preprocessor.


getSource

public java.lang.String getSource()

setDestination

public void setDestination(java.lang.String _destination)
Convenience method. Destination is available as BPP.destination in all stages of the preprocessor.


getDestination

public java.lang.String getDestination()

setArgs

public void setArgs(java.lang.String[] _args)
Convenience method. Args are available as BPP.args in all stages of the processor.


getArgs

public java.lang.String[] getArgs()

setClassPath

public void setClassPath(java.net.URL[] _classPath)

getClassPath

public java.net.URL[] getClassPath()

setMinStage

public void setMinStage(int _minStage)

Skip later preprocessing stages.

The normal stages generated by the preprocessor are:

nn
stage1234...
stage#interpreter#decorator##interpreter##decorator...
Setting MinStage to some value other than the default (of zero), forces stages below the MinStage to be replaced by identity filters (that do no transformation to the input). Thus, for example, to see the output of the ##decorator, use setMinStage(4). To see the output of running the ##decorated code from running it through the ##interpreter, use setMinStage(3).


getMinStage

public int getMinStage()

getStageMap

public java.util.Map getStageMap()

setStageMap

public void setStageMap(java.util.Map _stageMap)

setModeExact

public void setModeExact()
Lines that do not begin with a pound(#), quote, (') or double quote("), are subject to some default translation. This sets up exact translation by default.


setModeMagic

public void setModeMagic()
Lines that do not begin with a pound(#), quote, (') or double quote("), are subject to some default translation. This sets up magic translation by default.


getLineStage

public int getLineStage(java.lang.String line)
Parse line and determine which stage should be in place to interpret it. Normally internal use only.

Specified by:
getLineStage in class StageFilter

getStageFilter

public Filter getStageFilter()
Produce filter appropriate for a given stage.

Specified by:
getStageFilter in class StageFilter