Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 12 package org.eclipse.core.filesystem.provider; 13 14 import org.eclipse.core.filesystem.EFS; 15 import org.eclipse.core.filesystem.IFileInfo; 16 17 25 public class FileInfo implements IFileInfo { 26 29 private static final int ATTRIBUTE_DIRECTORY = 1 << 0; 30 31 34 private static final int ATTRIBUTE_EXISTS = 1 << 16; 35 36 39 private int attributes = 0; 40 41 44 private long lastModified = EFS.NONE; 45 46 49 private long length = EFS.NONE; 50 51 54 private String name = ""; 56 59 private String linkTarget = null; 60 61 64 public FileInfo() { 65 super(); 66 } 67 68 74 public FileInfo(String name) { 75 super(); 76 this.name = name; 77 } 78 79 84 private void clear(int mask) { 85 attributes &= ~mask; 86 } 87 88 92 public Object clone() { 93 try { 94 return super.clone(); 95 } catch (CloneNotSupportedException e) { 96 return null; 98 } 99 } 100 101 105 public int compareTo(Object o) { 106 return name.compareTo(((FileInfo) o).name); 107 } 108 109 112 public boolean exists() { 113 return getAttribute(ATTRIBUTE_EXISTS); 114 } 115 116 public boolean getAttribute(int attribute) { 117 return isSet(attribute); 118 } 119 120 123 public String getStringAttribute(int attribute) { 124 if (attribute == EFS.ATTRIBUTE_LINK_TARGET) 125 return this.linkTarget; 126 return null; 127 } 128 129 132 public long getLastModified() { 133 return lastModified; 134 } 135 136 139 public long getLength() { 140 return length; 141 } 142 143 146 public String getName() { 147 return name; 148 } 149 150 153 public boolean isDirectory() { 154 return isSet(ATTRIBUTE_DIRECTORY); 155 } 156 157 private boolean isSet(long mask) { 158 return (attributes & mask) != 0; 159 } 160 161 private void set(int mask) { 162 attributes |= mask; 163 } 164 165 168 public void setAttribute(int attribute, boolean value) { 169 if (value) 170 set(attribute); 171 else 172 clear(attribute); 173 } 174 175 181 public void setDirectory(boolean value) { 182 if (value) 183 set(ATTRIBUTE_DIRECTORY); 184 else 185 clear(ATTRIBUTE_DIRECTORY); 186 } 187 188 194 public void setExists(boolean value) { 195 if (value) 196 set(ATTRIBUTE_EXISTS); 197 else 198 clear(ATTRIBUTE_EXISTS); 199 } 200 201 204 public void setLastModified(long value) { 205 lastModified = value; 206 } 207 208 214 public void setLength(long value) { 215 this.length = value; 216 } 217 218 223 public void setName(String name) { 224 if (name == null) 225 throw new IllegalArgumentException (); 226 this.name = name; 227 } 228 229 238 public void setStringAttribute(int attribute, String value) { 239 if (attribute == EFS.ATTRIBUTE_LINK_TARGET) 240 this.linkTarget = value; 241 } 242 243 246 public String toString() { 247 return name; 248 } 249 }
| Popular Tags
|