/** * {@inheritDoc} * <p> * Note: uses the index for fast lookup */ @SuppressWarnings("unchecked") @Override public boolean contains(final Object object) { return index.containsKey(keyTransformer.transform((C) object)); }
/** * Provides checking for adding the index. * * @param object the object to index * @throws IllegalArgumentException if the object maps to an existing key and the index * enforces a uniqueness constraint */ private void addToIndex(final C object) { final K key = keyTransformer.transform(object); if (uniqueIndex && index.containsKey(key)) { throw new IllegalArgumentException("Duplicate key in uniquely indexed collection."); } index.put(key, object); }
@Override public boolean containsHeader(String name) { return headers.containsKey(name); }
public InMemoryCachedEntry(byte[] out, String contentType, String characterEncoding, int statusCode, MultiMap headers, long modificationDate, String originalUrl, int timeToLiveInSeconds) throws IOException { super(contentType, characterEncoding, statusCode, headers, modificationDate, originalUrl, timeToLiveInSeconds); // content which is actually of a compressed type must stay that way if (GZipUtil.isGZipped(out)) { this.gzippedContent = out; boolean isGzippedResponse = headers.containsKey("Content-Encoding") && ((Collection)headers.get("Content-Encoding")).contains("gzip"); if(isGzippedResponse){ this.plainContent = GZipUtil.ungzip(out); } // in case of serving a gzip file (gif for instance) else{ this.plainContent = null; } } else { this.gzippedContent = GZipUtil.gzip(out); this.plainContent = out; } }