ReadOnlyFilteredCOSStream extends COSStream { public static ReadOnlyFilteredCOSStream readOnly(COSStream existing) throws IOException { requireNotNullArg(existing, "input stream cannot be null"); existing.setEncryptor(null); return new ReadOnlyFilteredCOSStream(existing, () -> existing.getFilteredStream(), existing.getFilteredLength()); } ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStream stream, long length);  ReadOnlyFilteredCOSStream(COSDictionary existingDictionary, InputStreamSupplier<InputStream> stream,
            long length); @Override long getFilteredLength(); @Override long getUnfilteredLength(); @Override InputStream getUnfilteredStream(); @Override SeekableSource getUnfilteredSource(); @Override OutputStream createFilteredStream(); @Override OutputStream createFilteredStream(COSBase filters); @Override void setFilters(COSBase filters); @Override boolean addCompression(); @Override boolean encryptable(); @Override void encryptable(boolean encryptable); @Override OutputStream createUnfilteredStream(); @Override boolean isEmpty(); @Override boolean indirectLength(); @Override void indirectLength(boolean indirectLength); @Override IndirectCOSObjectIdentifier id(); @Override void idIfAbsent(IndirectCOSObjectIdentifier id); @Override void close(); static ReadOnlyFilteredCOSStream readOnly(COSStream existing); static ReadOnlyFilteredCOSStream readOnlyJpegImage(File imageFile, int width, int height,
            int bitsPerComponent, PDColorSpace colorSpace); static final ReadOnlyFilteredCOSStream readOnlyEmbeddedFile(Source<?> source);  }
@Test(expected = IllegalArgumentException.class) public void readOnlyNullConstructor() throws IOException { ReadOnlyFilteredCOSStream.readOnly(null); }
@Test public void readOnly() throws IOException { COSStream existing = spy(new COSStream()); existing.setItem(COSName.A, COSInteger.THREE); victim = ReadOnlyFilteredCOSStream.readOnly(existing); assertEquals(COSInteger.THREE, victim.getItem(COSName.A)); verify(existing).setEncryptor(null); verify(existing, never()).getFilteredStream(); victim.getFilteredStream(); verify(existing).getFilteredStream(); }