177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair/* 277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Copyright 2008 the original author or authors. 377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Licensed under the Apache License, Version 2.0 (the "License"); 577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * you may not use this file except in compliance with the License. 677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * You may obtain a copy of the License at 777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * http://www.apache.org/licenses/LICENSE-2.0 977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 1077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Unless required by applicable law or agreed to in writing, software 1177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * distributed under the License is distributed on an "AS IS" BASIS, 1277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * See the License for the specific language governing permissions and 1477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * limitations under the License. 1577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 1677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismairpackage org.mockftpserver.fake.filesystem; 1777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 1877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair/** 1977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * File system entry representing a directory 2077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 2177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @author Chris Mair 2277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @version $Revision$ - $Date$ 2377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 2477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismairpublic class DirectoryEntry extends AbstractFileSystemEntry { 2577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 2677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair /** 2777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Construct a new instance without setting its path 2877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 2977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair public DirectoryEntry() { 3077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair } 3177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 3277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair /** 3377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Construct a new instance with the specified value for its path 3477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 3577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @param path - the value for path 3677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 3777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair public DirectoryEntry(String path) { 3877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair super(path); 3977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair } 4077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 4177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair /** 4277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Return true to indicate that this entry represents a directory 4377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 4477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @return true 4577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 4677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair public boolean isDirectory() { 4777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair return true; 4877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair } 4977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 5077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair /** 5177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Return the size of this directory. This method returns zero. 5277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 5377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @return the file size in bytes 5477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 5577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair public long getSize() { 5677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair return 0; 5777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair } 5877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 5977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair /** 6077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @see java.lang.Object#toString() 6177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 6277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair public String toString() { 6377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair return "Directory['" + getPath() + "' lastModified=" + getLastModified() + " owner=" + getOwner() + 6477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair " group=" + getGroup() + " permissions=" + getPermissions() + "]"; 6577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair } 6677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 6777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair /** 6877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * Return a new FileSystemEntry that is a clone of this object, except having the specified path 6977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * 7077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @param path - the new path value for the cloned file system entry 7177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair * @return a new FileSystemEntry that has all the same values as this object except for its path 7277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair */ 7377b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair public FileSystemEntry cloneWithNewPath(String path) { 7477b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair DirectoryEntry clone = new DirectoryEntry(path); 7577b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair clone.setLastModified(getLastModified()); 7677b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair clone.setOwner(getOwner()); 7777b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair clone.setGroup(getGroup()); 7877b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair clone.setPermissions(getPermissions()); 7977b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair return clone; 8077b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair } 8177b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair 8277b8661f08d1379c0bdf2af93d8004fced9f1ab0chrismair} 83