Coverage Report - com.javaforge.bobber.archetype.model.Variable
 
Classes in this File Line Coverage Branch Coverage Complexity
Variable
0%
0/38
0%
0/14
1.643
 
 1  
 /*
 2  
  * $Id$
 3  
  */
 4  
 
 5  
 package com.javaforge.bobber.archetype.model;
 6  
 
 7  
   //---------------------------------/
 8  
  //- Imported classes and packages -/
 9  
 //---------------------------------/
 10  
 
 11  
 import java.util.Collection;
 12  
 import java.util.Date;
 13  
 
 14  
 /**
 15  
  * 
 16  
  *              Represents system variable to be put in the
 17  
  * Velocity Context
 18  
  *           .
 19  
  * 
 20  
  * @version $Revision$ $Date$
 21  
  */
 22  0
 public class Variable implements java.io.Serializable {
 23  
 
 24  
 
 25  
       //--------------------------/
 26  
      //- Class/Member Variables -/
 27  
     //--------------------------/
 28  
 
 29  
     /**
 30  
      * Field name.
 31  
      */
 32  
     private String name;
 33  
 
 34  
     /**
 35  
      * Field description.
 36  
      */
 37  
     private String description;
 38  
 
 39  
     /**
 40  
      * Field defvalue.
 41  
      */
 42  
     private String defvalue;
 43  
 
 44  
     /**
 45  
      * Field variables.
 46  
      */
 47  
     private java.util.List variables;
 48  
 
 49  
 
 50  
       //-----------/
 51  
      //- Methods -/
 52  
     //-----------/
 53  
 
 54  
     /**
 55  
      * Method addVariable.
 56  
      * 
 57  
      * @param variable
 58  
      */
 59  
     public void addVariable(Variable variable)
 60  
     {
 61  0
         if ( !(variable instanceof Variable) )
 62  
         {
 63  0
             throw new ClassCastException( "Variable.addVariables(variable) parameter must be instanceof " + Variable.class.getName() );
 64  
         }
 65  0
         getVariables().add( variable );
 66  0
         variable.createVariableAssociation( this );
 67  0
     } //-- void addVariable(Variable) 
 68  
 
 69  
     /**
 70  
      * Method breakVariableAssociation.
 71  
      * 
 72  
      * @param variable
 73  
      */
 74  
     public void breakVariableAssociation(Variable variable)
 75  
     {
 76  0
         if ( ! getVariables().contains( variable ) )
 77  
         {
 78  0
             throw new IllegalStateException( "variable isn't associated." );
 79  
         }
 80  
         
 81  0
         getVariables().remove( variable );
 82  0
     } //-- void breakVariableAssociation(Variable) 
 83  
 
 84  
     /**
 85  
      * Method createVariableAssociation.
 86  
      * 
 87  
      * @param variable
 88  
      */
 89  
     public void createVariableAssociation(Variable variable)
 90  
     {
 91  0
         Collection variables = getVariables();
 92  
         
 93  0
         if ( getVariables().contains(variable) )
 94  
         {
 95  0
             throw new IllegalStateException( "variable is already assigned." );
 96  
         }
 97  
         
 98  0
         variables.add( variable );
 99  0
     } //-- void createVariableAssociation(Variable) 
 100  
 
 101  
     /**
 102  
      * Get the defvalue field.
 103  
      * 
 104  
      * @return String
 105  
      */
 106  
     public String getDefvalue()
 107  
     {
 108  0
         return this.defvalue;
 109  
     } //-- String getDefvalue() 
 110  
 
 111  
     /**
 112  
      * Get the description field.
 113  
      * 
 114  
      * @return String
 115  
      */
 116  
     public String getDescription()
 117  
     {
 118  0
         return this.description;
 119  
     } //-- String getDescription() 
 120  
 
 121  
     /**
 122  
      * Get the name field.
 123  
      * 
 124  
      * @return String
 125  
      */
 126  
     public String getName()
 127  
     {
 128  0
         return this.name;
 129  
     } //-- String getName() 
 130  
 
 131  
     /**
 132  
      * Method getVariables.
 133  
      * 
 134  
      * @return java.util.List
 135  
      */
 136  
     public java.util.List getVariables()
 137  
     {
 138  0
         if ( this.variables == null )
 139  
         {
 140  0
             this.variables = new java.util.ArrayList();
 141  
         }
 142  
         
 143  0
         return this.variables;
 144  
     } //-- java.util.List getVariables() 
 145  
 
 146  
     /**
 147  
      * Method removeVariable.
 148  
      * 
 149  
      * @param variable
 150  
      */
 151  
     public void removeVariable(Variable variable)
 152  
     {
 153  0
         if ( !(variable instanceof Variable) )
 154  
         {
 155  0
             throw new ClassCastException( "Variable.removeVariables(variable) parameter must be instanceof " + Variable.class.getName() );
 156  
         }
 157  0
         variable.breakVariableAssociation( this );
 158  0
         getVariables().remove( variable );
 159  0
     } //-- void removeVariable(Variable) 
 160  
 
 161  
     /**
 162  
      * Set the defvalue field.
 163  
      * 
 164  
      * @param defvalue
 165  
      */
 166  
     public void setDefvalue(String defvalue)
 167  
     {
 168  0
         this.defvalue = defvalue;
 169  0
     } //-- void setDefvalue(String) 
 170  
 
 171  
     /**
 172  
      * Set the description field.
 173  
      * 
 174  
      * @param description
 175  
      */
 176  
     public void setDescription(String description)
 177  
     {
 178  0
         this.description = description;
 179  0
     } //-- void setDescription(String) 
 180  
 
 181  
     /**
 182  
      * Set the name field.
 183  
      * 
 184  
      * @param name
 185  
      */
 186  
     public void setName(String name)
 187  
     {
 188  0
         this.name = name;
 189  0
     } //-- void setName(String) 
 190  
 
 191  
     /**
 192  
      * Set 
 193  
      *             Variables that depend on their parent.
 194  
      * 
 195  
      * @param variables
 196  
      */
 197  
     public void setVariables(java.util.List variables)
 198  
     {
 199  0
         this.variables = variables;
 200  0
     } //-- void setVariables(java.util.List) 
 201  
 
 202  
 
 203  0
     private String modelEncoding = "UTF-8";
 204  
 
 205  
     /**
 206  
      * Set an encoding used for reading/writing the model.
 207  
      *
 208  
      * @param modelEncoding the encoding used when reading/writing the model.
 209  
      */
 210  
     public void setModelEncoding( String modelEncoding )
 211  
     {
 212  0
         this.modelEncoding = modelEncoding;
 213  0
     }
 214  
 
 215  
     /**
 216  
      * @return the current encoding used when reading/writing this model.
 217  
      */
 218  
     public String getModelEncoding()
 219  
     {
 220  0
         return modelEncoding;
 221  
     }
 222  
 }