(EvaluateVisitor visitor, Node[] args, EvaluationManager manager)
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public Object evaluate(EvaluateVisitor visitor, Node[] args, EvaluationManager manager) |
| 144 | { |
| 145 | LoadContext context = manager.get(ManagerKey.CONTEXT); |
| 146 | AbstractReferenceContext refContext = context.getReferenceContext(); |
| 147 | DataTable dataTable = (DataTable) args[0].jjtAccept(visitor, |
| 148 | manager.getWith(EvaluationManager.ASSERTED, Optional.of(refContext.getManufacturer(DATATABLE_CLASS)))); |
| 149 | |
| 150 | FormatManager<?> lookupFormat = dataTable.getFormat(0); |
| 151 | |
| 152 | //Lookup value (format based on the table) |
| 153 | Object lookupValue = |
| 154 | args[1].jjtAccept(visitor, manager.getWith(EvaluationManager.ASSERTED, Optional.of(lookupFormat))); |
| 155 | |
| 156 | //Result Column |
| 157 | TableColumn column = (TableColumn) args[2].jjtAccept(visitor, |
| 158 | manager.getWith(EvaluationManager.ASSERTED, Optional.of(refContext.getManufacturer(COLUMN_CLASS)))); |
| 159 | |
| 160 | String columnName = column.getName(); |
| 161 | if (!dataTable.isColumn(columnName)) |
| 162 | { |
| 163 | FormatManager<?> fmt = column.getFormatManager(); |
| 164 | System.out.println("Lookup called on invalid column: '" + columnName + "' is not present on table '" |
| 165 | + dataTable.getName() + "' assuming default for " + fmt.getIdentifierType()); |
| 166 | FormulaManager fm = manager.get(EvaluationManager.FMANAGER); |
| 167 | return fm.getDefault(fmt); |
| 168 | } |
| 169 | String lookupRule = "EXACT"; |
| 170 | if (args.length == 4) |
| 171 | { |
| 172 | lookupRule = (String) args[3].jjtAccept(visitor, |
| 173 | manager.getWith(EvaluationManager.ASSERTED, Optional.of(FormatUtilities.STRING_MANAGER))); |
| 174 | } |
| 175 | LookupType lookupType = DataTable.LookupType.valueOf(lookupRule); |
| 176 | if (!dataTable.hasRow(lookupType, lookupValue)) |
| 177 | { |
| 178 | FormatManager<?> fmt = column.getFormatManager(); |
| 179 | System.out.println( |
| 180 | "Lookup called on invalid item: '" + lookupValue + "' is not present in the first row of table '" |
| 181 | + dataTable.getName() + "' assuming default for " + fmt.getIdentifierType()); |
| 182 | FormulaManager fm = manager.get(EvaluationManager.FMANAGER); |
| 183 | return fm.getDefault(fmt); |
| 184 | } |
| 185 | return dataTable.lookup(lookupType, lookupValue, columnName); |
| 186 | } |
| 187 | |
| 188 | @Override |
| 189 | public Optional<FormatManager<?>> getDependencies(DependencyVisitor visitor, DependencyManager manager, Node[] args) |
nothing calls this directly
no test coverage detected