gov.llnl.babel.symbols
Class Extendable

java.lang.Object
  |
  +--gov.llnl.babel.symbols.Symbol
        |
        +--gov.llnl.babel.symbols.Extendable
Direct Known Subclasses:
Class, Interface

public abstract class Extendable
extends Symbol

Class Extendable is a base class for SIDL symbols of type class and interface. It brings together common methods and implementation for both final classes. Class and interfaces have a set of methods and interface inheritance in common. Classes have the additional property that they can be extended by another class; that functionality is not defined here. Many of the member functions take a boolean argument that selects whether the method refers to this particular extendable only or to this extendable and all of its parents in the SIDL inheritance system. Constraints on the validity of methods added to this object must be checked by the parser. Key design goals include providing mechanisms to: - ensure method lookups in O(1) by both long and short names; - ensure fast return of abstract, static, non-static, local, and both local and parent (or all) methods; - ensure original ordering of methods preserved when returning lists;


Field Summary
 
Fields inherited from class gov.llnl.babel.symbols.Symbol
CLASS, ENUM, INTERFACE, PACKAGE, s_type, SCOPE
 
Constructor Summary
Extendable(SymbolID id, int type, Comment comment)
          Create an empty Extendable object that will be constructed by calls to other member functions.
Extendable(SymbolID id, int type, Comment comment, Metadata m)
          Create an empty Extendable object that will be constructed by calls to other member functions.
 
Method Summary
 void addMethod(Method method)
          Add a new method to this object.
protected  void addParentData(Extendable ext)
          Protected method called by parents to add their methods and their interfaces to this extendable object.
abstract  void addParentInterface(Interface parent)
          Add a new parent interface to this class.
 java.util.Collection getAbstractMethods()
          Return the abstract methods for this class or interface, which includes all parent classes and interfaces.
 java.util.Set getAllSymbolReferences()
          Return the symbol references for the whole type hierarchy rooted with this symbol.
 java.util.Set getBasicArrayRefs()
          Return the set of basic array types for this class.
 java.util.Collection getMethods(boolean all)
          Return the methods in this interface as a Collection.
 java.util.Collection getNonstaticMethods(boolean all)
          Return the non-static methods in this interface as a Collection.
 java.util.Collection getParentInterfaces(boolean all)
          Return the parent interfaces in a Collection.
 java.util.Collection getStaticMethods(boolean all)
          Return the static methods in this interface as a Collection.
 java.util.Set getSymbolReferences()
          Return the set of symbol references for this class.
 boolean hasExceptionThrowingMethod(boolean all)
          Return whether any of the methods throw exceptions.
 boolean hasMethodByLongName(java.lang.String name, boolean all)
          Query whether the specified method exists by long name.
 boolean hasMethodByShortName(java.lang.String name, boolean all)
          Query whether the specified method exists by short name.
 boolean hasParentInterface(SymbolID id, boolean all)
          Return whether this class has the specified parent interface.
abstract  boolean hasStaticMethod(boolean all)
          Return whether any of the methods are static methods.
abstract  boolean isAbstract()
          Return whether this object contains any abstract methods.
abstract  boolean isInterface()
          Return whether this object represents an interface or a class.
 Method lookupMethodByLongName(java.lang.String name, boolean all)
          Lookup the specified method by long method name.
 java.util.Collection lookupMethodByShortName(java.lang.String name, boolean all)
          Lookup the specified method by short method name, returning the associated collection of methods, if found; otherwise, return null.
 
Methods inherited from class gov.llnl.babel.symbols.Symbol
addMetadata, getComment, getFullName, getMetadata, getSymbolID, getSymbolType, getSymbolTypeString, setComment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extendable

public Extendable(SymbolID id,
                  int type,
                  Comment comment)
Create an empty Extendable object that will be constructed by calls to other member functions.


Extendable

public Extendable(SymbolID id,
                  int type,
                  Comment comment,
                  Metadata m)
Create an empty Extendable object that will be constructed by calls to other member functions.

Method Detail

isAbstract

