001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.rGUI.RFileBrowser; 020 021import java.io.File; 022import java.io.Serializable; 023 024/** 025 * This Class represents one Remote File 026 * is useful to see the properties of a file 027 * 028 * @author Samuel Campos <samuelcampos@ua.pt> 029 */ 030@Deprecated 031public class RemoteFile implements Serializable { 032 static final long serialVersionUID = 1L; 033 034 private String filePath; 035 private String name; 036 037 private boolean canRead; 038 private boolean canWrite; 039 private boolean canExecute; 040 041 private boolean isDirectory; 042 private boolean isFile; 043 private boolean isHidden; 044 045 private long length; 046 047 048 public RemoteFile(File file){ 049 filePath = file.getAbsolutePath(); 050 name = file.getName(); 051 052 if(name.equals("") && System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1) 053 { 054 name = file.getPath(); 055 } 056 else if(name.equals("")) 057 name = "/"; 058 059 060 canRead = file.canRead(); 061 canWrite = file.canWrite(); 062 canExecute = file.canExecute(); 063 064 isDirectory = file.isDirectory(); 065 isFile = file.isFile(); 066 isHidden = file.isHidden(); 067 068 length = file.length(); 069 070 } 071 072 /** 073 * 074 * @return the current path of the remote file 075 */ 076 public String getPath(){ 077 return filePath; 078 } 079 080 /** 081 * 082 * @return the name of the remote file 083 */ 084 public String getName(){ 085 return name; 086 } 087 088 /** 089 * 090 * @return true if the server have the permitions to read the file 091 */ 092 public boolean canRead(){ 093 return canRead; 094 } 095 096 /** 097 * 098 * @return true if the server have the permitions to write in file 099 */ 100 public boolean canWrite(){ 101 return canWrite; 102 } 103 104 /** 105 * 106 * @return true if the server have the permitions to execute the file 107 */ 108 public boolean canExecute(){ 109 return canExecute; 110 } 111 112 /** 113 * 114 * @return true if the file is one directory 115 */ 116 public boolean isDirectory(){ 117 return isDirectory; 118 } 119 120 /** 121 * 122 * @return if the file is not a directory 123 */ 124 public boolean isFile(){ 125 return isFile; 126 } 127 128 /** 129 * 130 * @return true if the file is hidden 131 */ 132 public boolean isHidden(){ 133 return isHidden; 134 } 135 136 /** 137 * 138 * @return the file length (in bytes) 139 */ 140 public long length(){ 141 return length; 142 } 143 144 /** 145 * 146 * @return the name of the file 147 */ 148 @Override 149 public String toString(){ 150 return this.getName(); 151 } 152 153 /** 154 * Test if the file is equals to another 155 * 156 * @param other 157 * @return 158 */ 159 @Override 160 public boolean equals(Object other) { 161 if (other == null || other.getClass() != getClass()) { 162 return false; 163 } 164 165 if (other == this) { 166 return true; 167 } 168 169 RemoteFile tmp = (RemoteFile) other; 170 171 if (filePath.equals(tmp.filePath) && name.equals(tmp.name) && canRead == tmp.canRead 172 && canWrite == tmp.canWrite && canExecute == tmp.canExecute 173 && isDirectory == tmp.isDirectory && isFile == tmp.isFile 174 && isHidden == tmp.isHidden && length == tmp.length) { 175 return true; 176 } 177 178 return false; 179 } 180 181}