gov.llnl.babel.symbols
Class Method

java.lang.Object
  extended bygov.llnl.babel.symbols.Method
All Implemented Interfaces:
java.lang.Cloneable

public class Method
extends java.lang.Object
implements java.lang.Cloneable

The Method class defines a sidl method, including modifiers, return type, name, arguments, and exceptions. Methods may have one of three definition modifiers: final, static, or abstract. They may also have one of two communication modifiers: local or oneway. The return type is either a type or null (which indicates void). The method name is a simple identifier string. The optional arguments are an ordered collection or arguments. The method may throw any number of exceptions.


Field Summary
static int ABSTRACT
           
static int FINAL
           
static int LOCAL
           
static int NORMAL
           
static int ONEWAY
           
static java.lang.String[] s_comm_mod
           
static java.lang.String[] s_def_mod
           
static int STATIC
           
 
Constructor Summary
Method()
          Create an empty Method object that will be built by calls to other member functions.
 
Method Summary
 void addArgument(Argument arg)
          Add another argument to the end of the list of method arguments.
 void addThrows(SymbolID id)
          Add a symbol identifier to the list of supported exceptions for this method.
 Method cloneMethod()
          Return a shallow copy of this method object.
 java.util.ArrayList getArgumentList()
          Return the array of arguments in an ArrayList container.
 java.util.Set getBasicArrays()
          Return the set of basic array references SymbolIDs.
 Comment getComment()
          Get the comment for the method.
 int getCommunicationModifier()
          Get the communication modifier for this method.
 java.lang.String getCommunicationModifierString()
          Return the communication modifier string for this method.
 int getDefinitionModifier()
          Return the definition modifier for the method.
 java.lang.String getDefinitionModifier(boolean is_interface)
          Return the explicit definition modifier string for the method based on the type of extendable in which it belongs.
 java.lang.String getLongMethodName()
          Return the long name of the method (a standard sidl identifier).
 java.lang.String getNameExtension()
          Return the name extension of the method (a standard sidl identifier).
 Type getReturnType()
          Get the return type for the method.
 java.lang.String getReturnType(java.lang.String parent_pkg)
          Return the string corresponding to the return type for this method.
 java.lang.String getShortMethodName()
          Return the short name of the method (a standard sidl identifier).
 java.lang.String getSignature()
          Return the signature of the method.
 java.lang.String getSignature(boolean is_interface, java.lang.String parent_pkg)
          Return the signature of the method, including the definition modifier based on the extendable type.
 java.lang.String getSignaturePreface(boolean is_interface, java.lang.String parent_pkg)
          Return the concatenation of the explicit definition modifier, copy, return type, name and extension.
 java.util.Set getSymbolReferences()
          Return the set of symbols referred to by this method.
 java.util.Set getThrows()
          Retrieve the set of exceptions that may be thrown by this method.
 boolean hasArrayOrderSpec()
          Return true if and only if at least one argument of this method is an array with an ordering specification.
 boolean isAbstract()
          Return whether the method is abstract.
 boolean isFinal()
          Return whether the methos is final.
 boolean isReturnCopy()
          Get the copy mode for the return type.
 boolean isStatic()
          Return whether the method is static.
 boolean sameBaseSignature(Method m)
          Compare the base signatures of the two methods.
 boolean sameSignature(Method m)
          Compare the signatures of two methods.
 void setComment(Comment comment)
          Set the comment for the method.
 void setCommunicationModifier(int modifier)
          Set the communication modifier for the method.
 void setDefinitionModifier(int modifier)
          Set the definition modifier for the method.
 void setMethodName(java.lang.String shortName)
          Set the names of the method (a standard sidl identifier).
 void setMethodName(java.lang.String shortName, java.lang.String extension)
          Set the names of the method (a standard sidl identifier).
 void setReturnCopy(boolean copy)
          Set the copy mode for the return type.
 void setReturnType(Type type)
          Set the return type for the method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

ABSTRACT

public static final int ABSTRACT
See Also:
Constant Field Values

FINAL

public static final int FINAL
See Also:
Constant Field Values

STATIC

public static final int STATIC
See Also:
Constant Field Values

LOCAL

public static final int LOCAL
See Also:
Constant Field Values

ONEWAY

public static final int ONEWAY
See Also:
Constant Field Values

s_def_mod

public static final java.lang.String[] s_def_mod

s_comm_mod

public static final java.lang.String[] s_comm_mod
Constructor Detail

Method

public Method()
Create an empty Method object that will be built by calls to other member functions.

Method Detail

cloneMethod

public Method cloneMethod()
Return a shallow copy of this method object. This method should never fail since this method is cloneable. Send in the clones.


addArgument

public void addArgument(Argument arg)
Add another argument to the end of the list of method arguments.


getArgumentList

public java.util.ArrayList getArgumentList()
Return the array of arguments in an ArrayList container.


setComment

public void setComment(Comment comment)
Set the comment for the method. This may be null if there is no comment.


getComment

public Comment getComment()
Get the comment for the method. This may be null if there is no comment.


setCommunicationModifier

public void setCommunicationModifier(int modifier)
Set the communication modifier for the method. Valid modifiers are NORMAL, LOCAL, or ONEWAY.


