1 /*
2 * Replica is published under the terms
3 * of the Apache Software License.
4 */
5 package replica.server.commands.sql;
6
7 import replica.command.CommandProcessor;
8 import replica.core.ApplicationMessage;
9 import replica.server.commands.PrintCommand;
10 import replica.server.mvc.View;
11
12 /***
13 * @author Pedro Costa
14 * @author Helder Silva
15 * @since 20/Jan/2004
16 */
17 public class SelectCommand extends SqlCommand {
18
19 CommandProcessor databaseCommandProcessor;
20 CommandProcessor serverCommandProcessor;
21 View view;
22
23 /***
24 *
25 */
26 public SelectCommand() {
27 super();
28 }
29
30 /* (non-Javadoc)
31 * @see replica.server.commands.LoggedInCommand#internalExecute(replica.server.ServerCommandVO)
32 */
33 protected Object internalExecute(ApplicationMessage appMsg) {
34
35 try{
36 Object res = getDatabaseCommandProcessor().process( appMsg );
37
38 if( !(res instanceof String) )
39 res = getView().render( res ).toString();
40
41 String resStr = res.toString();
42
43 if( resStr.startsWith(PrintCommand.NAME+" ") )
44 resStr = resStr.substring(PrintCommand.NAME.length()).trim();
45
46 return resStr;
47 }
48 finally{
49 }
50 }
51
52 /***
53 * @return
54 */
55 public View getView() {
56 return view;
57 }
58
59 /***
60 * @param view
61 */
62 public void setView(View view) {
63 this.view = view;
64 }
65
66 /***
67 * @return
68 */
69 public CommandProcessor getDatabaseCommandProcessor() {
70 return databaseCommandProcessor;
71 }
72
73 /***
74 * @param processor
75 */
76 public void setDatabaseCommandProcessor(CommandProcessor processor) {
77 databaseCommandProcessor = processor;
78 }
79
80 /***
81 * @return
82 */
83 public CommandProcessor getServerCommandProcessor() {
84 return serverCommandProcessor;
85 }
86
87 /***
88 * @param processor
89 */
90 public void setServerCommandProcessor(CommandProcessor processor) {
91 serverCommandProcessor = processor;
92 }
93
94 }
This page was automatically generated by Maven