0

How to pass an argument into method when is in map?

I'm trying to create excel file with dynamic values from table. In map I have some references to records in table like BOM.BOMid and I want to pass this like an argument to this function not like str:

Map  map = new Map(Types::Integer, Types::Container);
MapEnumerator en = new MapEnumerator(map); 

map.insert(1, bom.ItemId);

xlsWorkSheet.cells().item(row,column).value(<value from map>);column++;

1 Answers1

4

If you used map.insert(1, bom.ItemId); to add an element to the map, you can retrieve the value as follows:

Map map = new Map(Types::Integer, Types::String);
ItemId value;
...
if (map.exists(1))
{
    value = map.lookup(1);
}

You can also make use of MapEnumerator as follows:

//int key;
...
MapEnumerator en = map.getEnumerator();
while (enum.moveNext())
{
    //key = enum.currentKey();
    value = enum.currentValue();
    ...
}
10p
  • 5,488
  • 22
  • 30