Search code examples
javapentaho

Peeking the next row


I want to delete some tags out of my xml with help of PDI. I only need 1 mime of each type per Product. I thought I can write a User Defined Java Class for it, but I need to peek the next row when I'm at the first node. My xml looks like this:

<MIME_INFO>
                <MIME>
                    <MIME_TYPE>image/tiff</MIME_TYPE>
                    <MIME_SOURCE>P_I202_XX_06499E600600.TIF</MIME_SOURCE>
                    <MIME_PURPOSE>detail</MIME_PURPOSE>
                </MIME>
                <MIME>
                    <MIME_TYPE>image/jpeg</MIME_TYPE>
                    <MIME_SOURCE>P_I202_XX_06499I300300.JPG</MIME_SOURCE>
                    <MIME_PURPOSE>normal</MIME_PURPOSE>
                </MIME>
                <MIME>
                    <MIME_TYPE>image/jpeg</MIME_TYPE>
                    <MIME_SOURCE>P_I202_XX_00482I300300.JPG</MIME_SOURCE>
                    <MIME_PURPOSE>normal</MIME_PURPOSE>
                </MIME>
            </MIME_INFO> 

I process the rows line by line with the main UDJC function, but when I'm at the row I have to know the type of the mime to know if I have to skip it or not. How can I peek on the next row? Something like getNextRow() or getRow(1).


Solution

  • I found the solution... just had to call the getRow once more, but to store the first row in a temp variable. Then after finding out what was in the second row, I could decide if I wanted to process the first row or not (if my line contained a MIME node, i processed 2 rows in one step).