##### Coverage Report - org.webmacro.directive.TextDirective

Classes in this File | Line Coverage | Branch Coverage | Complexity
TextDirective |
25% | 3/12
N/A | N/A
| 1.0;1

1 |  |
     /*
2 |  |
      * Copyright (C) 1998-2000 Semiotek Inc.  All Rights Reserved.
3 |  |
      *
4 |  |
      * Redistribution and use in source and binary forms, with or without
5 |  |
      * modification, are permitted under the terms of either of the following
6 |  |
      * Open Source licenses:
7 |  |
      *
8 |  |
      * The GNU General Public License, version 2, or any later version, as
9 |  |
      * published by the Free Software Foundation
10 |  |
      * (http://www.fsf.org/copyleft/gpl.html);
11 |  |
      *
12 |  |
      *  or
13 |  |
      *
14 |  |
      * The Semiotek Public License (http://webmacro.org/LICENSE.)
15 |  |
      *
16 |  |
      * This software is provided "as is", with NO WARRANTY, not even the
17 |  |
      * implied warranties of fitness to purpose, or merchantability. You
18 |  |
      * assume all risks and liabilities associated with its use.
19 |  |
      *
20 |  |
      * See www.webmacro.org for more information on the WebMacro project.
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 |  |
      * Implements the treatment of a
36 |  |
      * block as text not subject to evaluation.
37 |  |
      */
38 | 0 |
     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 | 2 |
                 myArgs = new ArgDescriptor[]{
47 |  |
                     new LiteralBlockArg(TEXT_BLOCK)
48 |  |
                 };
49 |  |
50 |  |
         private static final DirectiveDescriptor
51 | 2 |
                 myDescr = new DirectiveDescriptor("text", null, myArgs, null);
52 |  |
53 |  |
         public static DirectiveDescriptor getDescriptor ()
54 |  |
         {
55 | 6 |
             return myDescr;
56 |  |
         }
57 |  |
58 |  |
         public Object build (DirectiveBuilder builder,
59 |  |
                              BuildContext bc)
60 |  |
                 throws BuildException
61 |  |
         {
62 | 0 |
             block = (Block) builder.getArg(TEXT_BLOCK, bc);
63 | 0 |
             return this;
64 |  |
         }
65 |  |
66 |  |
         public void write (FastWriter out, Context context)
67 |  |
                 throws PropertyException, IOException
68 |  |
         {
69 | 0 |
             block.write(out, context);
70 | 0 |
         }
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 |  |
     }