Hi
I have created a simple java service that will invoke a built-in java service “pub.date.dateTimeFormat”.
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++ )
{
try{
out[i] = Service.doInvoke("pub.date","dateTimeFormat", date[i]);
}catch(Exception ex){}
}
}
pipelineCursor.destroy();
for ( int i = 0; i <out.length; i++ )
{
IDataCursor outCursor = out[i].getCursor();
output[i] = IDataUtil.getString( outCursor, "value" );
outCursor.destroy();
}
// 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] );
dateOutCursor.destroy();
}
IDataUtil.put( pipelineCursor_1, “dateOut”, dateOut );
pipelineCursor_1.destroy();
Thanks in advance…
Trinadh