public int add(TableFormat format) { cacheLock.EnterWriteLock(); try { if (format == null) { throw new ArgumentException("Format is NULL"); } int id = this.currentId++; this.addImpl(format, id); if (!format.isImmutable()) { Log.PROTOCOL_CACHING.warn("Cached mutable format as #" + id + ": " + format, new Exception()); } if (Log.PROTOCOL_CACHING.isDebugEnabled()) { Log.PROTOCOL_CACHING.debug("Cached format as #" + id + ": " + format); } return(id); } finally { cacheLock.ExitWriteLock(); } }
private TableFormat addImpl(TableFormat format, int id) { // We consider all formats as immutable now. This can cause some bugs if we cache mutable formats if (this.useExternalIds && format.isImmutable()) { format.setId(id); } this.reverse[format] = id; this.cache[id] = format; return(format); }