public boolean accept(final Visitor visitor) { return table.accept(new IntHashtable.Visitor() { public boolean visit(int key, Object value) { return visitor.visit((DicomElement) value); } }); }
public void clear() { table.clear(); charset = null; }
@SuppressWarnings("unchecked") @Override public boolean equals(Object that) { if (!(that instanceof IntHashtable)) return false; IntHashtable<T> other = (IntHashtable<T>) that; if (other.size() != count) { return false; } for (int i = 0; i < values.length; ++i) { Object v = values[i]; if (v != null && !v.equals(other.get(keyList[i]))) return false; } return equals(value0, other.value0);// && equals(value_1, // other.value_1); }
private void rehash() { T[] oldValues = values; int[] oldkeyList = keyList; int newPrimeIndex = primeIndex; if (count > highWaterMark) { ++newPrimeIndex; } else if (count < lowWaterMark) { newPrimeIndex -= 2; } initialize(newPrimeIndex); for (int i = oldkeyList.length - 1; i >= 0; --i) { T value = oldValues[i]; if (value != null) { int key = oldkeyList[i]; int index = find(key); keyList[index] = key; values[index] = value; ++count; } } }
public Object remove(int key) { Object retval = null; if (key == 0) { if (value0 != null) { retval = value0; value0 = null; --count; } } else { final int index = find(key); if (values[index] != null) { retval = values[index]; sortedKeys = null; values[index] = null; --count; if (count < lowWaterMark) { rehash(); } } } return retval; }
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; } }
private DimseRSPHandler getDimseRSPHandler(int msgId) { synchronized (rspHandlerForMsgId) { return rspHandlerForMsgId.get(msgId); } }
private void addDimseRSPHandler(int msgId, DimseRSPHandler rspHandler) throws InterruptedException { synchronized (rspHandlerForMsgId) { while (maxOpsInvoked > 0 && rspHandlerForMsgId.size() >= maxOpsInvoked) rspHandlerForMsgId.wait(); if (isReadyForDataReceive()) rspHandlerForMsgId.put(msgId, rspHandler); } }
void checkIdle(final long now) { if (performing > 0) return; if (rspHandlerForMsgId.isEmpty()) { if (now > idleTimeout) try { release(false); } catch (InterruptedException e) { e.printStackTrace(); } } else { rspHandlerForMsgId.accept(new IntHashtable.Visitor() { public boolean visit(int key, Object value) { DimseRSPHandler rspHandler = (DimseRSPHandler) value; if (now < rspHandler.getTimeout()) return true; Association.this.abort(); return false; } }); } }
@Override public void endElement(String uri, String localName, String qName) { if ("element".equals(qName)) { table.put(tag, name.toString()); name.setLength(0); tag = -1; } } }
protected DicomObject readRecord(int offset) throws IOException { if (offset == 0) { return null; } DicomObject item = cache.get(offset); long off = offset & 0xffffffffL; if (item != null) { log.debug("Get record @ {} from cache", new Long(off)); } else { log.debug("Load record @ {} from file {}", new Long(off), file); raf.seek(off); in.setStreamPosition(off); item = new BasicDicomObject(); in.readItem(item); cache.put(offset, item); } return item; }
private void onClosed() { if (ae != null) ae.removeFromPool(this); reaper.unregister(this); synchronized (rspHandlerForMsgId) { rspHandlerForMsgId.accept(new IntHashtable.Visitor() { public boolean visit(int key, Object value) { ((DimseRSPHandler) value).onClosed(Association.this); return true; } }); rspHandlerForMsgId.clear(); rspHandlerForMsgId.notifyAll(); } if (ae != null) { ae.associationClosed(this); } }
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { is.defaultReadObject(); tagClassName = (String) is.readObject(); privateCreator = (String) is.readObject(); int size = is.readInt(); table = new IntHashtable<String>(size); for (int i = 0, tag; i < size; ++i) { tag = is.readInt(); table.put(tag, is.readUTF()); } }
public DicomElement remove(int tag) { DicomElement attr = (DicomElement) table.remove(tag); if (attr != null) { if (tag == Tag.SpecificCharacterSet) { charset = null; } } return attr; }
@Override public boolean isEmpty() { return table.isEmpty(); }
/** Returns true if there are available operations left to run */ public boolean isAvailableOps() { if( maxOpsInvoked==0 ) return true; synchronized(rspHandlerForMsgId) { return rspHandlerForMsgId.size() < maxOpsInvoked; } }
public BasicDicomObject(DicomObject defaults, int capacity) { this.defaults = defaults; this.table = new IntHashtable<DicomElement>(capacity); }
public T get(int key) { return key == 0 ? value0 : values[find(key)]; }
private void writeObject(final ObjectOutputStream os) throws IOException { os.defaultWriteObject(); os.writeObject(tagClassName); 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.writeUTF((String) value); return true; } catch (IOException e) { throw new RuntimeException(e); } } }); } catch (Exception e) { throw (IOException) e; } }