src/share/classes/java/util/zip/ZipEntry.java

Print this page
rev 4793 : 7117249: java.util warnings patches from LJC/Mike Barker


 264     /**
 265      * Returns true if this is a directory entry. A directory entry is
 266      * defined to be one whose name ends with a '/'.
 267      * @return true if this is a directory entry
 268      */
 269     public boolean isDirectory() {
 270         return name.endsWith("/");
 271     }
 272 
 273     /**
 274      * Returns a string representation of the ZIP entry.
 275      */
 276     public String toString() {
 277         return getName();
 278     }
 279 
 280     /*
 281      * Converts DOS time to Java time (number of milliseconds since epoch).
 282      */
 283     private static long dosToJavaTime(long dtime) {


 284         Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
 285                           (int)(((dtime >> 21) & 0x0f) - 1),
 286                           (int)((dtime >> 16) & 0x1f),
 287                           (int)((dtime >> 11) & 0x1f),
 288                           (int)((dtime >> 5) & 0x3f),
 289                           (int)((dtime << 1) & 0x3e));
 290         return d.getTime();
 291     }
 292 
 293     /*
 294      * Converts Java time to DOS time.
 295      */


 296     private static long javaToDosTime(long time) {
 297         Date d = new Date(time);
 298         int year = d.getYear() + 1900;
 299         if (year < 1980) {
 300             return (1 << 21) | (1 << 16);
 301         }
 302         return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
 303                d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
 304                d.getSeconds() >> 1;
 305     }
 306 
 307     /**
 308      * Returns the hash code value for this entry.
 309      */
 310     public int hashCode() {
 311         return name.hashCode();
 312     }
 313 
 314     /**
 315      * Returns a copy of this entry.


 264     /**
 265      * Returns true if this is a directory entry. A directory entry is
 266      * defined to be one whose name ends with a '/'.
 267      * @return true if this is a directory entry
 268      */
 269     public boolean isDirectory() {
 270         return name.endsWith("/");
 271     }
 272 
 273     /**
 274      * Returns a string representation of the ZIP entry.
 275      */
 276     public String toString() {
 277         return getName();
 278     }
 279 
 280     /*
 281      * Converts DOS time to Java time (number of milliseconds since epoch).
 282      */
 283     private static long dosToJavaTime(long dtime) {
 284         @SuppressWarnings("deprecation") // Changing to j.u.Calendar would have an
 285                                          // unknown impact on performance/gc.
 286         Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
 287                           (int)(((dtime >> 21) & 0x0f) - 1),
 288                           (int)((dtime >> 16) & 0x1f),
 289                           (int)((dtime >> 11) & 0x1f),
 290                           (int)((dtime >> 5) & 0x3f),
 291                           (int)((dtime << 1) & 0x3e));
 292         return d.getTime();
 293     }
 294 
 295     /*
 296      * Converts Java time to DOS time.
 297      */
 298     @SuppressWarnings("deprecation") // Changing to j.u.Calendar would have an
 299                                      // unknown impact on performance/gc.
 300     private static long javaToDosTime(long time) {
 301         Date d = new Date(time);
 302         int year = d.getYear() + 1900;
 303         if (year < 1980) {
 304             return (1 << 21) | (1 << 16);
 305         }
 306         return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
 307                d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
 308                d.getSeconds() >> 1;
 309     }
 310 
 311     /**
 312      * Returns the hash code value for this entry.
 313      */
 314     public int hashCode() {
 315         return name.hashCode();
 316     }
 317 
 318     /**
 319      * Returns a copy of this entry.