< prev index next >

src/java.base/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java

Print this page




 427         if (LCoded != 0 && tokenCoding == fitTokenCoding(fVlen, L)) {
 428             // A simple L value is enough to recover the tokenCoding.
 429             tokenDflt = tokenCoding;
 430         }
 431         int FDef = (favoredCoding == dflt)?1:0;
 432         int UDef = (unfavoredCoding == dflt || unfavoredCoding == null)?1:0;
 433         int TDef = (tokenCoding == tokenDflt)?1:0;
 434         int TDefL = (TDef == 1) ? LCoded : 0;
 435         assert(TDef == ((TDefL>0)?1:0));
 436         ByteArrayOutputStream bytes = new ByteArrayOutputStream(10);
 437         bytes.write(_meta_pop + FDef + 2*UDef + 4*TDefL);
 438         try {
 439             if (FDef == 0)  bytes.write(favoredCoding.getMetaCoding(dflt));
 440             if (TDef == 0)  bytes.write(tokenCoding.getMetaCoding(dflt));
 441             if (UDef == 0)  bytes.write(unfavoredCoding.getMetaCoding(dflt));
 442         } catch (IOException ee) {
 443             throw new RuntimeException(ee);
 444         }
 445         return bytes.toByteArray();
 446     }
 447     public static int parseMetaCoding(byte[] bytes, int pos, Coding dflt, CodingMethod res[]) {
 448         int op = bytes[pos++] & 0xFF;
 449         if (op < _meta_pop || op >= _meta_limit)  return pos-1; // backup
 450         op -= _meta_pop;
 451         int FDef = op % 2;
 452         int UDef = (op / 2) % 2;
 453         int TDefL = (op / 4);
 454         int TDef = (TDefL > 0)?1:0;
 455         int L = LValuesCoded[TDefL];
 456         CodingMethod[] FCode = {dflt}, TCode = {null}, UCode = {dflt};
 457         if (FDef == 0)
 458             pos = BandStructure.parseMetaCoding(bytes, pos, dflt, FCode);
 459         if (TDef == 0)
 460             pos = BandStructure.parseMetaCoding(bytes, pos, dflt, TCode);
 461         if (UDef == 0)
 462             pos = BandStructure.parseMetaCoding(bytes, pos, dflt, UCode);
 463         PopulationCoding pop = new PopulationCoding();
 464         pop.L = L;  // might be -1
 465         pop.favoredCoding   = FCode[0];
 466         pop.tokenCoding     = TCode[0];  // might be null!
 467         pop.unfavoredCoding = UCode[0];




 427         if (LCoded != 0 && tokenCoding == fitTokenCoding(fVlen, L)) {
 428             // A simple L value is enough to recover the tokenCoding.
 429             tokenDflt = tokenCoding;
 430         }
 431         int FDef = (favoredCoding == dflt)?1:0;
 432         int UDef = (unfavoredCoding == dflt || unfavoredCoding == null)?1:0;
 433         int TDef = (tokenCoding == tokenDflt)?1:0;
 434         int TDefL = (TDef == 1) ? LCoded : 0;
 435         assert(TDef == ((TDefL>0)?1:0));
 436         ByteArrayOutputStream bytes = new ByteArrayOutputStream(10);
 437         bytes.write(_meta_pop + FDef + 2*UDef + 4*TDefL);
 438         try {
 439             if (FDef == 0)  bytes.write(favoredCoding.getMetaCoding(dflt));
 440             if (TDef == 0)  bytes.write(tokenCoding.getMetaCoding(dflt));
 441             if (UDef == 0)  bytes.write(unfavoredCoding.getMetaCoding(dflt));
 442         } catch (IOException ee) {
 443             throw new RuntimeException(ee);
 444         }
 445         return bytes.toByteArray();
 446     }
 447     public static int parseMetaCoding(byte[] bytes, int pos, Coding dflt, CodingMethod[] res) {
 448         int op = bytes[pos++] & 0xFF;
 449         if (op < _meta_pop || op >= _meta_limit)  return pos-1; // backup
 450         op -= _meta_pop;
 451         int FDef = op % 2;
 452         int UDef = (op / 2) % 2;
 453         int TDefL = (op / 4);
 454         int TDef = (TDefL > 0)?1:0;
 455         int L = LValuesCoded[TDefL];
 456         CodingMethod[] FCode = {dflt}, TCode = {null}, UCode = {dflt};
 457         if (FDef == 0)
 458             pos = BandStructure.parseMetaCoding(bytes, pos, dflt, FCode);
 459         if (TDef == 0)
 460             pos = BandStructure.parseMetaCoding(bytes, pos, dflt, TCode);
 461         if (UDef == 0)
 462             pos = BandStructure.parseMetaCoding(bytes, pos, dflt, UCode);
 463         PopulationCoding pop = new PopulationCoding();
 464         pop.L = L;  // might be -1
 465         pop.favoredCoding   = FCode[0];
 466         pop.tokenCoding     = TCode[0];  // might be null!
 467         pop.unfavoredCoding = UCode[0];


< prev index next >