com.objectwave.sourceParser
Class SourceCodeReader

java.lang.Object
  |
  +--com.objectwave.sourceParser.SourceCodeReader
All Implemented Interfaces:
java.io.Serializable

public class SourceCodeReader
extends java.lang.Object
implements java.io.Serializable

Will parse Java 1.1 source code to turn it into our meta model. This, hopefully, correctly deals with comments and every possible legal class definition. Unfortunately this implementation is very specific to java source code. Most notably the 1.1 sources.

Version:
$Id: SourceCodeReader.java,v 2.0 2001/06/11 15:54:25 dave_hoag Exp $
Author:
dhoag
See Also:
Serialized Form

Nested Class Summary
static class SourceCodeReader.Test
          Unit tests for SourceCodeReader
 
Constructor Summary
SourceCodeReader(java.io.Reader rdr)
          Provide the source at instantiantion time.
 
Method Summary
 java.io.BufferedReader getSource()
           
static void main(java.lang.String[] argv)
          Test routine: Currently only verifies nextJavaIdentifier() method.
static java.lang.StringBuffer nextBlockPair(java.lang.StringBuffer buf, java.io.Reader rdr, char openChar, char closeChar)
           
static java.lang.StringBuffer nextBlockPairStarting(java.lang.StringBuffer buf, java.io.Reader rdr, char openChar, char closeChar, boolean start, boolean checkComments)
          Used to get 'blocks' of code.
static java.lang.StringBuffer nextJavaIdentifier(java.lang.StringBuffer buf, java.io.Reader rdr)
          This will scan for the next valid java identifier.
protected static void parseIt(java.lang.String[] files, boolean verbose)
           
 ClassElement[] parseSource()
          Parse the source found in the instance variable 'theSource'.
protected  void parseSource(java.util.Vector elements)
          The acutal work horse method for parseSource(); This will fill the parameter 'elements' with all of the found ClassElements.
static ClassElement parseSourceFor(java.io.StringReader rdr, ClassParser def)
          Parse the paramter 'rdr' looking for a particular type of definition.
 void setSource(java.io.BufferedReader rdr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceCodeReader

public SourceCodeReader(java.io.Reader rdr)
Provide the source at instantiantion time.

Parameters:
rdr - Description of Parameter
Method Detail

setSource

public void setSource(java.io.BufferedReader rdr)
Parameters:
rdr - The new Source value

getSource

public java.io.BufferedReader getSource()
Returns:
The Source value

parseSource

public ClassElement[] parseSource()
                           throws java.io.IOException
Parse the source found in the instance variable 'theSource'.

Returns:
com.objectwave.sourceModel.ClassElement []
Throws:
java.io.IOException - Description of Exception

parseSource

protected void parseSource(java.util.Vector elements)
                    throws java.io.IOException
The acutal work horse method for parseSource(); This will fill the parameter 'elements' with all of the found ClassElements.

Parameters:
elements - Description of Parameter
Throws:
java.io.IOException - Description of Exception
See Also:
parseSource(), ClassElement

main

public static void main(java.lang.String[] argv)
Test routine: Currently only verifies nextJavaIdentifier() method.

Parameters:
argv - The command line arguments

nextBlockPair

public static java.lang.StringBuffer nextBlockPair(java.lang.StringBuffer buf,
                                                   java.io.Reader rdr,
                                                   char openChar,
                                                   char closeChar)
                                            throws java.io.IOException
Parameters:
buf - Description of Parameter
rdr - Description of Parameter
openChar - Description of Parameter
closeChar - Description of Parameter
Returns:
Description of the Returned Value
Throws:
java.io.IOException - Description of Exception

nextBlockPairStarting

public static java.lang.StringBuffer nextBlockPairStarting(java.lang.StringBuffer buf,
                                                           java.io.Reader rdr,
                                                           char openChar,
                                                           char closeChar,
                                                           boolean start,
                                                           boolean checkComments)
                                                    throws java.io.IOException
Used to get 'blocks' of code. The arguments define the blocks. Any commented out versions of the arguments will be ignored. This assumes that for every begining block specification there exist a closing block specification. Valid characters as block pair parameters MUST be valid java identifier characters... or part of my isMySpecialIdent() list. If a block element is found within a String or character literal: "{ ", '}' it will be ignored.

Parameters:
buf - Description of Parameter
rdr - Description of Parameter
openChar - Description of Parameter
closeChar - Description of Parameter
start - Description of Parameter
checkComments - Description of Parameter
Returns:
Description of the Returned Value
Throws:
java.io.IOException - Description of Exception
See Also:
#isMySpecialIdent

nextJavaIdentifier

public static java.lang.StringBuffer nextJavaIdentifier(java.lang.StringBuffer buf,
                                                        java.io.Reader rdr)
                                                 throws java.io.IOException
This will scan for the next valid java identifier. This will skip comments (and their entire commented section) thereby only retrieving relevant identifiers. I've also decided that { and } are valid java identifiers. Also, since I'm not parsing the details of a method, a '.' is a valid part of an identifier.

Parameters:
buf - Description of Parameter
rdr - Description of Parameter
Returns:
Description of the Returned Value
Throws:
java.io.IOException - Description of Exception

parseSourceFor

public static ClassElement parseSourceFor(java.io.StringReader rdr,
                                          ClassParser def)
Parse the paramter 'rdr' looking for a particular type of definition.

Parameters:
rdr - Description of Parameter
def - Description of Parameter
Returns:
Description of the Returned Value

parseIt

protected static void parseIt(java.lang.String[] files,
                              boolean verbose)
                       throws java.io.IOException
Parameters:
files - Description of Parameter
verbose - Description of Parameter
Throws:
java.io.IOException - Description of Exception