edu.rice.cs.drjava.model
Class ClassAndInterfaceFinder

java.lang.Object
  extended by edu.rice.cs.drjava.model.ClassAndInterfaceFinder

public class ClassAndInterfaceFinder
extends Object

Class with getClassName method for finding the name of the first class or interface defined in a file


Field Summary
private  StreamTokenizer tokenizer
           
 
Constructor Summary
ClassAndInterfaceFinder(File f)
           
ClassAndInterfaceFinder(Reader r)
           
 
Method Summary
 String getClassName()
          Finds the the name of the first class (excluding interfaces) defined in this file.
 String getClassOrInterfaceName()
          Finds the the name of the first class or interface defined in this file.
(package private)  String getName(boolean interfaceOK)
          Finds the the name of the first class or interface in this file, respecting the value of the interfaceOK flag.
private  void initialize(Reader r)
           
private  boolean isClassOrInterfaceWord(int tt, boolean interfaceOK)
          returns true iff the token is "class" or we're at the end of the file
private static boolean isEOF(int tt)
           
private  boolean isPackageWord(int tt)
          returns true iff the token is "package" or we're at the end of the file
private static boolean isWord(int tt)
          returns true iff the token is a word (as defined by StreamTokenizer)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokenizer

private StreamTokenizer tokenizer
Constructor Detail

ClassAndInterfaceFinder

public ClassAndInterfaceFinder(Reader r)

ClassAndInterfaceFinder

public ClassAndInterfaceFinder(File f)
Method Detail

initialize

private void initialize(Reader r)

getClassOrInterfaceName

public String getClassOrInterfaceName()
Finds the the name of the first class or interface defined in this file.

Returns:
the String containing this name or "" if no such class or interface is found.

getClassName

public String getClassName()
Finds the the name of the first class (excluding interfaces) defined in this file.

Returns:
the String containing this name or "" if no such class or interface is found.

getName

String getName(boolean interfaceOK)
Finds the the name of the first class or interface in this file, respecting the value of the interfaceOK flag. I hate flags but did not see a simpler way to avoid duplicated code. This method has package (rather than private) visibility for testing purposes.


isWord

private static boolean isWord(int tt)
returns true iff the token is a word (as defined by StreamTokenizer)


isEOF

private static boolean isEOF(int tt)

isClassOrInterfaceWord

private boolean isClassOrInterfaceWord(int tt,
                                       boolean interfaceOK)
returns true iff the token is "class" or we're at the end of the file


isPackageWord

private boolean isPackageWord(int tt)
returns true iff the token is "package" or we're at the end of the file