No applicable constructor/method found for actual parameters

No applicable constructor/method found for actual parameters “java.lang.String” is the error message I am receiving.

I am writing Java behind a Reformat transform as below

// automatically generated on Thu Aug 26 16:37:59 EDT 2010
import java.util.*;
import org.jetel.data.*;
import org.jetel.graph.*;
import org.jetel.metadata.*;
import org.jetel.component.*;
import org.jetel.exception.*;
import org.jetel.data.sequence.*;

import org.apache.commons.lang.StringUtils;

import com.mysgi.io.ImageFinder;
import com.mysgi.image.ItemImage;

public class Transform extends DataRecordTransform { 
	final List images;

    final String BAD_FILENAME_CHARS = "\\/:*?\"<>|&=%";
    final String BAD_FILENAME_REPLACE = "------------";
    
	/**
	 * Initializes reformat class/function. This method is called only once at then
	 * beginning of transformation process. Any object allocation/initialization should
	 * happen here.
	 */
	public boolean init() throws ComponentNotReadyException {
		images = ImageFinder.getImageRecords();

		return true;
	}

	/**
	 * Performs reformat of source records to target records.
	 * This method is called as one step in transforming flow of
	 * records.
	 */
	public int transform(DataRecord[] inputRecords, DataRecord[] outputRecords) throws TransformException {
		try {
			// user's code STARTs from here !
			String strippedName;

			${out.0.ItemID}=${in.0.ItemID};
			${out.0.ItemNumber}=${in.0.ItemNum};
			strippedName = StringUtils.replaceChars( ${in.0.ItemNum}, 
                                                     BAD_FILENAME_CHARS, 
                                                     BAD_FILENAME_REPLACE);
            if(images.contains(strippedName)) {
				${out.0.ImageLocation}=(Object)(images.get(strippedName).getImgFile().getPath());
			}
			
			// user's code ENDs here !
		} catch(Exception e) {
			throw new TransformException("Error in transformation class " + Transform.class.getName() + ": " + e.getMessage(), e);
		}
		return ALL;
	}

	/**
	 * Method called at the end of transformation process. No more
	 * records will be processed. The implementing class should release
	 * any resource reserved during init() or runtime at this point.
	 */
	public void finished() {
		
	}
}
//end of transform class 

The problem is on the line:

${out.0.ImageLocation}=(Object)(images.get(strippedName).getImgFile().getPath());

As you can see, I have tried casting the string to an Object (since the error said a constructor existed for Object). However, I get the same error message. It’s still trying to use a String even after the explicit cast.

I don’t know what to do. Help?

Hello,
try


outputRecords[0].getField("ImageLocation").setValue(images.get(strippedName).getImgFile().getPath());

instead of


${out.0.ImageLocation}=(Object)(images.get(strippedName).getImgFile().getPath());

For performance improvement use rather field’s numbers instead of theirs names, eg.:


outputRecords[0].getField(0).setValue(inputRecords[0].getField(0)); //${out.0.ItemID}=${in.0.ItemID}
outputRecords[0].getField(1).setValue(inputRecords[0].getField(1)); // ${out.0.ItemNumber}=${in.0.ItemNum}
.
.
.
outputRecords[0].getField(2).setValue(images.get(strippedName).getImgFile().getPath());