org.webmacro.engine
Class MacroAdapter

java.lang.Object
  extended byorg.webmacro.engine.MacroAdapter
All Implemented Interfaces:
Macro, Visitable

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

Looks like a Macro, but really it's not. Wrap any object as a Macro via the createMacro method. You can use this when you have to return a Macro, but what you have is something else.


Method Summary
 void accept(TemplateVisitor v)
           
static Macro createMacro(java.lang.Object wrapMe)
          If wrapMe is not a Macro, wrap it and return it.
 java.lang.Object evaluate(Context context)
          Returns the wrapped object, context is ignored.
 java.lang.String toString()
           
 void write(FastWriter out, Context context)
          Just calls toString() and writes that, context is ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

toString

public final java.lang.String toString()

evaluate

public final java.lang.Object evaluate(Context context)
Returns the wrapped object, context is ignored.

Specified by:
evaluate in interface Macro

write

public final void write(FastWriter out,
                        Context context)
                 throws java.io.IOException
Just calls toString() and writes that, context is ignored.

Specified by:
write in interface Macro
Throws:
java.io.IOException - if we could not successfully write to out

accept

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

createMacro

public static final Macro createMacro(java.lang.Object wrapMe)
                               throws BuildException
If wrapMe is not a Macro, wrap it and return it. If it is a Macro already, just return it.

Throws:
BuildException