public class WritableFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
static WritableFactory |
getInstance() |
Writable |
newWritable(short writableTypeKey)
Create a new writable instance (using reflection) given the specified key
|
Writable |
readWithType(DataInput dataInput)
Read a Writable From the DataInput, where the Writable was previously written using
writeWithType(Writable, DataOutput) |
void |
registerWritableType(short writableTypeKey,
Class<? extends Writable> writableClass)
Register a writable class with a specific key (as a short).
|
void |
writeWithType(Writable w,
DataOutput dataOutput)
A convenience method for writing a given Writable object to a DataOutput.
|
public static WritableFactory getInstance()
public void registerWritableType(short writableTypeKey,
@NonNull
Class<? extends Writable> writableClass)
writableTypeKey - Key for the WritablewritableClass - Class for the given key. Must have a no-arg constructorpublic Writable newWritable(short writableTypeKey)
writableTypeKey - Key to create a new writable instance forpublic void writeWithType(Writable w, DataOutput dataOutput) throws IOException
w - Writable valuedataOutput - DataOutput to write both key and value toIOException - If an error occurs during writing to the DataOutputpublic Writable readWithType(DataInput dataInput) throws IOException
writeWithType(Writable, DataOutput)dataInput - DataInput to read the Writable fromIOException - In an error occurs during readingCopyright © 2019. All rights reserved.