Coverage Report - org.jtheque.core.managers.update.actions.AbstractUpdateAction
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractUpdateAction
0 %
0/15
0 %
0/2
1.2
 
 1  
 package org.jtheque.core.managers.update.actions;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.utils.StringUtils;
 5  
 
 6  
 import java.io.File;
 7  
 
 8  
 /*
 9  
  * This file is part of JTheque.
 10  
  *
 11  
  * JTheque is free software: you can redistribute it and/or modify
 12  
  * it under the terms of the GNU General Public License as published by
 13  
  * the Free Software Foundation, either version 3 of the License.
 14  
  *
 15  
  * JTheque is distributed in the hope that it will be useful,
 16  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18  
  * GNU General Public License for more details.
 19  
  *
 20  
  * You should have received a copy of the GNU General Public License
 21  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 22  
  */
 23  
 
 24  
 /**
 25  
  * @author Baptiste Wicht
 26  
  */
 27  0
 public abstract class AbstractUpdateAction implements UpdateAction {
 28  
     private String file;
 29  
     private String folder;
 30  
 
 31  
     /**
 32  
      * Set the name of the file.
 33  
      *
 34  
      * @param file The name of the file.
 35  
      */
 36  
     public final void setFile(String file) {
 37  0
         this.file = file;
 38  0
     }
 39  
 
 40  
     /**
 41  
      * Set the name of the folder.
 42  
      *
 43  
      * @param folder The name of folder.
 44  
      */
 45  
     public final void setFolder(String folder) {
 46  0
         this.folder = folder;
 47  0
     }
 48  
 
 49  
     /**
 50  
      * Return the complete path to the destination file.
 51  
      *
 52  
      * @return The complete path.
 53  
      */
 54  
     final String getDestination() {
 55  0
         return buildFilePath(folder, file);
 56  
     }
 57  
 
 58  
     /**
 59  
      * Return the name of the file.
 60  
      *
 61  
      * @return The name of the file. 
 62  
      */
 63  
     public String getFile() {
 64  0
         return file;
 65  
     }
 66  
 
 67  
     /**
 68  
      * Build the file path with the specified folder and file.
 69  
      *
 70  
      * @param folder The folder of the file path.
 71  
      * @param file   The file part of the path.
 72  
      * @return The file path.
 73  
      */
 74  
     static String buildFilePath(String folder, String file) {
 75  0
         StringBuilder builder = new StringBuilder(200);
 76  
 
 77  0
         builder.append(Managers.getCore().getFolders().getApplicationFolder().getAbsolutePath());
 78  
 
 79  0
         if (!StringUtils.isEmpty(folder)) {
 80  0
             builder.append(File.separator);
 81  0
             builder.append(folder);
 82  
         }
 83  
 
 84  0
         builder.append(File.separator);
 85  0
         builder.append(file);
 86  
 
 87  0
         return builder.toString();
 88  
     }
 89  
 }