1 17 package net.sourceforge.groboutils.codecoverage.v2.ant.zip; 18 19 29 public class Resource implements Cloneable , Comparable { 30 private String name = null; 31 private boolean exists = true; 32 private long lastmodified = 0; 33 private boolean directory = false; 34 35 38 public Resource() { 39 } 40 41 49 public Resource(String name) { 50 this(name, false, 0, false); 51 } 52 53 59 public Resource(String name, boolean exists, long lastmodified) { 60 this(name, exists, lastmodified, false); 61 } 62 63 67 public Resource(String name, boolean exists, long lastmodified, 68 boolean directory) { 69 this.name = name; 70 this.exists = exists; 71 this.lastmodified = lastmodified; 72 this.directory = directory; 73 } 74 75 86 public String getName() { 87 return name; 88 } 89 90 94 public void setName(String name) { 95 this.name = name; 96 } 97 100 public boolean isExists() { 101 return exists; 102 } 103 104 public void setExists(boolean exists) { 105 this.exists = exists; 106 } 107 108 114 public long getLastModified() { 115 return !exists || lastmodified < 0 ? 0 : lastmodified; 116 } 117 118 public void setLastModified(long lastmodified) { 119 this.lastmodified = lastmodified; 120 } 121 125 public boolean isDirectory() { 126 return directory; 127 } 128 129 public void setDirectory(boolean directory) { 130 this.directory = directory; 131 } 132 133 136 public Object clone() { 137 try { 138 return super.clone(); 139 } catch (CloneNotSupportedException e) { 140 throw new Error ("CloneNotSupportedException for a " 141 + "Clonable Resource caught?"); 142 } 143 } 144 145 150 public int compareTo(Object other) { 151 if (!(other instanceof Resource)) { 152 throw new IllegalArgumentException ("Can only be compared with " 153 + "Resources"); 154 } 155 Resource r = (Resource) other; 156 return getName().compareTo(r.getName()); 157 } 158 } 159 | Popular Tags |