openjava.mop
Class FileEnvironment

java.lang.Object
  |
  +--openjava.mop.Environment
        |
        +--openjava.mop.FileEnvironment

public class FileEnvironment
extends Environment

An environment based upon a Java source file.

The symbols available are those specified in import statements, and the class(es) defined in this file.

Since:
%SOFTWARE% 1.0
Version:
1.0
Author:
Michiaki Tatsubori
See Also:
Object

Nested Class Summary
 
Nested classes inherited from class openjava.mop.Environment
Environment.BasicVariableInfo, Environment.VariableInfo
 
Field Summary
private  Vector importedClasses
           
private  Vector importedPackages
           
private  Vector localClasses
           
private  Hashtable localClassTable
           
private  String mainClassName
           
private static HashSet nonExistentClasses
          Cache to speed up theClassExists(java.lang.String).
private  String packageName
           
 
Fields inherited from class openjava.mop.Environment
parent
 
Constructor Summary
FileEnvironment(Environment e)
           
FileEnvironment(Environment e, CompilationUnit comp_unit, String mainname)
           
FileEnvironment(Environment e, String pack, String name)
           
 
Method Summary
 void bindVariable(String name, Environment.VariableInfo info)
          binds a name to the class type.
 String getPackage()
          Gets the package name.
 String getPublicClassName()
           
 boolean importClass(String qualified_name)
          Imports a class.
 void importPackage(String name)
          Imports a package.
private  boolean isAlreadyImportedClass(String qualified_name)
           
private  boolean isCrashingClassName(String simple_name)
           
private static boolean isPrimitiveType(String name)
           
 Environment.VariableInfo lookupBind(String name)
          Looks up a binded type of the given variable or field name.
 OJClass lookupClass(String name)
          Looks a class object up.
 void record(String name, OJClass clazz)
          Records a class object.
 void recordLocalClassName(String name)
          Register a simple name as a local class
private  String searchImportedClasses(String simple_name)
           
private  String searchImportedPackages(String simple_name)
           
 void setPackage(String pack)
          Sets the package name.
private  boolean theClassExists(String class_name)
           
 String toQualifiedName(String name)
          Obtains the fully-qualified name of the given class name.
 String toString()
           
private static void writeStringVector(PrintWriter out, Vector v)
           
 
Methods inherited from class openjava.mop.Environment
bindVariable, currentClassName, getClassEnvironmentParent, getGlobalEnvironment, getParent, isBind, isQualifiedName, isRegisteredModifier, lookupClass, recordMemberClass, toPackageName, toSimpleName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

packageName

private String packageName

mainClassName

private String mainClassName

localClasses

private Vector localClasses

importedClasses

private Vector importedClasses

importedPackages

private Vector importedPackages

localClassTable

private Hashtable localClassTable

nonExistentClasses

private static HashSet nonExistentClasses
Cache to speed up theClassExists(java.lang.String).

Constructor Detail

FileEnvironment

public FileEnvironment(Environment e,
                       String pack,
                       String name)

FileEnvironment

public FileEnvironment(Environment e)

FileEnvironment

public FileEnvironment(Environment e,
                       CompilationUnit comp_unit,
                       String mainname)
Method Detail

toString

public String toString()
Specified by:
toString in class Environment

writeStringVector

private static void writeStringVector(PrintWriter out,
                                      Vector v)

getPublicClassName

public String getPublicClassName()

setPackage

public void setPackage(String pack)
Sets the package name.


getPackage

public String getPackage()
Gets the package name.

Overrides:
getPackage in class Environment

lookupClass

public OJClass lookupClass(String name)
Looks a class object up.

Overrides:
lookupClass in class Environment
Parameters:
name - the name of the fully-qualified name of the class looked for

record

public void record(String name,
                   OJClass clazz)
Records a class object.

Specified by:
record in class Environment
Parameters:
name - the fully-qualified name of the class
clazz - the class object associated with that name

importClass

public boolean importClass(String qualified_name)
Imports a class.

Parameters:
qualified_name - fully-qualified name of the imported class
Returns:
false if the given name is already registered or if it is an ambiguous name.

importPackage

public void importPackage(String name)
Imports a package.

Parameters:
name - the fully-qualified name of the imported package

toQualifiedName

public String toQualifiedName(String name)
Obtains the fully-qualified name of the given class name.

Overrides:
toQualifiedName in class Environment
Parameters:
name - a simple class name or a fully-qualified class name
Returns:
the fully-qualified name of the class

recordLocalClassName

public void recordLocalClassName(String name)
Register a simple name as a local class


isPrimitiveType

private static final boolean isPrimitiveType(String name)

searchImportedClasses

private String searchImportedClasses(String simple_name)

isAlreadyImportedClass

private boolean isAlreadyImportedClass(String qualified_name)

isCrashingClassName

private boolean isCrashingClassName(String simple_name)

searchImportedPackages

private String searchImportedPackages(String simple_name)

theClassExists

private boolean theClassExists(String class_name)

bindVariable

public void bindVariable(String name,
                         Environment.VariableInfo info)
binds a name to the class type.

Specified by:
bindVariable in class Environment
Parameters:
name - the fully-qualified name of the class
info - the class object associated with that name

lookupBind

public Environment.VariableInfo lookupBind(String name)
Description copied from class: Environment
Looks up a binded type of the given variable or field name.

Overrides:
lookupBind in class Environment
Parameters:
name - the fully-qualified name of the class

SourceForge.net_Logo