Access to content of cells

hello,

I´m implementing my first node in the eclipse-environment and i´ve got a bit trouble with the access to the content of the several cells...

p.ex. I have a column which contains Arrays as input-column and now i want to convert it into an ArrayList. but the method "toArrayList()" is not definded for the DataType class.

Moreover I´d like to operate with columns which contain Arrays...converting them is not possible in Java Snippet, so I switched to the eclipse environment.but now I don´t know how to access to the content of the several cells...

thanks for any advice!

Hi! First of all try the guide (there could really be more examples for developer beginners here on the homepage. I agree! When I started the guide was old and the examples didn't even work for the actual knime version....)

http://tech.knime.org/developer-guide

 

Second there are lots of examples in your created project. Navigate to Plug-in dependencies -> knime-base and you'll find all the implementations for the knime nodes. Its nice to look how it was done in nodes that do almost the same! To view the sources you have to download the knime-core sources plugin (in Eclipse Help-> install new Software -> configure KNIME update site ...Sources -> Sources for KNIME Core

as you want to deal with arrays take a look at the code from a node that deals with arrays. I am not quite sure there is a datatype for arrays. You may can use StringValue and seperate by ; or , ...

 

 

Third I have an example for you how to get a value in the table:

As your execute method started you can get the data by:

 

CloseableRowIterator tableIterator = inData[0].iterator();

//you got the iterator, now you can iterate over the rows...

int index= inData[0].getDataTableSpec().findColumnIndex(m_colName.getColumnName());

//you got the index, now you can get the right column from your actual row

//the column name you may have set in the configuration dialog

String actualCell = tableIterator.next().getCell(index).toString();

//the first row ... do this in a loop if you want to handle all rows

actualValue = Double.valueOf(actualCell ).doubleValue();

// get a special column value

...

it's not too easy to handle the knime datatable structure.

 

Keep me informed =)

Cheers

hey!

first of all thank you for that extensive reply!

it will be anyway a usefull hint to view the implementations for the knime nodes that already exist! (I already was searching for how to view the implementations, but I didn´t find,so thanks;))

at the first impression they seem a bit complicated, but as I see they contain one principle (the execute- and the configure-function, the BufferedDataContainer container, the CloseableRowIterator....)

my task is finally to create a node, that is able to choose elements from a string-array and to remove them (so I would need an ArrayList adtually).

but as a DataCell only has a DataType I have to create a new type in a knime-node (accoring to some descriptions)... therefore I was looking at

http://tech.knime.org/docs/api/org/knime/core/data/doc-files/newtypes.html#newtypes

there obviously already exist Types like ListCells

http://tech.knime.org/docs/api/org/knime/core/data/DataValue.html

but until now I didn´t come to terms with the descriptions...

so thats my information until now =)

thank you for the hints!

cheers

"my task is finally to create a node, that is able to choose elements from a string-array and to remove them (so I would need an ArrayList adtually)."

 

hm maybe you can just use the reference row filter (option exclude).

check that out. You can filter out elements from table 1 referenced in table 2...

As it does not all you want to do, you can still use this node as a basis and implement some new things.

"You can filter out elements from table 1 referenced in table 2..."

yes, this could work. As I firstly want to choose a row randomly and secondly I want to choose an element from always the same column of the choosen row (also randomly), which type is an Array, this method may function for  the first step:) I could create a reference-table which contains the randomly choosen rows. the second step should also be feasible by using the java snippet. the problem here is, that I have to repeat these two steps for many times (p.e. 300 times)...

this is why I tried to realize this in the eclipse-environment by creating only one custom node to address this two steps (thaks therefore for the hints). I even could finalize these two steps but at least I got a problem with the DataType class which is needed to create a cell... I still don´t know how to implement a cell (or a column) which can contain an array of some type...??? I tried to convert my resulting array to an Object firstly and then into a DataType, but that leads to errors when testing the node...

It would also be helpful to know how to select/to get access to a cell of a specific row using the javasnippet (p.e. by using indices or whatever)

but firstly I will check out the reference row filter now. any try could help:)

cheers!