class BERTLVObject {
private void readTag(DataInputStream in) throws IOException {
int b = in.readUnsignedByte();
if (b == 0x00000000 || b == 0x000000FF) {
throw new IllegalArgumentException("00 or FF tag not allowed");
}
switch (b & 0x000000C0) {
case 0x00000000: tagClass = UNIVERSAL_CLASS; break;
case 0x00000040: tagClass = APPLICATION_CLASS; break;
case 0x00000080: tagClass = CONTEXT_SPECIFIC_CLASS; break;
case 0x000000C0: tagClass = PRIVATE_CLASS; break;
}
switch (b & 0x00000020) {
case 0x00000000: isPrimitive = true; break;
case 0x00000020: isPrimitive = false; break;
}
switch (b & 0x0000001F) {
case 0x0000001F:
ArrayList tagBytes = new ArrayList();
tagBytes.add(new Integer(b));
b = in.readUnsignedByte();
while ((b & 0x00000080) == 0x00000080) {
tagBytes.add(new Integer(b));
}
tagBytes.add(new Integer(b));
tag = new byte[tagBytes.size()];
for (int i = 0; i < tagBytes.size(); i++) {
tag[i] = (byte)(((Integer)tagBytes.get(i)).intValue());
}
break;
default:
tag = new byte[1]; tag[0] = (byte)b; break;
}
if (tag == null) {
throw new NumberFormatException("Could not read tag");
}
}
}
|