Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 82   Methods: 6
NCLOC: 25   Classes: 1
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
AbstractCommandProcessor.java - 42,9% 50% 46,2%
coverage coverage
 1   
 /*
 2   
  * Replica is published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 package replica.command;
 6   
 
 7   
 import java.util.StringTokenizer;
 8   
 
 9   
 /**
 10   
  * Generic implementation of a CommandProcessor.
 11   
  *  
 12   
  * @author Pedro Costa
 13   
  * @author Helder Silva
 14   
  * @since 17/Jan/2004
 15   
  */
 16   
 public abstract class AbstractCommandProcessor implements CommandProcessor {
 17   
     
 18   
     private Mappings mappings;
 19   
 
 20   
     /**
 21   
      * 
 22   
      */
 23  9
     public AbstractCommandProcessor() {
 24  9
         super();
 25   
     }
 26   
 
 27   
     /**
 28   
      * This default implementation assumes that command is a string and that the first word is the action Id.
 29   
      * 
 30   
      *  It passes the all command instruction, including the action Id, to the mapped command on execute.
 31   
      *  
 32   
      * @return Object the result of the command execution.
 33   
      * @see replica.server.cmd.CommandProcessor#process(java.lang.String)
 34   
      * @throws CommandException if there is a problem executing the command.
 35   
      *          Callers can choose to catch or not.
 36   
      */
 37  0
     public Object process(Object command){
 38   
         
 39  0
         return getCommand( command ).execute( command );
 40   
     }
 41   
     
 42  0
     protected Command getCommand(Object command){    
 43  0
         StringTokenizer tokenizer = new StringTokenizer(command.toString());
 44   
         
 45  0
         return getMappings().getNewCommand( tokenizer.nextToken().trim() );
 46   
     }
 47   
     
 48   
     /**
 49   
      * You must call this method to initialize this class mappings.
 50   
      *
 51   
      */
 52  6
     public void configure(){
 53   
         
 54  6
         setMappings( readMappings() );
 55   
     }
 56   
     
 57   
     /**
 58   
      * Reads a new configuration mapping.
 59   
      * 
 60   
      * Extended classes can read this configuration from diferent type of sources: xml files, properties files,
 61   
      * databases, JNDI, or others.
 62   
      * 
 63   
      * @return a new mapping configuration.
 64   
      */
 65   
     protected abstract Mappings readMappings(); 
 66   
     
 67   
     /**
 68   
      * @return
 69   
      */
 70  0
     protected Mappings getMappings() {
 71  0
         return mappings;
 72   
     }
 73   
 
 74   
     /**
 75   
      * @param mappings
 76   
      */
 77  6
     protected void setMappings(Mappings mappings) {
 78  6
         this.mappings = mappings;
 79   
     }
 80   
 
 81   
 }
 82