/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Adaptive coding.
* See the section "Adaptive Encodings" in the Pack200 spec.
* @author John Rose
*/
int headLength;
assert(isCodableLength(headLength));
this.headLength = headLength;
this.headCoding = headCoding;
this.tailCoding = tailCoding;
}
this.headCoding = headCoding;
}
assert(isCodableLength(headLength));
this.headLength = headLength;
}
this.tailCoding = tailCoding;
}
public boolean isTrivial() {
return headCoding == tailCoding;
}
// CodingMethod methods.
}
// writeArrayTo must be coded iteratively, not recursively:
private static void writeArray(AdaptiveCoding run, OutputStream out, int[] a, int start, int end) throws IOException {
for (;;) {
continue;
}
break;
}
}
}
private static void readArray(AdaptiveCoding run, InputStream in, int[] a, int start, int end) throws IOException {
for (;;) {
continue;
}
break;
}
}
static int getKXOf(int K) {
return KX;
K >>>= KX_LG2BASE;
}
return -1;
}
static int getKBOf(int K) {
K >>>= (KX * KX_LG2BASE);
return K-1;
}
}
static int getNextK(int K) {
if (K <= 0) return 1; // 1st K value
// This is the increment we expect to apply:
return K1;
}
KX += 1;
return K1;
}
// Is K of the form ((KB:[0..255])+1) * 16^(KX:{0..3])?
public static boolean isCodableLength(int K) {
if (KX < 0) return false;
}
//assert(!isTrivial()); // can happen
// See the isCodableLength restriction in CodingChooser.
try {
} catch (IOException ee) {
throw new RuntimeException(ee);
}
return bytes.toByteArray();
}
throws IOException {
for (;;) {
int K = headLength;
assert(isCodableLength(K));
assert(ABDef < 3);
if (tailCoding instanceof AdaptiveCoding) {
continue; // tail call, to avoid deep stack recursion
}
break;
}
}
keepGoing = false;
assert(ABDef < 3);
int KB = KB_DEFAULT;
if (KBFlag != 0)
if (ADef == 0) {
}
if (BDef == 0 &&
pos++;
keepGoing = true;
} else if (BDef == 0) {
}
} else {
}
}
return pos;
}
if (m instanceof Coding)
return m.toString();
}
AdaptiveCoding run = this;
for (;;) {
continue;
}
break;
}
}
/*
public static void main(String av[]) {
int[][] samples = {
{1,2,3,4,5},
{254,255,256,256+1*16,256+2*16},
{0xfd,0xfe,0xff,0x100,0x110,0x120,0x130},
{0xfd0,0xfe0,0xff0,0x1000,0x1100,0x1200,0x1300},
{0xfd00,0xfe00,0xff00,0x10000,0x11000,0x12000,0x13000},
{0xfd000,0xfe000,0xff000,0x100000}
};
for (int i = 0; i < samples.length; i++) {
for (int j = 0; j < samples[i].length; j++) {
int K = samples[i][j];
int KX = getKXOf(K);
int KB = getKBOf(K);
System.out.println("K="+Integer.toHexString(K)+
" KX="+KX+" KB="+KB);
assert(isCodableLength(K));
assert(K == decodeK(KX, KB));
if (j == 0) continue;
int K1 = samples[i][j-1];
assert(K == getNextK(K1));
}
}
}
//*/
}