Hi, I am trying to check datatype of a variable using Java Service. I try to get datatype of a string which in doclist of doc. but I am getting class “com.wm.data.ISMemDataImpl” in output.
my code
public static final void new_javaService(IData pipeline) throws ServiceException {
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
// doc
IData doc = IDataUtil.getIData( pipelineCursor, "doc" );
if ( doc != null)
{
IDataCursor docCursor = doc.getCursor();
// i.docList
IData[] docList = IDataUtil.getIDataArray( docCursor, "docList" );
if ( docList != null)
{
for ( int i = 0; i < docList.length; i++ )
{
Class<?> name = docList[i].getClass();
IDataUtil.put(pipelineCursor, "name", String.valueOf(name));
}
}
docCursor.destroy();
}
pipelineCursor.destroy();
// pipeline
}
// --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
// --- <<IS-END-SHARED-SOURCE-AREA>> ---
I need datatype of “name” in above image. please help! thanks in advance
Error messages / full error message screenshot / log file:
what exactly would be the use case for such a service?
Regarding your code:
You are referring to the current docList-Element, which is a container type and not its child element “name”.
You will have to retrieve the child element prior to checking its type.
You know everything in Integration Server pipeline is usually a string right? When you implement a java service your pipeline is linked and passed to your Java service. That doesn’t necessarily mean that what you had in your pipeline and what you get in your java service as object, are entirely same.
You should explain what your requirement is, not ask for a solution to your attempt. Currently you are asking questions about your attempted solution. Its called XY problem. https://xyproblem.info/
Based upon this description, this is simply trying to set a default value for a field if a value is not present, correct?
Or are you looking for a literal string “NULL”? (Seems unlikely). But if you are checking for a literal “NULL” string, then this is easily doable in FLOW.
You may be aware, but null entities do not have a data type. One cannot inspect a var that is null to see what type it is – it is nothing.
If you’re simply trying to set a default value of ‘A’ this can be done in FLOW. No need for Java and certainly no need to check the data type.
All that said, this almost feels like this is an interview question or perhaps a university assignment – it’s okay if it is, but that information will help the community steer you in the right direction.
in MAP step, when you map a variable from input to output, you can additionally set a default value on the output and mark “Overwrite pipeline value” as false.
When input has a content, this one will be mapped and used further on, but if there is no value on the input, the value set on the output will be used instead.
See “Working with Designer” and ServiceDevelopment Guides for further informations.