< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageLocationWriter.java

Print this page
rev 16768 : imported patch imgstr_oneup


  91 
  92         return new ImageLocationWriter(strings)
  93                .addAttribute(ATTRIBUTE_MODULE, moduleName)
  94                .addAttribute(ATTRIBUTE_PARENT, parentName)
  95                .addAttribute(ATTRIBUTE_BASE, baseName)
  96                .addAttribute(ATTRIBUTE_EXTENSION, extensionName)
  97                .addAttribute(ATTRIBUTE_OFFSET, contentOffset)
  98                .addAttribute(ATTRIBUTE_COMPRESSED, compressedSize)
  99                .addAttribute(ATTRIBUTE_UNCOMPRESSED, uncompressedSize);
 100     }
 101 
 102     @Override
 103     public int hashCode() {
 104         return hashCode(ImageStringsReader.HASH_MULTIPLIER);
 105     }
 106 
 107     int hashCode(int seed) {
 108         int hash = seed;
 109 
 110         if (getModuleOffset() != 0) {
 111             hash = ImageStringsReader.hashCode("/", hash);
 112             hash = ImageStringsReader.hashCode(getModule(), hash);
 113             hash = ImageStringsReader.hashCode("/", hash);
 114         }
 115 
 116         if (getParentOffset() != 0) {
 117             hash = ImageStringsReader.hashCode(getParent(), hash);
 118             hash = ImageStringsReader.hashCode("/", hash);
 119         }
 120 
 121         hash = ImageStringsReader.hashCode(getBase(), hash);
 122 
 123         if (getExtensionOffset() != 0) {
 124             hash = ImageStringsReader.hashCode(".", hash);
 125             hash = ImageStringsReader.hashCode(getExtension(), hash);
 126         }
 127 
 128         return hash;
 129     }
 130 
 131     @Override
 132     public boolean equals(Object obj) {
 133         if (this == obj) {
 134             return true;
 135         }
 136 
 137         if (!(obj instanceof ImageLocationWriter)) {
 138             return false;
 139         }
 140 
 141         ImageLocationWriter other = (ImageLocationWriter) obj;
 142 
 143         return getModuleOffset() == other.getModuleOffset() &&
 144                getParentOffset() == other.getParentOffset() &&
 145                getBaseOffset() == other.getBaseOffset() &&
 146                getExtensionOffset() == other.getExtensionOffset();
 147     }
 148 


  91 
  92         return new ImageLocationWriter(strings)
  93                .addAttribute(ATTRIBUTE_MODULE, moduleName)
  94                .addAttribute(ATTRIBUTE_PARENT, parentName)
  95                .addAttribute(ATTRIBUTE_BASE, baseName)
  96                .addAttribute(ATTRIBUTE_EXTENSION, extensionName)
  97                .addAttribute(ATTRIBUTE_OFFSET, contentOffset)
  98                .addAttribute(ATTRIBUTE_COMPRESSED, compressedSize)
  99                .addAttribute(ATTRIBUTE_UNCOMPRESSED, uncompressedSize);
 100     }
 101 
 102     @Override
 103     public int hashCode() {
 104         return hashCode(ImageStringsReader.HASH_MULTIPLIER);
 105     }
 106 
 107     int hashCode(int seed) {
 108         int hash = seed;
 109 
 110         if (getModuleOffset() != 0) {
 111             hash = ImageStringsReader.unmaskedHashCode("/", hash);
 112             hash = ImageStringsReader.unmaskedHashCode(getModule(), hash);
 113             hash = ImageStringsReader.unmaskedHashCode("/", hash);
 114         }
 115 
 116         if (getParentOffset() != 0) {
 117             hash = ImageStringsReader.unmaskedHashCode(getParent(), hash);
 118             hash = ImageStringsReader.unmaskedHashCode("/", hash);
 119         }
 120 
 121         hash = ImageStringsReader.unmaskedHashCode(getBase(), hash);
 122 
 123         if (getExtensionOffset() != 0) {
 124             hash = ImageStringsReader.unmaskedHashCode(".", hash);
 125             hash = ImageStringsReader.unmaskedHashCode(getExtension(), hash);
 126         }
 127 
 128         return hash & ImageStringsReader.POSITIVE_MASK;
 129     }
 130 
 131     @Override
 132     public boolean equals(Object obj) {
 133         if (this == obj) {
 134             return true;
 135         }
 136 
 137         if (!(obj instanceof ImageLocationWriter)) {
 138             return false;
 139         }
 140 
 141         ImageLocationWriter other = (ImageLocationWriter) obj;
 142 
 143         return getModuleOffset() == other.getModuleOffset() &&
 144                getParentOffset() == other.getParentOffset() &&
 145                getBaseOffset() == other.getBaseOffset() &&
 146                getExtensionOffset() == other.getExtensionOffset();
 147     }
 148 
< prev index next >