|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sofya.base.Handler sofya.base.SourceHandler
public class SourceHandler
The SourceHandler provides routines to display Java source code files.
SourceViewer
Field Summary |
---|
Fields inherited from class sofya.base.Handler |
---|
HANDLER_EXTENSIONS, LINE_SEP |
Constructor Summary | |
---|---|
SourceHandler()
|
Method Summary | |
---|---|
int |
getNumOfLines()
Gets the number of lines in the file. |
java.lang.String[] |
getSource()
Gets all of the lines in the file. |
java.lang.String |
getSourceLine(int lineNumber)
Gets a line from the file. |
static void |
main(java.lang.String[] args)
Test driver for SourceHandler. |
void |
readSourceFile(java.lang.String fileName)
Reads Java source code file. |
Methods inherited from class sofya.base.Handler |
---|
copyFile, createCacheFile, disableParseNumbers, ensureTagExists, formatSignature, isIntAvailable, isStringAvailable, newCache, openCacheFile, openInputFile, openInputFile, openOutputFile, openOutputFile, parseClass, prepareTokenizer, readInt, readIntIgnoreEOL, readJarClasses, readNextLine, readProgFile, readString, readStringIgnoreEOL, readToEOL, readToNextDataLine, toBinary, toHex |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SourceHandler()
Method Detail |
---|
public void readSourceFile(java.lang.String fileName) throws BadFileFormatException, java.io.FileNotFoundException, java.io.IOException
The source code is read from the file and stored to an internal
data structure. This data can then be retrieved via other
accessor functions in this class, such as
getSource()
.
fileName
- Name of the source file to be read.
BadFileFormatException
- If the specified file is not a Java
source code file.
java.io.FileNotFoundException
- If the specified file doesn't exist.
java.io.IOException
- If there is an error reading from the source file.public int getNumOfLines()
public java.lang.String[] getSource()
public java.lang.String getSourceLine(int lineNumber) throws java.lang.IndexOutOfBoundsException
lineNumber
- Line number of the line to be retrieved.
java.lang.IndexOutOfBoundsException
- If lineNumber
is
negative or exceeds the number of lines in the source file.public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |