chrismair | 00dc7bd | 2014-05-11 21:21:28 +0000 | [diff] [blame] | 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$ - $Date$
|
| 23 | */
|
| 24 | public class DirectoryEntry extends AbstractFileSystemEntry {
|
| 25 |
|
| 26 | /**
|
| 27 | * Construct a new instance without setting its path
|
| 28 | */
|
| 29 | public DirectoryEntry() {
|
| 30 | }
|
| 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 | super(path);
|
| 39 | }
|
| 40 |
|
| 41 | /**
|
| 42 | * Return true to indicate that this entry represents a directory
|
| 43 | *
|
| 44 | * @return true
|
| 45 | */
|
| 46 | public boolean isDirectory() {
|
| 47 | 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 | return 0;
|
| 57 | }
|
| 58 |
|
| 59 | /**
|
| 60 | * @see java.lang.Object#toString()
|
| 61 | */
|
| 62 | public String toString() {
|
| 63 | 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 | DirectoryEntry clone = new DirectoryEntry(path);
|
| 75 | clone.setLastModified(getLastModified());
|
| 76 | clone.setOwner(getOwner());
|
| 77 | clone.setGroup(getGroup());
|
| 78 | clone.setPermissions(getPermissions());
|
| 79 | return clone;
|
| 80 | }
|
| 81 |
|
| 82 | }
|