// Internal action code for project <PROJECT_NAME>

package <PCK>;

import jason.*;
import jason.asSemantics.*;
import jason.asSyntax.*;
import java.util.logging.*;

public class <IA_NAME> extends DefaultInternalAction {

    private Logger logger = Logger.getLogger("<PROJECT_NAME>."+<IA_NAME>.class.getName());

    // Example of that must receive one literal and one number as arguments
    @Override public int getMinArgs() { return 1; }
    @Override public int getMaxArgs() { return 2; }	

	// improve the check of the arguments to also check the type of the arguments
    @Override protected void checkArguments(Term[] args) throws JasonException {
        super.checkArguments(args); // check number of arguments
        if (!args[0].isLiteral()) 
            throw JasonException.createWrongArgument(this,"first argument must be a literal");
        if (args.length == 2 && !args[1].isNumeric()) 
            throw JasonException.createWrongArgument(this,"second argument must be a number");
    }

    @Override
    public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
        checkArguments(args);
        
        // execute the internal action
        ts.getAg().getLogger().info("executing internal action '<PCK>.<IA_NAME>'");
        if (true) { // just to show how to throw another kind of exception
            throw new JasonException("not implemented!");
        }
        
        // everything ok, so returns true
        return true;
    }
}
