Coverage Report - org.apache.commons.compress.changes.ChangeSetResults
 
Classes in this File Line Coverage Branch Coverage Complexity
ChangeSetResults
100%
16/16
100%
4/4
1,429
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.commons.compress.changes;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.List;
 23  
 
 24  
 /**
 25  
  * Stores the results of an performed ChangeSet operation.
 26  
  */
 27  24
 public class ChangeSetResults {
 28  24
     private final List<String> addedFromChangeSet = new ArrayList<String>();
 29  24
     private final List<String> addedFromStream = new ArrayList<String>();
 30  24
     private final List<String> deleted = new ArrayList<String>();
 31  
 
 32  
     /**
 33  
      * Adds the filename of a recently deleted file to the result list.
 34  
      * @param fileName the file which has been deleted
 35  
      */
 36  
     void deleted(String fileName) {
 37  31
         deleted.add(fileName);
 38  31
     }
 39  
 
 40  
     /**
 41  
      * Adds the name of a file to the result list which has been 
 42  
      * copied from the source stream to the target stream.
 43  
      * @param fileName the file name which has been added from the original stream
 44  
      */
 45  
     void addedFromStream(String fileName) {
 46  116
         addedFromStream.add(fileName);
 47  116
     }
 48  
 
 49  
     /**
 50  
      * Adds the name of a file to the result list which has been
 51  
      * copied from the changeset to the target stream
 52  
      * @param fileName the name of the file
 53  
      */
 54  
     void addedFromChangeSet(String fileName) {
 55  12
         addedFromChangeSet.add(fileName);
 56  12
     }
 57  
 
 58  
     /**
 59  
      * Returns a list of filenames which has been added from the changeset
 60  
      * @return the list of filenames
 61  
      */
 62  
     public List<String> getAddedFromChangeSet() {
 63  4
         return addedFromChangeSet;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Returns a list of filenames which has been added from the original stream
 68  
      * @return the list of filenames
 69  
      */
 70  
     public List<String> getAddedFromStream() {
 71  8
         return addedFromStream;
 72  
     }
 73  
 
 74  
     /**
 75  
      * Returns a list of filenames which has been deleted
 76  
      * @return the list of filenames
 77  
      */
 78  
     public List<String> getDeleted() {
 79  5
         return deleted;
 80  
     }
 81  
 
 82  
     /**
 83  
      * Checks if an filename already has been added to the result list
 84  
      * @param filename the filename to check
 85  
      * @return true, if this filename already has been added
 86  
      */
 87  
     boolean hasBeenAdded(String filename) {
 88  118
         if(addedFromChangeSet.contains(filename) || addedFromStream.contains(filename)) {
 89  2
             return true;
 90  
         } 
 91  116
         return false;
 92  
     }
 93  
 }