Customer Portal

Byte is a list or an array? CTl2

Comments 1

  • Avatar
    dpavlis
    0
    Comment actions Permalink
    Unfortunately, as of Clover version 3.5 the byte data type does not allow to access individual byte values in the array using index:
    b[i] = 1; //this is not valid

    We will fix this issue in the future version, but for now, following two options are available for you:




    Custom Java transformation example:

    import org.jetel.component.DataRecordTransform;
    import org.jetel.data.DataRecord;
    import org.jetel.exception.ComponentNotReadyException;
    import org.jetel.exception.TransformException;

    public class ColorTrans extends DataRecordTransform {

    @Override
    public boolean init() throws ComponentNotReadyException {
    return super.init();
    }

    @Override
    public int transform(DataRecord[] arg0, DataRecord[] arg1)
    throws TransformException {

    byte[] bytearray;

    // get source value
    String value=arg0[0].getField("myfieldStr").toString();

    // do some manipulation
    bytearray = value.getBytes();

    //set result to output
    arg1[0].getField("myoutputBye").setValue(bytearray);

    return OK; //next record
    }

    }

Please sign in to leave a comment.