- Timestamp:
- 09/09/11 23:52:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandExecuter.java
r1 r175 4 4 import java.util.ArrayList; 5 5 import java.util.List; 6 7 6 8 7 /** … … 14 13 * </p> 15 14 * <p> 16 * This class is implemented as a <i>Singleton</i>. 15 * This class is implemented as a <i>Singleton</i>. 17 16 * </p> 18 17 * 19 18 * @author Steffen Herbold 19 * @version 1.0 20 20 */ 21 21 public class CommandExecuter { … … 34 34 */ 35 35 private static final String cmdPrefix = "CMD"; 36 36 37 37 /** 38 38 * <p> … … 48 48 * </p> 49 49 * <p> 50 * The de faultcommands package has always lowest priority, unless it is51 * specificially added.50 * The de.ugoe.cs.util.console.defaultcommands package has always lowest 51 * priority, unless it is specifically added. 52 52 * </p> 53 53 */ … … 78 78 /** 79 79 * <p> 80 * Adds a package that will be used by exec to load command from. 80 * Adds a package that will be used by {@link #exec(String)} to load command 81 * from. 81 82 * </p> 82 83 * … … 111 112 parser.parse(command); 112 113 for (int i = 0; cmd == null && i < commandPackageList.size(); i++) { 113 cmd = loadCMD(commandPackageList.get(i)+"."+cmdPrefix+parser.getCommandName()); 114 cmd = loadCMD(commandPackageList.get(i) + "." + cmdPrefix 115 + parser.getCommandName()); 114 116 } 115 117 if (cmd == null) { // check if command is available as default command 116 cmd = loadCMD(defaultPackage+"."+cmdPrefix+parser.getCommandName()); 118 cmd = loadCMD(defaultPackage + "." + cmdPrefix 119 + parser.getCommandName()); 117 120 } 118 121 if (cmd == null) { … … 128 131 129 132 /** 133 * <p> 130 134 * Helper method that loads a class and tries to cast it to {@link Command}. 135 * </p> 131 136 * 132 * @param className qualified name of the class (including package name) 133 * @return if class is available and implement {@link Command} and instance of the class, null otherwise 137 * @param className 138 * qualified name of the class (including package name) 139 * @return if class is available and implement {@link Command} and instance 140 * of the class, null otherwise 134 141 */ 135 142 private Command loadCMD(String className) { … … 140 147 } catch (NoClassDefFoundError e) { 141 148 String[] splitResult = e.getMessage().split("CMD"); 142 String correctName = splitResult[splitResult.length-1].replace(")", ""); 149 String correctName = splitResult[splitResult.length - 1].replace( 150 ")", ""); 143 151 Console.traceln("Did you mean " + correctName + "?"); 144 152 } catch (ClassNotFoundException e) {
Note: See TracChangeset
for help on using the changeset viewer.