public class TextContext extends ViewerContext
This class is not guaranteed to be threadsafe.
| Constructor and Description |
|---|
TextContext(ViewerId vi)
Creates and initializes a TextContent instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendLine(String line)
Appends a line to the text data.
|
void |
appendText(String text)
Appends text.
|
void |
close()
Overrides to release any resources of this text context.
|
protected String |
escapeLine(String line)
Escapes a line.
|
byte[] |
getViewerData()
Overridden.
|
void |
loadFromFile(String fileName)
Loads the text from a file.
|
void |
loadFromReader(Reader r)
Loads the text from a reader.
|
void |
loadFromStream(InputStream is)
Loads the text from a stream
|
void |
loadFromText(String text)
Loads the text.
|
protected void |
resetData()
Resets the internal data.
|
getViewerIdpublic TextContext(ViewerId vi)
vi - The viewer ID to usepublic byte[] getViewerData()
getViewerData in class ViewerContextprotected void resetData()
This method is intended to reset the internal text data if custom handling of data is needed by derived classes.
public void loadFromFile(String fileName) throws IOException
fileName - The name of the file to load the text fromNullPointerException - If the fileName argument is nullIOException - If an I/O error occurredpublic void loadFromStream(InputStream is) throws IOException
is - The stream to load the text fromNullPointerException - if the is argument is nullIOException - if an I/O error occurspublic void loadFromReader(Reader r) throws IOException
r - The reader to read the text fromNullPointerException - If the r argument is nullIOException - If an I/O error occurredpublic void loadFromText(String text)
text - The text to loadNullPointerException - If the text argument is nullpublic void appendText(String text)
text - The text to appendNullPointerException - if the text argument is nullpublic void appendLine(String line)
line - The line to append. It should not be nullNullPointerException - if the line argument is nullprotected String escapeLine(String line)
If overriden in derived classes, this method escapes a line depending on the viewer format used. The default implementation does no escaping.
line - The line to escapepublic void close()
close in class ViewerContextCopyright © 2023. All rights reserved.