| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |   | 
  | 17 |  |   | 
  | 18 |  |   | 
  | 19 |  |   | 
  | 20 |  |   | 
  | 21 |  |   | 
  | 22 |  |   | 
  | 23 |  |  package org.webmacro.directive; | 
  | 24 |  |   | 
  | 25 |  |  import org.webmacro.Context; | 
  | 26 |  |  import org.webmacro.FastWriter; | 
  | 27 |  |  import org.webmacro.PropertyException; | 
  | 28 |  |  import org.webmacro.TemplateVisitor; | 
  | 29 |  |  import org.webmacro.engine.Block; | 
  | 30 |  |  import org.webmacro.engine.BuildContext; | 
  | 31 |  |  import org.webmacro.engine.BuildException; | 
  | 32 |  |   | 
  | 33 |  |  import java.io.IOException; | 
  | 34 |  |   | 
  | 35 |  |   | 
  | 36 |  |   | 
  | 37 |  |   | 
  | 38 | 126 |  public class TextDirective extends Directive | 
  | 39 |  |  { | 
  | 40 |  |   | 
  | 41 |  |      private static final int TEXT_BLOCK = 1; | 
  | 42 |  |   | 
  | 43 |  |      private Block block; | 
  | 44 |  |   | 
  | 45 |  |      private static final ArgDescriptor[] | 
  | 46 | 40 |              myArgs = new ArgDescriptor[]{ | 
  | 47 |  |                  new LiteralBlockArg(TEXT_BLOCK) | 
  | 48 |  |              }; | 
  | 49 |  |   | 
  | 50 |  |      private static final DirectiveDescriptor | 
  | 51 | 40 |              myDescr = new DirectiveDescriptor("text", null, myArgs, null); | 
  | 52 |  |   | 
  | 53 |  |      public static DirectiveDescriptor getDescriptor () | 
  | 54 |  |      { | 
  | 55 | 63 |          return myDescr; | 
  | 56 |  |      } | 
  | 57 |  |   | 
  | 58 |  |      public Object build (DirectiveBuilder builder, | 
  | 59 |  |                           BuildContext bc) | 
  | 60 |  |              throws BuildException | 
  | 61 |  |      { | 
  | 62 | 126 |          block = (Block) builder.getArg(TEXT_BLOCK, bc); | 
  | 63 | 126 |          return this; | 
  | 64 |  |      } | 
  | 65 |  |   | 
  | 66 |  |      public void write (FastWriter out, Context context) | 
  | 67 |  |              throws PropertyException, IOException | 
  | 68 |  |      { | 
  | 69 | 126 |          block.write(out, context); | 
  | 70 | 126 |      } | 
  | 71 |  |   | 
  | 72 |  |      public void accept (TemplateVisitor v) | 
  | 73 |  |      { | 
  | 74 | 0 |          v.beginDirective(myDescr.name); | 
  | 75 | 0 |          block.accept(v); | 
  | 76 | 0 |          v.endDirective(); | 
  | 77 | 0 |      } | 
  | 78 |  |   | 
  | 79 |  |  } |