Coverage Report - org.webmacro.engine.GlobalVariable
 
Classes in this File Line Coverage Branch Coverage Complexity
GlobalVariable
0%
0/7
0%
0/4
1.75
 
 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  
 
 24  
 package org.webmacro.engine;
 25  
 
 26  
 import org.webmacro.Context;
 27  
 import org.webmacro.PropertyException;
 28  
 
 29  
 
 30  
 /**
 31  
  * Operate on bean properties in a context
 32  
  */
 33  
 final class GlobalVariable extends Variable
 34  
 {
 35  
 
 36  
     /**
 37  
      * No special initialization
 38  
      */
 39  
     GlobalVariable (Object names[])
 40  
     {
 41  0
         super(names);
 42  0
     }
 43  
 
 44  
     /**
 45  
      * Look up my value in the corresponding Map, possibly using introspection,
 46  
      * and return it
 47  
      * @exception PropertyException If the property does not exist
 48  
      */
 49  
     public final Object getValue (Context context)
 50  
             throws PropertyException
 51  
     {
 52  0
         return context.getProperty(_names);
 53  
     }
 54  
 
 55  
     /**
 56  
      * Look up my the value of this variable in the specified Map, possibly
 57  
      * using introspection, and set it to the supplied value.
 58  
      * @exception PropertyException If the property does not exist
 59  
      */
 60  
     public final void setValue (Context context, Object newValue)
 61  
             throws PropertyException
 62  
     {
 63  
 
 64  0
         if (!context.set(_names, newValue))
 65  
         {
 66  0
             throw new PropertyException("No method to set \"" + getVariableName() +
 67  
                     "\" to type " +
 68  
                     ((newValue == null) ? "null" : newValue.getClass().toString())
 69  
                     + " in supplied context (" + context.getClass() + ")");
 70  
         }
 71  0
     }
 72  
 
 73  
     /**
 74  
      * Return a string representation naming the variable for
 75  
      * debugging purposes.
 76  
      */
 77  
     public final String toString ()
 78  
     {
 79  0
         return "global:" + getVariableName();
 80  
     }
 81  
 
 82  
 }