Coverage Report - org.webmacro.directive.GlobalDirective
 
Classes in this File Line Coverage Branch Coverage Complexity
GlobalDirective
0%
0/14
0%
0/2
2.333
 
 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.engine.BuildContext;
 29  
 import org.webmacro.engine.BuildException;
 30  
 import org.webmacro.engine.Variable;
 31  
 
 32  
 import java.io.IOException;
 33  
 /**
 34  
  * Implements a directive supporting a global value.
 35  
  */
 36  0
 public class GlobalDirective extends Directive
 37  
 {
 38  
 
 39  
     private static final int GLOBAL_TARGET = 1;
 40  
 
 41  
     private static final ArgDescriptor[]
 42  0
             myArgs = new ArgDescriptor[]{
 43  
                 new LValueArg(GLOBAL_TARGET),
 44  
             };
 45  
 
 46  
     private static final DirectiveDescriptor
 47  0
             myDescr = new DirectiveDescriptor("global", null, myArgs, null);
 48  
 
 49  
     public static DirectiveDescriptor getDescriptor ()
 50  
     {
 51  0
         return myDescr;
 52  
     }
 53  
 
 54  
     public Object build (DirectiveBuilder builder,
 55  
                          BuildContext bc)
 56  
             throws BuildException
 57  
     {
 58  0
         Variable target = null;
 59  
 
 60  
         try
 61  
         {
 62  0
             target = (Variable) builder.getArg(GLOBAL_TARGET, bc);
 63  
         }
 64  0
         catch (ClassCastException e)
 65  
         {
 66  0
             throw new NotVariableBuildException(myDescr.name, e);
 67  0
         }
 68  0
         if (!target.isSimpleName())
 69  0
             throw new NotSimpleVariableBuildException(myDescr.name);
 70  
 
 71  0
         bc.setVariableType(target.getName(), Variable.LOCAL_TYPE);
 72  0
         return null;
 73  
     }
 74  
 
 75  
     public void write (FastWriter out, Context context)
 76  
             throws PropertyException, IOException
 77  
     {
 78  0
     }
 79  
 
 80  
 }