private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { is.defaultReadObject(); privateCreator = (String) is.readObject(); int size = is.readInt(); table = new IntHashtable<VR>(size); for (int i = 0, tag, code; i < size; ++i) { tag = is.readInt(); code = is.readUnsignedShort(); table.put(tag, VR.valueOf(code)); } }
private void writeObject(final ObjectOutputStream os) throws IOException { os.defaultWriteObject(); os.writeObject(privateCreator); os.writeInt(table.size()); try { table.accept( new IntHashtable.Visitor() { public boolean visit(int key, Object value) { try { os.writeInt(key); os.writeShort(((VR) value).code); return true; } catch (IOException e) { throw new RuntimeException(e); } } }); } catch (Exception e) { throw (IOException) e; } }
public VR vrOf(int tag) { if ((tag & 0x0000ffff) == 0) // Group Length return VR.UL; if ((tag & 0xffff0000) == 0) // Command Element return vrOfCommand(tag); if ((tag & 0x00010000) != 0) { // Private Element if ((tag & 0x0000ff00) == 0) return VR.LO; // Private Creator tag &= 0xffff00ff; } else { final int ggg00000 = tag & 0xffe00000; if (ggg00000 == 0x50000000 || ggg00000 == 0x60000000) tag &= 0xff00ffff; // (50xx,eeee), (60xx,eeee) } if (table == null) return VR.UN; VR vr = table.get(tag); return vr != null ? vr : VR.UN; }