org.webmacro.engine
Class Block

java.lang.Object
  |
  +--org.webmacro.engine.Block
All Implemented Interfaces:
Macro, Visitable

public final class Block
extends java.lang.Object
implements Macro, Visitable

A Block is essentially a Macro[] that knows how to write itself out as a String.


Constructor Summary
protected Block(java.lang.String name, java.lang.String[] strings, Macro[] macros, int[] lineNos, int[] colNos)
          A Block must be constructed from a BlockBuilder.
 
Method Summary
 void accept(TemplateVisitor v)
           
 java.lang.Object evaluate(Context context)
          same as out but returns a String
 BlockBuilder.BlockIterator getBlockIterator()
           
 int getColNo(int i)
           
 int getLineNo(int i)
           
 java.lang.String getTemplateName()
           
 void write(FastWriter out, Context context)
          Interpret the directive and write it out, using the values in the supplied context as appropriate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Block

protected Block(java.lang.String name,
                java.lang.String[] strings,
                Macro[] macros,
                int[] lineNos,
                int[] colNos)
A Block must be constructed from a BlockBuilder. The format of a block is: String (Macro String)* and the constructor expects to receive two arrays matching this structure. The output of the block will be the first string, followed by the first macro, followed by the second string, followed by the second macro, etc., and terminated by the final string.
Method Detail

write

public final void write(FastWriter out,
                        Context context)
                 throws PropertyException,
                        java.io.IOException
Interpret the directive and write it out, using the values in the supplied context as appropriate.

Specified by:
write in interface Macro
Throws:
PropertyException - if required data was missing from context
java.io.IOException - if we could not successfully write to out

getTemplateName

public java.lang.String getTemplateName()

getLineNo

public int getLineNo(int i)

getColNo

public int getColNo(int i)

getBlockIterator

public BlockBuilder.BlockIterator getBlockIterator()

accept

public final void accept(TemplateVisitor v)
Specified by:
accept in interface Visitable

evaluate

public final java.lang.Object evaluate(Context context)
                                throws PropertyException
same as out but returns a String

Specified by:
evaluate in interface Macro
Throws:
PropertyException - if required data was missing from context