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

Print this page
rev 4802 : 7117249: fix warnings in java.util.jar, .logging, .prefs, .zip
Reviewed-by: alanb, dholmes, forax, sherman, smarks
Contributed-by: London Java Community and Michael Barker <mikeb01@gmail.com>


 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") // Use of date constructor.
 285         Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
 286                           (int)(((dtime >> 21) & 0x0f) - 1),
 287                           (int)((dtime >> 16) & 0x1f),
 288                           (int)((dtime >> 11) & 0x1f),
 289                           (int)((dtime >> 5) & 0x3f),
 290                           (int)((dtime << 1) & 0x3e));
 291         return d.getTime();
 292     }
 293 
 294     /*
 295      * Converts Java time to DOS time.
 296      */
 297     @SuppressWarnings("deprecation") // Use of date methods
 298     private static long javaToDosTime(long time) {
 299         Date d = new Date(time);
 300         int year = d.getYear() + 1900;
 301         if (year < 1980) {
 302             return (1 << 21) | (1 << 16);
 303         }
 304         return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
 305                d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
 306                d.getSeconds() >> 1;
 307     }
 308 
 309     /**
 310      * Returns the hash code value for this entry.
 311      */
 312     public int hashCode() {
 313         return name.hashCode();
 314     }
 315 
 316     /**
 317      * Returns a copy of this entry.