DirectoryEntry.java revision c1de24f1bfa6699e54b069e300af5e4246b34a34
1c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair/* 2c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Copyright 2008 the original author or authors. 3c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 4c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Licensed under the Apache License, Version 2.0 (the "License"); 5c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * you may not use this file except in compliance with the License. 6c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * You may obtain a copy of the License at 7c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 8c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * http://www.apache.org/licenses/LICENSE-2.0 9c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 10c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Unless required by applicable law or agreed to in writing, software 11c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * distributed under the License is distributed on an "AS IS" BASIS, 12c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * See the License for the specific language governing permissions and 14c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * limitations under the License. 15c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 16c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairpackage org.mockftpserver.fake.filesystem; 17c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 18c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair/** 19c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * File system entry representing a directory 20c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 21c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @author Chris Mair 22c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @version $Revision$ - $Date$ 23c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 24c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairpublic class DirectoryEntry extends AbstractFileSystemEntry { 25c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 26c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair /** 27c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Construct a new instance without setting its path 28c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 29c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair public DirectoryEntry() { 30c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair } 31c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 32c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair /** 33c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Construct a new instance with the specified value for its path 34c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 35c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @param path - the value for path 36c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 37c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair public DirectoryEntry(String path) { 38c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair super(path); 39c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair } 40c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 41c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair /** 42c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Return true to indicate that this entry represents a directory 43c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 44c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @return true 45c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 46c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair public boolean isDirectory() { 47c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair return true; 48c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair } 49c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 50c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair /** 51c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Return the size of this directory. This method returns zero. 52c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 53c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @return the file size in bytes 54c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 55c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair public long getSize() { 56c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair return 0; 57c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair } 58c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 59c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair /** 60c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @see java.lang.Object#toString() 61c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 62c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair public String toString() { 63c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair return "Directory['" + getPath() + "' lastModified=" + getLastModified() + " owner=" + getOwner() + 64c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair " group=" + getGroup() + " permissions=" + getPermissions() + "]"; 65c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair } 66c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 67c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair /** 68c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Return a new FileSystemEntry that is a clone of this object, except having the specified path 69c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * 70c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @param path - the new path value for the cloned file system entry 71c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @return a new FileSystemEntry that has all the same values as this object except for its path 72c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */ 73c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair public FileSystemEntry cloneWithNewPath(String path) { 74c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair DirectoryEntry clone = new DirectoryEntry(path); 75c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair clone.setLastModified(getLastModified()); 76c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair clone.setOwner(getOwner()); 77c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair clone.setGroup(getGroup()); 78c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair clone.setPermissions(getPermissions()); 79c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair return clone; 80c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair } 81c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair 82c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair} 83