Java 8 MemoryCacheImageInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MemoryCacheImageInputStream class.

This code example shows how to use the following methods:
	private ImageInputStream createImageInputStream(InputStream is) throws IOException {
		if (this.cacheDir != null) {
			return new FileCacheImageInputStream(is, cacheDir);
		} 
		else { 
			return new MemoryCacheImageInputStream(is);
		} 
	} 
 
	@Override 
	public void write(BufferedImage image, MediaType contentType, HttpOutputMessage outputMessage)
			throws IOException, HttpMessageNotWritableException {
 
		if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
			contentType = getDefaultContentType();
		} 
		Assert.notNull(contentType,
				"Count not determine Content-Type, set one using the 'defaultContentType' property"); 
		outputMessage.getHeaders().setContentType(contentType);
		ImageOutputStream imageOutputStream = null;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        } 
        return null; 
    } 
 
    private static DecodeQualification checkDecodeQualificationOnStream(InputStream headerStream) {
        return checkDecodeQualificationOnStream(new MemoryCacheImageInputStream(headerStream));
    } 
 
    private static DecodeQualification checkDecodeQualificationOnStream(ImageInputStream headerStream) {
        try { 
            final String line = headerStream.readLine();
            if (line != null && line.startsWith(EnviConstants.FIRST_LINE)) {
                return DecodeQualification.SUITABLE; 
            } 
 
        } catch (IOException ignore) {
            // intentionally nothing in here tb 20080409 
        } 
        return DecodeQualification.UNABLE; 
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getStreamPosition, seek
 
    @Test
    public void testSeekBeforeStreamNoEnd() throws IOException {
        byte[] bytes = new byte[20];
 
        MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
 
        input.seek(10);
        assertEquals(10, input.getStreamPosition());
 
        IIOInputStreamAdapter stream = new IIOInputStreamAdapter(input);
        assertEquals("Should not skip backwards", 0, stream.skip(-5));
        assertEquals(10, input.getStreamPosition());
    } 
 
    @Test
    public void testSeekBeforeStream() throws IOException {
        byte[] bytes = new byte[20];
 
        MemoryCacheImageInputStream input = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    @Override 
    public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir)  
        throws IOException { 
        if (input instanceof byte[]) { 
            return new MemoryCacheImageInputStream(new ByteArrayInputStream((byte[])input)); 
        } 
        return null; 
    } 
 
    @Override 
    public String getDescription(Locale locale) { 
        return "Byte array stream"; 
    } 
 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    getParent().markAsNeedingLayout(); 
  } 
 
  public void setData(byte[] bytes) throws ExceptionImageInputStream imageInput = new MemoryCacheImageInputStream(new ByteArrayInputStream(bytes));
    setImage(ImageIO.read(imageInput));
    filename = "[DATA]";
 
    markAsNeedingLayout(); 
    getParent().markAsNeedingLayout(); 
  } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
                if (source instanceof InputStream) {
                    // Use of the ImageInputStreamAdapter 
                    if (isAggressiveInputStreamSupported()) { 
                        stream = new ImageInputStreamAdapter((InputStream) source);
                    } else { 
                        stream = new MemoryCacheImageInputStream((InputStream) source);
                    } 
 
                    // Image reading 
                    reader.setInput(stream);
                    return reader.read(0);
                }else{ 
                    throw new IllegalArgumentException("Wrong input object");
                } 
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
                throw e;
            } finally { 
                // reader disposal 
                if (reader != null) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            try { 
                return new FileCacheImageInputStream(stream, null);
            } catch (IOException e) {
 
            } 
        return new MemoryCacheImageInputStream(stream);
    } 
 
    public InputStream getTarget() {
        return is;
    } 
 
    public Class<InputStream> getBinding() {
        return InputStream.class;
    } 
} 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            if (tempFile.exists() && tempFile.isFile() && tempFile.canRead())
                return fileStreamSPI.createInputStreamInstance(tempFile,useCache, cacheDir);
 
            // URL that does NOT points to a file, let's open up a stream 
            if (useCache)
                return new MemoryCacheImageInputStream(sourceURL.openStream());
            else 
                return new FileCacheImageInputStream(sourceURL.openStream(), cacheDir);
 
        } catch (IOException e) {
            if (LOGGER.isLoggable(Level.FINE))
                LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
            return null; 
        } 
    } 
 
    /** 
     * @see ImageInputStreamSpi#getDescription(Locale). 
     */ 
    public String getDescription(Locale locale) {
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    public ImageMetadataMap(InputStream input) {
        ByteArrayOutputStream tempOutput = new ByteArrayOutputStream();
 
        try { 
            IoUtils.copy(input, tempOutput);
            populateDimension(new MemoryCacheImageInputStream(new ByteArrayInputStream(tempOutput.toByteArray())));
            populateMetadata(ImageMetadataReader.readMetadata(new BufferedInputStream(new ByteArrayInputStream(tempOutput.toByteArray()))));
 
        } catch (Throwable error) {
            errors.add(error);
        } 
    } 
 
    /** 
     * Creates an instance based on the given {@code file}. 
     * 
     * @param file Can't be {@code null}. 
     */ 
    public ImageMetadataMap(File file) {
        try { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	private ImageInputStream createImageInputStream(InputStream is) throws IOException {
		if (this.cacheDir != null) {
			return new FileCacheImageInputStream(is, cacheDir);
		} 
		else { 
			return new MemoryCacheImageInputStream(is);
		} 
	} 
 
	public void write(BufferedImage image, MediaType contentType, HttpOutputMessage outputMessage,HttpInputMessage inputMessage )
			throws IOException, HttpMessageNotWritableException {
 
		if (contentType == null) {
			contentType = getDefaultContentType();
		} 
		Assert.notNull(contentType,
				"Count not determine Content-Type, set one using the 'defaultContentType' property"); 
		outputMessage.getHeaders().setContentType(contentType);
		ImageOutputStream imageOutputStream = null;
		ImageWriter imageWriter = null;
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 MemoryCacheImageInputStream Methods: