|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| PrintCommand.java | 0% | 12,5% | 50% | 14,3% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* Replica is published under the terms
|
|
| 3 |
* of the Apache Software License.
|
|
| 4 |
*/
|
|
| 5 |
package replica.server.commands;
|
|
| 6 |
|
|
| 7 |
import replica.core.*;
|
|
| 8 |
import replica.core.ApplicationMessage;
|
|
| 9 |
import replica.server.ServerProcess;
|
|
| 10 |
|
|
| 11 |
/**
|
|
| 12 |
* This command simple sends a given string to the user.
|
|
| 13 |
*
|
|
| 14 |
* @author Pedro Costa
|
|
| 15 |
* @author Helder Silva
|
|
| 16 |
* @since 21/Jan/2004
|
|
| 17 |
*/
|
|
| 18 |
public class PrintCommand extends ApplicationCommand { |
|
| 19 |
|
|
| 20 |
public final static String NAME = "print"; |
|
| 21 |
|
|
| 22 |
/**
|
|
| 23 |
* Default constructor.
|
|
| 24 |
*/
|
|
| 25 | 3 |
public PrintCommand() {
|
| 26 | 3 |
super();
|
| 27 |
} |
|
| 28 |
|
|
| 29 |
/* (non-Javadoc)
|
|
| 30 |
* @see replica.server.commands.ServerCommand#execute(replica.core.ApplicationMessage)
|
|
| 31 |
*/
|
|
| 32 | 0 |
protected Object execute(ApplicationMessage arg) {
|
| 33 |
|
|
| 34 | 0 |
ServerProcess serverProcess = getServerProcess(arg.getSessionID()); |
| 35 |
|
|
| 36 | 0 |
if( serverProcess != null ){ |
| 37 | 0 |
String msg = arg.getBody().toString().trim(); |
| 38 |
|
|
| 39 | 0 |
if(msg.startsWith(NAME + " ")) |
| 40 | 0 |
msg = msg.substring( (NAME+" ").length() ).trim();
|
| 41 |
|
|
| 42 | 0 |
serverProcess.sendResponse(msg); |
| 43 |
} |
|
| 44 |
|
|
| 45 |
// else that session id belongs to any other group member
|
|
| 46 |
|
|
| 47 | 0 |
return null; |
| 48 |
} |
|
| 49 |
|
|
| 50 |
} |
|
| 51 |
|
|
||||||||||