Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
CustomerID|CustomerName
123|John Doe
456|Jane Doe
I.e. CustomerID=123,CustomerName=John Doe;CustomerID=456,CustomerName=Jane Doe;...
output_row.OutString = input_row.CustomerID;
String columnName ="";
String fieldType = "";
String outString = "";
for (java.lang.reflect.Field field: tMapOut.getClass().getDeclaredFields()) {
/*
tMapOut is the name connector from tMap to tJavaRow. Change to your map name
getDeclaredFields - to get the tmap output fields
*/
columnName = field.getName();
Class type = field.getType();
String fieldValue = "";
Object objType = field.get(tMapOut);
switch (type.getSimpleName())
{
case "String": // Write as many cases as there are data types in your job. Convert each output to string using the respective methods
fieldValue = (String)objType;
break;
case "Integer":
fieldValue = String.valueOf((int)objType);
break;
case "BigDecimal":
fieldValue = ((BigDecimal)objType).toPlainString();
}
outString += columnName + "=" + fieldValue + ",";
}
System.out.println(outString);
CustomerID|CustomerName
This line is the column name or the first row of incoming message?
Which components do you use in the job?
How do you define the schema?
Just want to find out your needs, so that I can give your accurate answer.
String columnName ="";
String fieldType = "";
String outString = "";
for (java.lang.reflect.Field field: tMapOut.getClass().getDeclaredFields()) {
/*
tMapOut is the name connector from tMap to tJavaRow. Change to your map name
getDeclaredFields - to get the tmap output fields
*/
columnName = field.getName();
Class type = field.getType();
String fieldValue = "";
Object objType = field.get(tMapOut);
switch (type.getSimpleName())
{
case "String": // Write as many cases as there are data types in your job. Convert each output to string using the respective methods
fieldValue = (String)objType;
break;
case "Integer":
fieldValue = String.valueOf((int)objType);
break;
case "BigDecimal":
fieldValue = ((BigDecimal)objType).toPlainString();
}
outString += columnName + "=" + fieldValue + ",";
}
System.out.println(outString);