Coverage Report - org.jtheque.utils.io.SocketUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
SocketUtils
0%
0/14
0%
0/4
2.333
 
 1  
 package org.jtheque.utils.io;
 2  
 
 3  
 import org.slf4j.LoggerFactory;
 4  
 
 5  
 import java.io.IOException;
 6  
 import java.net.ServerSocket;
 7  
 import java.net.Socket;
 8  
 
 9  
 /*
 10  
  * This file is part of JTheque.
 11  
  *
 12  
  * JTheque is free software: you can redistribute it and/or modify
 13  
  * it under the terms of the GNU General Public License as published by
 14  
  * the Free Software Foundation, either version 3 of the License.
 15  
  *
 16  
  * JTheque is distributed in the hope that it will be useful,
 17  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 19  
  * GNU General Public License for more details.
 20  
  *
 21  
  * You should have received a copy of the GNU General Public License
 22  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 23  
  */
 24  
 
 25  
 /**
 26  
  * An utility class for the Socket use.
 27  
  *
 28  
  * @author Baptiste Wicht
 29  
  */
 30  
 public final class SocketUtils {
 31  
     /**
 32  
      * Construct a new SocketUtils. This class is an utility class, it cannot be instantiated.
 33  
      */
 34  
     private SocketUtils() {
 35  0
         super();
 36  0
     }
 37  
 
 38  
     /**
 39  
      * Close the socket.
 40  
      *
 41  
      * @param socket The socket set to close.
 42  
      */
 43  
     public static void close(Socket socket) {
 44  0
         if (socket != null) {
 45  
             try {
 46  0
                 socket.close();
 47  0
             } catch (IOException e) {
 48  0
                 LoggerFactory.getLogger(SocketUtils.class).error(e.getMessage(), e);
 49  0
             }
 50  
         }
 51  0
     }
 52  
 
 53  
     /**
 54  
      * Close the server socket.
 55  
      *
 56  
      * @param socket The socket to close.
 57  
      */
 58  
     public static void close(ServerSocket socket) {
 59  0
         if (socket != null) {
 60  
             try {
 61  0
                 socket.close();
 62  0
             } catch (IOException e) {
 63  0
                 LoggerFactory.getLogger(SocketUtils.class).error(e.getMessage(), e);
 64  0
             }
 65  
         }
 66  0
     }
 67  
 }