javax.imageio.stream.FileCacheImageInputStream Java Examples

The following examples show how to use javax.imageio.stream.FileCacheImageInputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InputStreamImageInputStreamSpi.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #2
Source File: InputStreamImageInputStreamSpi.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #3
Source File: InputStreamImageInputStreamSpi.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #4
Source File: InputStreamImageInputStreamSpi.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #5
Source File: InputStreamImageInputStreamSpi.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #6
Source File: InputStreamImageInputStreamSpi.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #7
Source File: InputStreamImageInputStreamSpi.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #8
Source File: InputStreamImageInputStreamSpi.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #9
Source File: InputStreamImageInputStreamSpi.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #10
Source File: InputStreamImageInputStreamSpi.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #11
Source File: InputStreamImageInputStreamSpi.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #12
Source File: InputStreamImageInputStreamSpi.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #13
Source File: InputStreamImageInputStreamSpi.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #14
Source File: InputStreamImageInputStreamSpi.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #15
Source File: InputStreamImageInputStreamSpi.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #16
Source File: InputStreamImageInputStreamSpi.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
 
Example #17
Source File: BufferedImageHttpMessageConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
	if (this.cacheDir != null) {
		return new FileCacheImageInputStream(is, cacheDir);
	}
	else {
		return new MemoryCacheImageInputStream(is);
	}
}
 
Example #18
Source File: FileCacheImageInputStreamNullTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String[] args) throws Exception {
    boolean gotIAE = false;
    try {
        FileCacheImageInputStream fciis =
            new FileCacheImageInputStream(null, null);
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }

    if (!gotIAE) {
        throw new RuntimeException
            ("Failed to get IllegalArgumentException!");
    }
}
 
Example #19
Source File: BufferedImageHttpMessageConverter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
	if (this.cacheDir != null) {
		return new FileCacheImageInputStream(is, cacheDir);
	}
	else {
		return new MemoryCacheImageInputStream(is);
	}
}
 
Example #20
Source File: BufferedImageHttpMessageConverter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
	if (this.cacheDir != null) {
		return new FileCacheImageInputStream(is, this.cacheDir);
	}
	else {
		return new MemoryCacheImageInputStream(is);
	}
}
 
Example #21
Source File: FileCacheImageInputStreamNullTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String[] args) throws Exception {
    boolean gotIAE = false;
    try {
        FileCacheImageInputStream fciis =
            new FileCacheImageInputStream(null, null);
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }

    if (!gotIAE) {
        throw new RuntimeException
            ("Failed to get IllegalArgumentException!");
    }
}
 
Example #22
Source File: BufferedImageHttpMessageConverter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
	if (this.cacheDir != null) {
		return new FileCacheImageInputStream(is, this.cacheDir);
	}
	else {
		return new MemoryCacheImageInputStream(is);
	}
}
 
Example #23
Source File: ReadBitsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    byte[] buffer = new byte[] {(byte)169, (byte)85}; // 10101001 01010101
    InputStream ins = new ByteArrayInputStream(buffer);
    ImageInputStream in = new FileCacheImageInputStream(ins,null);

    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Initial bit offset != 0!");
    }

    int bit0 = in.readBit(); // 1
    if (bit0 != 1) {
        throw new RuntimeException("First bit != 1");
    }
    if (in.getBitOffset() != 1) {
        throw new RuntimeException("Second bit offset != 1");
    }

    long bits1 = in.readBits(5); // 01010 = 10
    if (bits1 != 10) {
        throw new RuntimeException("Bits 1-5 != 10 (= " + bits1 + ")");
    }
    if (in.getBitOffset() != 6) {
        throw new RuntimeException("Third bit offset != 6");
    }

    int bit1 = in.readBit(); // 0
    if (bit1 != 0) {
        throw new RuntimeException("Bit 6 != 0");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Third bit offset != 7");
    }

    long bits2 = in.readBits(8); // 10101010 = 170
    if (bits2 != 170) {
        throw new RuntimeException("Bits 7-14 != 170 (= " + bits2 + ")");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Fourth bit offset != 7");
    }

    int bit2 = in.readBit(); // 1
    if (bit2 != 1) {
        throw new RuntimeException("Bit 15 != 1");
    }
    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Fifth bit offset != 0");
    }

    in.close();
}
 
Example #24
Source File: ReadBitsTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    byte[] buffer = new byte[] {(byte)169, (byte)85}; // 10101001 01010101
    InputStream ins = new ByteArrayInputStream(buffer);
    ImageInputStream in = new FileCacheImageInputStream(ins,null);

    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Initial bit offset != 0!");
    }

    int bit0 = in.readBit(); // 1
    if (bit0 != 1) {
        throw new RuntimeException("First bit != 1");
    }
    if (in.getBitOffset() != 1) {
        throw new RuntimeException("Second bit offset != 1");
    }

    long bits1 = in.readBits(5); // 01010 = 10
    if (bits1 != 10) {
        throw new RuntimeException("Bits 1-5 != 10 (= " + bits1 + ")");
    }
    if (in.getBitOffset() != 6) {
        throw new RuntimeException("Third bit offset != 6");
    }

    int bit1 = in.readBit(); // 0
    if (bit1 != 0) {
        throw new RuntimeException("Bit 6 != 0");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Third bit offset != 7");
    }

    long bits2 = in.readBits(8); // 10101010 = 170
    if (bits2 != 170) {
        throw new RuntimeException("Bits 7-14 != 170 (= " + bits2 + ")");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Fourth bit offset != 7");
    }

    int bit2 = in.readBit(); // 1
    if (bit2 != 1) {
        throw new RuntimeException("Bit 15 != 1");
    }
    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Fifth bit offset != 0");
    }

    in.close();
}