Coverage Report - com.ccg.macros.TableField
 
Classes in this File Line Coverage Branch Coverage Complexity
TableField
0% 
0% 
4.5
 
 1  
 //----------------------------------------------------------------  
 2  
 // Helper class to process each row of a data table
 3  
 //----------------------------------------------------------------
 4  
 
 5  
 package com.ccg.macros;
 6  
 
 7  
 import java.io.IOException;
 8  
 
 9  
 import java.util.Vector;
 10  
 
 11  
 class TableField implements MacroHandler {
 12  
         private AtMacros _AtMacros;
 13  
 
 14  
         private TableInsert _Table;
 15  
 
 16  
         private String _Name;
 17  
 
 18  0
         TableField(AtMacros am, String name, TableInsert ti) {
 19  0
                 _AtMacros = am;
 20  0
                 _Table = ti;
 21  0
                 _Name = name;
 22  0
         }
 23  
 
 24  
         public void process(Output out, Vector args) throws IOException,
 25  
                         InterpretException {
 26  
 
 27  0
                 if (args.size() != 1) {
 28  0
                         throw new InterpretException("Error: @" + _Name
 29  
                                         + "(FIELD) requires " + "one argument");
 30  
                 }
 31  
 
 32  0
                 String val = args.elementAt(0).toString();
 33  0
                 int index = -1;
 34  
 
 35  0
                 if (Character.isDigit(val.charAt(0)))
 36  
                         try {
 37  0
                                 index = Integer.parseInt(val);
 38  0
                         } catch (Exception e) {
 39  0
                         }
 40  
 
 41  0
                 if (index < 0)
 42  0
                         index = _Table.getTable().getTableColumn(val);
 43  
 
 44  0
                 if (index < 0) {
 45  0
                         throw new InterpretException("Error: @" + _Name + "(" + val
 46  
                                         + ") has a " + "non-integer index specified");
 47  
                 }
 48  
 
 49  0
                 out.write(_AtMacros.interpretCheck(_Table.getTable().getFieldString(
 50  
                                 index, "")));
 51  0
         }
 52  
 
 53  
 }