return getValue(layout, value, segment);
}
private static Object getValue(String layout, long value, Segment segment)
throws Pack200Exception {
SegmentConstantPool pool = segment.getConstantPool();
if (layout.startsWith("R")) {
// references
if (layout.indexOf('N') != -1)
value--;
if (layout.startsWith("RU")) {
return pool.getValue(SegmentConstantPool.UTF_8, value);
} else if (layout.startsWith("RS")) {
return pool.getValue(SegmentConstantPool.SIGNATURE, value);
}
} else if (layout.startsWith("K")) {
char type = layout.charAt(1);
switch (type) {
case 'S': // String
return pool.getValue(SegmentConstantPool.CP_STRING, value);
case 'I': // Int (or byte or short)
case 'C': // Char
return pool.getValue(SegmentConstantPool.CP_INT, value);
case 'F': // Float
return pool.getValue(SegmentConstantPool.CP_FLOAT, value);
case 'J': // Long
return pool.getValue(SegmentConstantPool.CP_LONG,value);
case 'D': // Double
return pool.getValue(SegmentConstantPool.CP_DOUBLE,value);
}
}
throw new Pack200Exception("Unknown layout encoding: " + layout);
}