|
From: David W <di...@ho...> - 2009-04-30 15:47:26
|
The main question that I have is what would be the most efficient way to dispatch on options? The CLI that I'm working on basically consists of two levels of options--commands and options. The best analogy is something like Busybox, where there's a single binary (in this case jar file) that implements multiple commands, each with its own set of options (if any). So to be more concrete, in the "ARGS" section of the CLOPS file, I have command1 through commandN defined. I can check for the presence of a single command via iscommandNSet(). I'm wondering if there's a more efficient way of dispatching or testing for the command instead of doing a massive if/else-if statement, perhaps with enums or something (the enum could be used to create a proper subclass corresponding to a specific command). I would almost be tempted to define an enum with the same command names, create the correct method name programmatically (prepend "is" and append "Set" to the enum value), and then iterate through the list of enums, calling the automatically-generated method for checking to return back the correct enum. Basically, any pointers or suggestions at this point would be great. Normally I would ruminate on this for a bit, but I'm in a crunch situation and would appreciate some pointers. Thanks. _________________________________________________________________ Rediscover Hotmail®: Get e-mail storage that grows with you. http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009 |