Pipe Separated String Creator is used to create a pipe delimited string from a documentType structure defined in webMethods6.5. It is created from a java service.
Limitations
The input to this tool should be a webMethods defined structure only. No other middleware defined structures could be used.
Limitations
The input to this tool should be a webMethods defined structure only. No other middleware defined structures could be used.
import com.wm.data.*;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
// --- <<IS-START-IMPORTS>> ---
import java.util.*;
import com.wm.util.*;
// --- <<IS-END-IMPORTS>> ---
public final class pipeSeparatedStringCreator
{
// ---( internal utility methods )---
final static pipeSeparatedStringCreator _instance = new pipeSeparatedStringCreator();
static pipeSeparatedStringCreator _newInstance() { return new pipeSeparatedStringCreator(); }
static pipeSeparatedStringCreator _cast(Object o) { return (pipeSeparatedStringCreator)o; }
// ---( server methods )---
public static final void recordToPSS (IData pipeline)
throws ServiceException
{
// --- <<IS-START(recordToPSS)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:required record
// [o] field:0:required pipeSeparatedString
//main service
IDataCursor pipelineCursor = pipeline.getCursor();
IData record = IDataUtil.getIData( pipelineCursor, "record" );
if ( record != null)
{
String pss = new String();
pss = convertRecordToPSS(record,pss);
IDataUtil.put(pipelineCursor,"pipeSeparatedString",pss);
}
pipelineCursor.destroy();
// --- <<IS-END>> ---
}
// --- <<IS-START-SHARED>> ---
//shared part
static Object nextValue = null;
static String convertRecordToPSS(IData record,String buffer)
{
buffer = callRecordToPPS(record,buffer);
buffer = buffer.substring(0,buffer.length()-1);
return(buffer);
}
static String callRecordToPPS(IData record,String buffer)
{
IDataCursor recordCursor = ((IData)record).getCursor();
if(recordCursor.first())
{
do
{
nextValue = recordCursor.getValue();
if (nextValue!=null)
{
if(nextValue instanceof java.lang.String )
{
buffer = callStringToPPS(nextValue.toString(),buffer);
}
else if(nextValue instanceof java.lang.String[])
{
buffer = callStringArrayToPPS((String[])nextValue,buffer);
}
else if(nextValue instanceof com.wm.data.IData)
{
buffer = callRecordToPPS((IData)nextValue,buffer);
}
else if(nextValue instanceof com.wm.data.IData[])
{
buffer = callRecordListToPPS((IData[])nextValue,buffer);
}
}
}while(recordCursor.next());
}
recordCursor.destroy();
return(buffer);
}
static String callStringToPPS(String value,String buffer)
{
buffer = buffer.concat(value).concat("|");
return(buffer);
}
static String callStringArrayToPPS(String[] valueList,String buffer)
{
for(int j=0; j < valueList.length; j++)
{
nextValue = valueList[j];
if (nextValue!=null)
{
if(nextValue instanceof java.lang.String )
{
buffer = callStringToPPS(nextValue.toString(),buffer);
}
else if(nextValue instanceof java.lang.String[] )
{
buffer = callStringArrayToPPS((String[])nextValue,buffer);
}
}
}
return(buffer);
}
static String callRecordListToPPS(IData[] recordList,String buffer)
{
for(int i=0; i < recordList.length; i++)
{
IDataCursor recordListCursor = (recordList[i]).getCursor();
if(recordListCursor.first())
{
do
{
nextValue = recordListCursor.getValue();
if (nextValue!=null)
{
if(nextValue instanceof java.lang.String )
{
buffer = callStringToPPS(nextValue.toString(),buffer);
}
else if(nextValue instanceof java.lang.String[])
{
buffer = callStringArrayToPPS((String[])nextValue,buffer);
}
else if(nextValue instanceof com.wm.data.IData)
{
buffer = callRecordToPPS((IData)nextValue,buffer);
}
else if(nextValue instanceof com.wm.data.IData[])
{
buffer = callRecordListToPPS((IData[])nextValue,buffer);
}
}
}while(recordListCursor.next());
}
recordListCursor.destroy();
}
return(buffer);
}
// --- <<IS-END-SHARED>> ---
}