public class CachedStreamFactory extends Object
Factory for input/output streams caching values for repeat usage.
When using a constructor without all arguments, default values are used. System properties are first checked for such values under these keys:
cachedstream.mem.pool
: Pool max memory.cachedstream.mem.instance
: Instances max memory.cachedstream.dir
: Cache directory.The following are default initialization values when not supplied via constructor arguments or System properties:
Initialization values passed in constructor always take precedence.
Modifier and Type | Class and Description |
---|---|
class |
CachedStreamFactory.MemoryTracker |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_MEM_INSTANCE |
static int |
DEFAULT_MAX_MEM_POOL |
Constructor and Description |
---|
CachedStreamFactory()
Creates a new instance with default values (see class documentation)
|
CachedStreamFactory(int maxMemoryPool,
int maxMemoryInstance)
Constructor.
|
CachedStreamFactory(int maxMemoryPool,
int maxMemoryInstance,
Path cacheDirectory)
Constructor.
|
CachedStreamFactory(Path cacheDirectory)
Creates a new instance with default memory values
(see class documentation).
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxMemoryInstance() |
int |
getMaxMemoryPool() |
CachedInputStream |
newInputStream()
Creates an empty input stream.
|
CachedInputStream |
newInputStream(File file) |
CachedInputStream |
newInputStream(InputStream is) |
CachedInputStream |
newInputStream(Path path)
Creates a new cached input stream.
|
CachedInputStream |
newInputStream(String content)
Creates a new input stream, assuming UTF-8 content.
|
CachedOutputStream |
newOuputStream() |
CachedOutputStream |
newOuputStream(OutputStream os) |
public static final int DEFAULT_MAX_MEM_INSTANCE
public static final int DEFAULT_MAX_MEM_POOL
public CachedStreamFactory(int maxMemoryPool, int maxMemoryInstance)
maxMemoryPool
- maximum number of bytes used for memory caching by
all instances created by this factory combinedmaxMemoryInstance
- maximum number of bytes used for
memory by each cached stream instance createdpublic CachedStreamFactory(int maxMemoryPool, int maxMemoryInstance, Path cacheDirectory)
maxMemoryPool
- maximum number of bytes used for memory caching by
all instances created by this factory combinedmaxMemoryInstance
- maximum number of bytes used for
memory by each cached stream instance createdcacheDirectory
- location where file-based caching takes placepublic CachedStreamFactory(Path cacheDirectory)
cacheDirectory
- location where file-based caching takes placepublic CachedStreamFactory()
public int getMaxMemoryPool()
public int getMaxMemoryInstance()
public CachedInputStream newInputStream()
public CachedInputStream newInputStream(String content)
content
- content to streampublic CachedInputStream newInputStream(File file)
public CachedInputStream newInputStream(Path path)
path
- path where to cache large filespublic CachedInputStream newInputStream(InputStream is)
public CachedOutputStream newOuputStream(OutputStream os)
public CachedOutputStream newOuputStream()
Copyright © 2008–2023 Norconex Inc.. All rights reserved.