An array of IData objects


I have created a simple java service that will invoke a built-in java service “”.
I declared a DocumentList(named “date”) having “inString”, “currentPattern”, “newPattern” as fields in DocumentList.
And also another DocumentList(named “dateOut”) having “value” as a field.

Any way i developed the code and it is working properly.
And my doubt is:
“is it the correct way to create an array of IData objects and is there any better approach to do so?”
Here is my code…

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();

// date
IData[]    date = IDataUtil.getIDataArray( pipelineCursor, "date" );
int n=date.length;

IData out[] = new IData[n];// can we create IData objects like this?
String output[] =new String[n];
if ( date != null)
    for ( int i = 0; i < date.length; i++ )
                out[i] = Service.doInvoke("","dateTimeFormat", date[i]);
            }catch(Exception ex){}

for ( int i = 0; i <out.length; i++ ) 
    IDataCursor outCursor = out[i].getCursor();
    output[i] = IDataUtil.getString( outCursor, "value" );

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();

// dateOut
IData[]    dateOut = new IData[n];
for ( int i = 0; i <dateOut.length; i++ ) 
    dateOut[i] = IDataFactory.create();
    IDataCursor dateOutCursor = dateOut[i].getCursor();
    IDataUtil.put( dateOutCursor, "value", output[i] );

IDataUtil.put( pipelineCursor_1, “dateOut”, dateOut );

Thanks in advance…

I would suggest doing this with flow service. Java is not necessary for this.

I’m 100% with you. for most of the tasks using already built-in services should resolve it, and Java code SHOULD be used for very few particular things.

However for learning purposes it’s fine this kind of code :smiley: