Package com.gurock.smartinspect.contexts
Class BinaryContext
- java.lang.Object
-
- com.gurock.smartinspect.contexts.ViewerContext
-
- com.gurock.smartinspect.contexts.BinaryContext
-
- Direct Known Subclasses:
BinaryViewerContext
public class BinaryContext extends ViewerContext
This is the base class for all viewer contexts, which deal with binary data. A viewer context is the library-side representation of a viewer in the Console.This class is not guaranteed to be threadsafe.
-
-
Constructor Summary
Constructors Constructor Description BinaryContext(ViewerId vi)Creates and initializes a BinaryContext instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendBytes(byte[] b)Overloaded.voidappendBytes(byte[] b, int off, int len)Overloaded.voidclose()Overridden.byte[]getViewerData()Overridden.voidloadFromFile(String fileName)Loads the binary data from a file.voidloadFromStream(InputStream is)Loads the binary data from a stream.protected voidresetData()Resets the internal data stream.-
Methods inherited from class com.gurock.smartinspect.contexts.ViewerContext
getViewerId
-
-
-
-
Constructor Detail
-
BinaryContext
public BinaryContext(ViewerId vi)
Creates and initializes a BinaryContext instance.- Parameters:
vi- The viewer ID to use
-
-
Method Detail
-
getViewerData
public byte[] getViewerData()
Overridden. Returns the actual binary data which will be displayed in the viewer specified by the getViewerId- Specified by:
getViewerDatain classViewerContext- Returns:
- The actual binary data which will be displayed in the viewer specified by the getViewerId method.
-
resetData
protected void resetData()
Resets the internal data stream.This method is intended to reset the internal data stream if custom handling of data is needed by derived classes.
-
loadFromFile
public void loadFromFile(String fileName) throws IOException
Loads the binary data from a file.- Parameters:
fileName- The name of the file to load the binary data from.- Throws:
NullPointerException- The fileName argument is nullIOException- An I/O error occurred
-
loadFromStream
public void loadFromStream(InputStream is) throws IOException
Loads the binary data from a stream.- Parameters:
is- The stream to load the binary data from.- Throws:
NullPointerException- The is argument is nullIOException- An I/O error occurred
-
appendBytes
public void appendBytes(byte[] b)
Overloaded. Appends a buffer.- Parameters:
b- The buffer to append- Throws:
NullPointerException- The b argument is null
-
appendBytes
public void appendBytes(byte[] b, int off, int len)Overloaded. Appends a buffer. Lets you specify the offset in the buffer and the amount of bytes to append.- Parameters:
b- The buffer to appendoff- The offset at which to begin appendinglen- The number of bytes to append- Throws:
IndexOutOfBoundsException- The sum of the off and len parameters is greater than the actual buffer length or the off or len arguments are negativeNullPointerException- The b argument is null
-
close
public void close()
Overridden. Releases any resources used by this binary context.- Overrides:
closein classViewerContext
-
-