calling functions over client server connection

i am currently sending an object between client and server that contains getters that have string variables that are evaluated by a large if statement in the reciever. i was wondering if it is possible to do this a simpler way rather than having a large if statement for all fo the possibilities that are contained in the object.getAction.

ie:

client sends object to server where getAction() = count

server receives object and evaluates the getAction() in a large if statement like so

if object.getAction()=="hi"

hi();

else if object.getAction()=="hello"

that();

else if object.getAction()=="count"

count();

else if object.getAction()=="multiply"

multiply();

is there a simpler and quicker way to do this? i have thought of ways that would just allow a direct calling of a function on the server or client side but i don't see how it would be possible.

something like this...

String function = object.getAction()

function(); -- where function is the string variable it receives from getAtion();

I know it is not possible to call a function from a variable, but that was my idea. any input or ideas wold be helpful.

[1222 byte] By [developprogramsa] at [2007-11-26 20:41:42]
# 1
If your server has an array of predefined Runnable objects and the return value of the getAction() method is an int, thennew Thread(rarray[object.getAction()]).start();In Java, only closure-like object is Runnable.
hiwaa at 2007-7-10 2:00:30 > top of Java-index,Java Essentials,New To Java...