sofya.base
Class SourceHandler

java.lang.Object
  extended by sofya.base.Handler
      extended by sofya.base.SourceHandler

public class SourceHandler
extends Handler

The SourceHandler provides routines to display Java source code files.

Version:
11/19/2004
Author:
Alex Kinneer
See Also:
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

SourceHandler

public SourceHandler()
Method Detail

readSourceFile

public void readSourceFile(java.lang.String fileName)
                    throws BadFileFormatException,
                           java.io.FileNotFoundException,
                           java.io.IOException
Reads Java source code file.

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().

Parameters:
fileName - Name of the source file to be read.
Throws:
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.

getNumOfLines

public int getNumOfLines()
Gets the number of lines in the file.

Returns:
The number of lines read from the file.

getSource

public java.lang.String[] getSource()
Gets all of the lines in the file.

Returns:
A collection of all of the lines read from the file.

getSourceLine

public java.lang.String getSourceLine(int lineNumber)
                               throws java.lang.IndexOutOfBoundsException
Gets a line from the file.

Parameters:
lineNumber - Line number of the line to be retrieved.
Returns:
The matching line in the file.
Throws:
java.lang.IndexOutOfBoundsException - If lineNumber is negative or exceeds the number of lines in the source file.

main

public static void main(java.lang.String[] args)
Test driver for SourceHandler.