Coverage Report - org.mockftpserver.core.command.ReplyTextBundleUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
ReplyTextBundleUtil
85%
6/7
100%
4/4
3
 
 1  
 /*
 2  
  * Copyright 2007 the original author or authors.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.mockftpserver.core.command;
 17  
 
 18  
 import org.mockftpserver.core.util.Assert;
 19  
 
 20  
 import java.util.ResourceBundle;
 21  
 
 22  
 /**
 23  
  * Contains common utility method to conditionally set the reply text ResourceBundle on a
 24  
  * CommandHandler instance.
 25  
  * 
 26  
  * @version $Revision: 184 $ - $Date: 2008-12-03 17:52:39 -0500 (Wed, 03 Dec 2008) $
 27  
  *
 28  
  * @author Chris Mair
 29  
  */
 30  0
 public final class ReplyTextBundleUtil {
 31  
 
 32  
     /**
 33  
      * Set the <code>replyTextBundle</code> property of the specified CommandHandler to the 
 34  
      * <code>ResourceBundle</code> if and only if the <code>commandHandler</code> implements the 
 35  
      * {@link ReplyTextBundleAware} interface AND its <code>replyTextBundle</code> property 
 36  
      * has not been set (is null).
 37  
      * 
 38  
      * @param commandHandler - the CommandHandler instance
 39  
      * @param replyTextBundle - the ResourceBundle to use for localizing reply text
 40  
      * 
 41  
      * @throws org.mockftpserver.core.util.AssertFailedException - if the commandHandler is null
 42  
      */
 43  
     public static void setReplyTextBundleIfAppropriate(CommandHandler commandHandler, ResourceBundle replyTextBundle) {
 44  4905
         Assert.notNull(commandHandler, "commandHandler");
 45  4904
         if (commandHandler instanceof ReplyTextBundleAware) {
 46  4900
             ReplyTextBundleAware replyTextBundleAware = (ReplyTextBundleAware) commandHandler;
 47  4900
             if (replyTextBundleAware.getReplyTextBundle() == null) {
 48  4837
                 replyTextBundleAware.setReplyTextBundle(replyTextBundle);
 49  
             }
 50  
         }
 51  4904
     }
 52  
     
 53  
 }