##### Coverage Report - org.webmacro.engine.MacroBuilder

Classes in this File | Line Coverage | Branch Coverage | Complexity
MacroBuilder |
0% | 0/12
0% | 0/4
| 3.0;3

1 |  |
     /*
2 |  |
      * Copyright (C) 1998-2001 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 |  |
24 |  |
     package org.webmacro.engine;
25 |  |
26 |  |
27 |  |
     /**
28 |  |
      * MacroBuilder.java
29 |  |
      *
30 |  |
      * Represents the invocation of a (C-style) macro, which gets expanded
31 |  |
      * during the building of a template.  Not to be confused with Macro
32 |  |
      * as used by WebMacro, which is something else.
33 |  |
      *
34 |  |
      * @author Brian Goetz
35 |  |
      */
36 |  |
37 |  |
     public class MacroBuilder implements Builder
38 |  |
     {
39 |  |
40 |  |
         private String name;
41 |  |
         private ListBuilder argsBuilder;
42 |  |
         //private int lineNo, colNo;
43 |  |
         //private String[] nullArgs = new String[0];
44 |  |
45 |  |
         public MacroBuilder (String name,
46 |  |
                              ListBuilder argsBuilder,
47 |  |
                              int lineNo, int colNo)
48 | 0 |
         {
49 | 0 |
             this.name = name;
50 | 0 |
             this.argsBuilder = argsBuilder;
51 |  |
             //this.lineNo = lineNo;
52 |  |
             //this.colNo = colNo;
53 | 0 |
         }
54 |  |
55 |  |
         /**
56 |  |
          * Expand the macro.  Gets the macro definition from the build context.
57 |  |
          */
58 |  |
         public Object build (BuildContext bc) throws BuildException
59 |  |
         {
60 | 0 |
             MacroDefinition md = bc.getMacro(name);
61 | 0 |
             if (md == null)
62 |  |
             {
63 | 0 |
                 boolean relax = bc.getBroker().getBooleanSetting("RelaxedDirectiveBuilding");
64 | 0 |
                 if (relax)
65 | 0 |
                     return "#" + name + " ";
66 |  |
                 else
67 | 0 |
                     throw new BuildException("#" + name + ": no such Macro or Directive");
68 |  |
             }
69 | 0 |
             Object[] args = argsBuilder.buildAsArray(bc);
70 | 0 |
             return md.expand(args, bc);
71 |  |
         }
72 |  |
     }
73 |  |