public abstract boolean isAbstract()
Return whether this object contains any abstract methods. A class is abstract if and only if it has any abstract methods. An interface must always be abstract, even if it contains no methods.


isInterface

public abstract boolean isInterface()
Return whether this object represents an interface or a class.


addMethod

public void addMethod(Method method)
Add a new method to this object. No checking is done whether this method is valid for this particular extendable. The new method will over-write any existing method unless the new method is abstract.


getMethods

public java.util.Collection getMethods(boolean all)
Return the methods in this interface as a Collection. If the boolean argument is true, then all methods are returned; otherwise, only locally defined methods are returned. Each element in the collection is of type Method.


getNonstaticMethods

public java.util.Collection getNonstaticMethods(boolean all)
Return the non-static methods in this interface as a Collection. If the boolean argument is true, then all non-static methods are returned; otherwise, only locally defined non- static methods are returned. Each element in the collection is of type Method.


getStaticMethods

public java.util.Collection getStaticMethods(boolean all)
Return the static methods in this interface as a Collection. If the boolean argument is true, then all static methods are returned; otherwise, only locally defined static methods are returned. Each element in the collection is of type Method.


getAbstractMethods

public java.util.Collection getAbstractMethods()
Return the abstract methods for this class or interface, which includes all parent classes and interfaces. Each element in the collection is of type Method.


lookupMethodByLongName

public Method lookupMethodByLongName(java.lang.String name,
                                     boolean all)
Lookup the specified method by long method name. If the boolean argument is true, then search all locally defined methods and all parents. If no matching method name is found, then return null.


lookupMethodByShortName

public java.util.Collection lookupMethodByShortName(java.lang.String name,
                                                    boolean all)
Lookup the specified method by short method name, returning the associated collection of methods, if found; otherwise, return null. If the boolean argument is true, then search all locally defined methods and all parents.


hasMethodByLongName

public boolean hasMethodByLongName(java.lang.String name,
                                   boolean all)
Query whether the specified method exists by long name. If the boolean argument is true, then search all locally defined methods and all parents.


hasMethodByShortName

public boolean hasMethodByShortName(java.lang.String name,
                                    boolean all)
Query whether the specified method exists by short name. If the boolean argument is true, then search all locally defined methods and all parents. Recall there may be multiple methods with the same short name but here we only care if there is at least one.


hasStaticMethod

public abstract boolean hasStaticMethod(boolean all)
Return whether any of the methods are static methods. If the boolean argument is true, then search all locally defined methods and parents.


hasExceptionThrowingMethod

public boolean hasExceptionThrowingMethod(boolean all)
Return whether any of the methods throw exceptions. If the boolean argument is true, then search all locally defined methods and parents.


addParentInterface

public abstract void addParentInterface(Interface parent)
Add a new parent interface to this class. This method will be implemented by the Class and Interface subclasses.


getParentInterfaces

public java.util.Collection getParentInterfaces(boolean all)
Return the parent interfaces in a Collection. Each member of the collection is an Interface. If the boolean argument is true, then return all parents; otherwise, return only direct parents.


hasParentInterface

public boolean hasParentInterface(SymbolID id,
                                  boolean all)
Return whether this class has the specified parent interface. If the boolean argument is true, then all parents are searched; otherwise, only the direct parents of this interface are searched.


getSymbolReferences

public java.util.Set getSymbolReferences()
Return the set of symbol references for this class. These are defined as all references for this object as well as its parents. The set of references includes this symbol name, as well. Each element of the set is a SymbolID.

Specified by:
getSymbolReferences in class Symbol

getAllSymbolReferences

public java.util.Set getAllSymbolReferences()
Description copied from class: Symbol
Return the symbol references for the whole type hierarchy rooted with this symbol. For packages, this recurses down the package hierarchy.

Specified by:
getAllSymbolReferences in class Symbol

getBasicArrayRefs

public java.util.Set getBasicArrayRefs()
Return the set of basic array types for this class.

Specified by:
getBasicArrayRefs in class Symbol

addParentData

protected void addParentData(Extendable ext)
Protected method called by parents to add their methods and their interfaces to this extendable object.