public class BinaryReader extends Object
ByteBuffer buffer = ByteBuffer.allocate(8192);
BinaryWriter bw = new BinaryWriter(aterm);
while(!bw.isDone()) {
int bytesRead = channel.read(buffer); // Read the next chunk of data from the stream.
if(!buffer.hasRemaining() || bytesRead == -1) {
bw.serialize(buffer);
buffer.clear();
}
}
| Constructor and Description |
|---|
BinaryReader(PureFactory factory)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
deserialize(ByteBuffer buffer)
Constructs (a part of) the ATerm from the binary representation present in the given buffer.
|
ATerm |
getRoot()
Returns the reconstructed ATerm.
|
boolean |
isDone()
Checks if we are done serializing.
|
static ATerm |
readTermFromSAFFile(PureFactory pureFactory,
File file)
Reads the ATerm from the given SAF encoded file.
|
static ATerm |
readTermFromSAFString(PureFactory pureFactory,
byte[] data)
Reads the ATerm from the given SAF encoded data.
|
public BinaryReader(PureFactory factory)
factory - The factory to use for reconstruction of the ATerm.public void deserialize(ByteBuffer buffer)
buffer - The buffer that contains (a part of) the binary representation of the ATerm.public boolean isDone()
public ATerm getRoot()
public static ATerm readTermFromSAFFile(PureFactory pureFactory, File file) throws IOException
pureFactory - The factory to use.file - The file that contains the SAF encoded term.IOException - Thrown when an error occurs while reading the given file.public static ATerm readTermFromSAFString(PureFactory pureFactory, byte[] data)
pureFactory - The factory to use.data - The SAF encoded data.Copyright © 2012 CWI. All Rights Reserved.