getCommunicationModifier

public int getCommunicationModifier()
Get the communication modifier for this method. Valid values are NORMAL, LOCAL, or ONEWAY.


getCommunicationModifierString

public java.lang.String getCommunicationModifierString()
Return the communication modifier string for this method.


setDefinitionModifier

public void setDefinitionModifier(int modifier)
Set the definition modifier for the method. Valid modifiers are NORMAL, ABSTRACT, FINAL, or STATIC.


getDefinitionModifier

public int getDefinitionModifier()
Return the definition modifier for the method. Valid modifiers are NORMAL, ABSTRACT, FINAL, or STATIC.


getDefinitionModifier

public java.lang.String getDefinitionModifier(boolean is_interface)
Return the explicit definition modifier string for the method based on the type of extendable in which it belongs. At this time, ABSTRACT is implied for an Interface and all of the others (except NORMAL) are invalid.

Parameters:
is_interface - the boolean indication of the type of extendable to which the method belongs.
Returns:
the string associated with the explicit definition modifier

isAbstract

public boolean isAbstract()
Return whether the method is abstract.


isFinal

public boolean isFinal()
Return whether the methos is final.


isStatic

public boolean isStatic()
Return whether the method is static.


hasArrayOrderSpec

public boolean hasArrayOrderSpec()
Return true if and only if at least one argument of this method is an array with an ordering specification. Calling this on methods without array arguments will return false. Calling this method on something like void doIt(in array<int, 2, row-major> x); will return true.


setMethodName

public void setMethodName(java.lang.String shortName,
                          java.lang.String extension)
Set the names of the method (a standard sidl identifier).


setMethodName

public void setMethodName(java.lang.String shortName)
Set the names of the method (a standard sidl identifier). Use of this method will set the long and short name to be identical.


getShortMethodName

public java.lang.String getShortMethodName()
Return the short name of the method (a standard sidl identifier).


getNameExtension

public java.lang.String getNameExtension()
Return the name extension of the method (a standard sidl identifier).


getLongMethodName

public java.lang.String getLongMethodName()
Return the long name of the method (a standard sidl identifier).


setReturnCopy

public void setReturnCopy(boolean copy)
Set the copy mode for the return type. If true, then the return interface or class is copied to the caller.


isReturnCopy

public boolean isReturnCopy()
Get the copy mode for the return type. If true, then the return interface or class is copied to the caller.


setReturnType

public void setReturnType(Type type)
Set the return type for the method. A void return type must be represented by a Type object with value Type.VOID, not a null reference.


getReturnType

public Type getReturnType()
Get the return type for the method. A void return type is represented by a Type object with a value of Type.VOID.


addThrows

public void addThrows(SymbolID id)
Add a symbol identifier to the list of supported exceptions for this method. No error checking is performed to ensure that the specified symbol is valid in the throws clause; such checking must be performed by the parser.


getThrows

public java.util.Set getThrows()
Retrieve the set of exceptions that may be thrown by this method. The exceptions are returned in a Set object that contains the SymbolID symbol identifiers for the exception types.


getSymbolReferences

public java.util.Set getSymbolReferences()
Return the set of symbols referred to by this method. Each element of the set is a SymbolID.


getBasicArrays

public java.util.Set getBasicArrays()
Return the set of basic array references SymbolIDs. This set includes arrays of the fundamental types such as double, int, etc. as SymbolID objects.


getReturnType

public java.lang.String getReturnType(java.lang.String parent_pkg)
Return the string corresponding to the return type for this method.

Parameters:
parent_pkg - the string containing the parent package. When not null, it is used to strip the package from the return string if it is in the specified package.
Returns:
the string containing the possibly abbreviated return type.

getSignaturePreface

public java.lang.String getSignaturePreface(boolean is_interface,
                                            java.lang.String parent_pkg)
Return the concatenation of the explicit definition modifier, copy, return type, name and extension.

Parameters:
is_interface - True if interface and want the implicit definition modifier excluded from the result; otherwise, false
parent_pkg - the string containing the parent package. When not null, it is used to strip the package from the return string if it is in the specified package.
Returns:
the string containing the preface

getSignature

public java.lang.String getSignature(boolean is_interface,
                                     java.lang.String parent_pkg)
Return the signature of the method, including the definition modifier based on the extendable type. Also, optionally abbreviate type if in specified package.

Parameters:
is_interface - True if interface and want the implicit definition modifier excluded from the result; otherwise, false
parent_pkg - the string containing the parent package. When not null, it is used to strip the package from the return string if it is in the specified package.
Returns:
the string containing the full signature

getSignature

public java.lang.String getSignature()
Return the signature of the method. The signature does not include the attributes abstract, final, or static. It also does not abbreviate package names.


sameSignature

public boolean sameSignature(Method m)
Compare the signatures of two methods. For signatures to match, the methods must have the same return types and mode, the same names, the same arguments, and the same throws clauses. They must also have the same communication modifiers. The signature does not include modifiers static, abstract, or final.


sameBaseSignature

public boolean sameBaseSignature(Method m)
Compare the base signatures of the two methods. For them to match, the methods must have the same short and the same arguments.