public int getTagForID(int group, String id) {
   if (id == null) return 0;
   PrivateGroupIndex idx = index.get(new Integer(group));
   if (idx == null) return 0;
   Integer tagInteger = idx.get(id.trim());
   if (tagInteger == null) return 0;
   return tagInteger.intValue();
 }
    public PrivateGroupsIndex(Dataset ds) {
      this.ds = ds;
      cs = ds.getSpecificCharacterSet();
      index = new Hashtable<Integer, PrivateGroupIndex>();

      for (Iterator it = ds.iterator(); it.hasNext(); ) {
        DcmElement el = (DcmElement) it.next();
        int tag = el.tag();
        int group = (tag >> 16) & 0xFFFF;
        int element = tag & 0xFFFF;
        if (((group & 1) != 0) && (element < 0x100)) {

          // This is a private group element that claims a block.
          try {
            String blockOwnerID = el.getString(cs);
            if ((blockOwnerID != null) && !(blockOwnerID = blockOwnerID.trim()).equals("")) {

              // Get the index of this group
              Integer gpInteger = new Integer(group);
              PrivateGroupIndex idx = index.get(gpInteger);
              if (idx == null) {
                idx = new PrivateGroupIndex();
                index.put(gpInteger, idx);
              }

              // Store the mapping for this block.
              // Note: this implementation requires that all blocks
              // within a single private group be claimed with unique IDs.
              // The standard doesn't seem to require this constraint, but
              // objects in practice seem to observe it. There is a CP
              // inprocess to require it.
              idx.put(blockOwnerID, new Integer(tag));
            }
          } catch (Exception skip) {
          }
        }
      }
    }