Coverage Report - org.mockftpserver.fake.filesystem.DirectoryEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
DirectoryEntry
100%
13/13
N/A
1
 
 1  
 /*
 2  
  * Copyright 2008 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.fake.filesystem;
 17  
 
 18  
 /**
 19  
  * File system entry representing a directory
 20  
  *
 21  
  * @author Chris Mair
 22  
  * @version $Revision: 199 $ - $Date: 2008-12-10 22:03:52 -0500 (Wed, 10 Dec 2008) $
 23  
  */
 24  
 public class DirectoryEntry extends AbstractFileSystemEntry {
 25  
 
 26  
     /**
 27  
      * Construct a new instance without setting its path
 28  
      */
 29  16
     public DirectoryEntry() {
 30  16
     }
 31  
 
 32  
     /**
 33  
      * Construct a new instance with the specified value for its path
 34  
      *
 35  
      * @param path - the value for path
 36  
      */
 37  
     public DirectoryEntry(String path) {
 38  492
         super(path);
 39  492
     }
 40  
 
 41  
     /**
 42  
      * Return true to indicate that this entry represents a directory
 43  
      *
 44  
      * @return true
 45  
      */
 46  
     public boolean isDirectory() {
 47  287
         return true;
 48  
     }
 49  
 
 50  
     /**
 51  
      * Return the size of this directory. This method returns zero.
 52  
      *
 53  
      * @return the file size in bytes
 54  
      */
 55  
     public long getSize() {
 56  4
         return 0;
 57  
     }
 58  
 
 59  
     /**
 60  
      * @see java.lang.Object#toString()
 61  
      */
 62  
     public String toString() {
 63  9
         return "Directory['" + getPath() + "' lastModified=" + getLastModified() + "  owner=" + getOwner() +
 64  
                 "  group=" + getGroup() + "  permissions=" + getPermissions() + "]";
 65  
     }
 66  
 
 67  
     /**
 68  
      * Return a new FileSystemEntry that is a clone of this object, except having the specified path
 69  
      *
 70  
      * @param path - the new path value for the cloned file system entry
 71  
      * @return a new FileSystemEntry that has all the same values as this object except for its path
 72  
      */
 73  
     public FileSystemEntry cloneWithNewPath(String path) {
 74  5
         DirectoryEntry clone = new DirectoryEntry(path);
 75  5
         clone.setLastModified(getLastModified());
 76  5
         clone.setOwner(getOwner());
 77  5
         clone.setGroup(getGroup());
 78  5
         clone.setPermissions(getPermissions());
 79  5
         return clone;
 80  
     }
 81  
 
 82  
 }