public class ByteBufferReplacer extends Object
ByteBuffer
objects, where the replacements are
of equal length to what they're replacing.Constructor and Description |
---|
ByteBufferReplacer(com.google.common.collect.ImmutableMap<byte[],byte[]> replacements) |
Modifier and Type | Method and Description |
---|---|
static ByteBufferReplacer |
fromPaths(com.google.common.collect.ImmutableMap<Path,Path> paths,
char separator,
Charset charset)
Build a replacer using the given map of paths to replacement paths, using
charset to
convert to underlying byte arrays. |
int |
replace(ByteBuffer buffer) |
int |
replace(ByteBuffer buffer,
int maxReplacements)
Perform an in-place replacement pass over the given buffer (bounded by
Buffer.position and Buffer.limit ). |
public ByteBufferReplacer(com.google.common.collect.ImmutableMap<byte[],byte[]> replacements)
public static ByteBufferReplacer fromPaths(com.google.common.collect.ImmutableMap<Path,Path> paths, char separator, Charset charset)
charset
to
convert to underlying byte arrays. If the replacement paths are not long enough, use the given
path separator to fill.public int replace(ByteBuffer buffer, int maxReplacements)
Buffer.position
and Buffer.limit
).buffer
- the buffer on which to perform replacements.maxReplacements
- the maximum number of replacements to perform (-1 means unlimited).public int replace(ByteBuffer buffer)