Extension SDK 9.0.5

oracle.jdeveloper.audit.java
Interface JavaHelper


public interface JavaHelper

A helper object that exposes Java-specific attributes and operations computed during the course of an Audit traversal but not yet available through the JOT API.

An analyzer can obtain the JavaHelper at the beginning of an audit by overriding Analyzer#enter(AuditContext) as follows:

     private JavaHelper helper;
     public void enter (AuditContext context)
     {
       helper = (JavaHelper) context.getAttribute(context.sharedKey(JavaHelper.class));
     }
 

Many of the methods below can only be invoked from an exit method for that construct; each method documents its specific invocation restrictions.


Method Summary
 JotType getArgumentType(JotUnaryExpression expression)
          Gets the actual argument type of a unary expression, or null if the argument type is unresolvable.
 JotType[] getArgumentTypes(JotClassAllocation expression)
          Gets the actual argument types of a class instance creator, one for each argument.
 JotType[] getArgumentTypes(JotInfixExpression expression)
          Gets the actual argument types of a binary expression, one for each argument.
 JotType[] getArgumentTypes(JotMethodCall expression)
          Gets the actual argument types of a method call, one for each argument.
 JotType[] getArgumentTypes(JotQuestionExpression expression)
          Gets the actual argument types of a conditional expression, one for each argument.
 JotConstructor getCalledConstructor(JotClassAllocation expression)
          Gets the constructor called by a class allocation, or null if the constructor call is unresolvable.
 JotMethod getCalledMethod(JotMethodCall expression)
          Gets the method called by a method call, or null if the method call is unresolvable.
 JotClass getClass(java.lang.String name)
          Gets a type by name, or null if not present.
 JotMethod getDeclaredMethod(JotClass type, java.lang.String name, java.lang.String[] parameterTypes)
          Gets the method declared by a type that matches a signature, or null if no matching method is declared in the type.
 JotType[] getExpressionTypes(JotForInitializer construct)
          Gets the types of the expressions in a for initializer, one for each expression.
 JotCodeElement getReferredVariable(JotMethodCall expression)
          Gets the field, local variable, or parameter referred to by the primary expression embedded in a method call, or null if none.
 JotCodeElement getReferredVariable(JotPrimaryExpression expression)
          Gets the field, local variable, or parameter referred to by a primary expression, or null if none.
 java.util.Iterator getReferredVariablesOrTypes(JotMethodCall expression)
          Gets the fields, local variables, parameters, or types referred to by each element of the primary expression embedded in a method call, in left to right order, or an empty list if none.
 java.util.Iterator getReferredVariablesOrTypes(JotPrimaryExpression expression)
          Gets the fields, local variables, parameters, or types referred to by each element of a primary expression, in left to right order, or an empty list if none.
 JotType getSearchType(JotMethodCall expression)
          Gets the type of the context for the search for the called method, or null if the type is unresolvable (in this case, getType(oracle.jdeveloper.jot.JotExpression) will also return null).
 JotType getType(JotExpression expression)
          Gets the type of an expression, or null if the type is unresolvable.
 java.util.Set getUses(JotField field)
          Gets the uses of a field within the constructs audited.
 java.util.Set getUses(JotLocalVariable method)
          Gets the uses of a local variable within the constructs audited.
 java.util.Set getUses(JotMethod method)
          Gets the uses of a method within the constructs audited.
 java.util.Set getUses(JotParameter method)
          Gets the uses of a parameter within the constructs audited.
 boolean isAssignableFrom(JotClass target, JotClass source)
          Gets whether a class is assignable from another class.
 boolean matches(JotMethod method, java.lang.String name, java.lang.String[] parameterTypes)
          Gets whether a method matches a signature.
 

Method Detail

getClass

public JotClass getClass(java.lang.String name)
Gets a type by name, or null if not present. If the name is unqualified, the search starts at the construct currently being traversed and moves outward.

Parameters:
name - The unqualified or qualified name of a class.
Throws:
java.lang.IllegalStateException - if invoked on a Workspaces or Workspace construct (one without an implicit project context).

isAssignableFrom

public boolean isAssignableFrom(JotClass target,
                                JotClass source)
Gets whether a class is assignable from another class. As of 12/16/03, this method does not use JotClass.isAssignableFrom because of bugs with primitive types and with interfaces.


getType

public JotType getType(JotExpression expression)
Gets the type of an expression, or null if the type is unresolvable.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the expression.

getExpressionTypes

public JotType[] getExpressionTypes(JotForInitializer construct)
Gets the types of the expressions in a for initializer, one for each expression. Returns a null corresponding to each expression with an unresolvable type.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the for initializer.

getCalledMethod

public JotMethod getCalledMethod(JotMethodCall expression)
Gets the method called by a method call, or null if the method call is unresolvable.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getCalledConstructor

public JotConstructor getCalledConstructor(JotClassAllocation expression)
Gets the constructor called by a class allocation, or null if the constructor call is unresolvable.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getSearchType

public JotType getSearchType(JotMethodCall expression)
Gets the type of the context for the search for the called method, or null if the type is unresolvable (in this case, getType(oracle.jdeveloper.jot.JotExpression) will also return null). For an unqualified method call, this is the class immediately enclosing the method call. For a qualified method call, this is the type of the expression or type name preceding the last ".". Note that this type may be different from (for example, be a subclass of) the type which declares the method actually called.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getArgumentTypes

public JotType[] getArgumentTypes(JotMethodCall expression)
Gets the actual argument types of a method call, one for each argument. Returns a null corresponding to each argument with an unresolvable type.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getArgumentTypes

public JotType[] getArgumentTypes(JotClassAllocation expression)
Gets the actual argument types of a class instance creator, one for each argument. Returns a null corresponding to each argument with an unresolvable type.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getArgumentTypes

public JotType[] getArgumentTypes(JotInfixExpression expression)
Gets the actual argument types of a binary expression, one for each argument. Returns a null corresponding to each argument with an unresolvable type.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the binary expression.

getArgumentTypes

public JotType[] getArgumentTypes(JotQuestionExpression expression)
Gets the actual argument types of a conditional expression, one for each argument. Returns a null corresponding to each argument with an unresolvable type.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the conditional expression.

getArgumentType

public JotType getArgumentType(JotUnaryExpression expression)
Gets the actual argument type of a unary expression, or null if the argument type is unresolvable.

Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the unary expression.

getReferredVariable

public JotCodeElement getReferredVariable(JotPrimaryExpression expression)
Gets the field, local variable, or parameter referred to by a primary expression, or null if none.

Returns:
the JotField, JotLocalVariable, or JotParameter referred to by the expression, or null.
Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the primary expression.

getReferredVariablesOrTypes

public java.util.Iterator getReferredVariablesOrTypes(JotPrimaryExpression expression)
Gets the fields, local variables, parameters, or types referred to by each element of a primary expression, in left to right order, or an empty list if none. Jot considers the a and bin a.b.c() to be part of the method call.

Returns:
an Iterator yielding the JotFields, JotLocalVariables, JotParameters, and JotTypes referred to by the embedded expression, or an empty list if none.
Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the primary expression.

getReferredVariable

public JotCodeElement getReferredVariable(JotMethodCall expression)
Gets the field, local variable, or parameter referred to by the primary expression embedded in a method call, or null if none. Jot considers the a in a.b() to be part of the method call.

Returns:
the JotField, JotLocalVariable, or JotParameter referred to by the embedded expression, or null.
Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getReferredVariablesOrTypes

public java.util.Iterator getReferredVariablesOrTypes(JotMethodCall expression)
Gets the fields, local variables, parameters, or types referred to by each element of the primary expression embedded in a method call, in left to right order, or an empty list if none. Jot considers the a and bin a.b.c() to be part of the method call.

Returns:
an Iterator yielding the JotFields, JotLocalVariables, JotParameters, and JotTypes referred to by the embedded expression, or an empty list if none.
Throws:
java.lang.IllegalArgumentException - unless invoked from the exit method for the method call.

getUses

public java.util.Set getUses(JotMethod method)
Gets the uses of a method within the constructs audited. Uses will continue to be added to the set until the audit has completed. Each use is a Location of a JotMethodCall that calls this method.

Returns:
a set of Locations from which the method is called.

getUses

public java.util.Set getUses(JotField field)
Gets the uses of a field within the constructs audited. Uses will continue to be added to the set until the audit has completed. Each use is a Location of a JotPrimaryExpression or a JotMethodCall that uses this field.

Returns:
a set of Locations from which the field is used.

getUses

public java.util.Set getUses(JotLocalVariable method)
Gets the uses of a local variable within the constructs audited. Uses will continue to be added to the set until the audit has completed. Each use is a Location of a JotPrimaryExpression or a JotMethodCall that uses this local variable.

Returns:
a set of Locations from which the local variable is used.
Throws:
java.lang.IllegalArgumentException - unless invoked from the enter (not exit) method for the local variable.

getUses

public java.util.Set getUses(JotParameter method)
Gets the uses of a parameter within the constructs audited. Uses will continue to be added to the set until the audit has completed. Each use is a Location of a JotPrimaryExpression or JotMethodCall that uses this parameter.

Returns:
a set of Locations from which the parameter is used.
Throws:
java.lang.IllegalArgumentException - unless invoked from the enter (not exit) method for the parameter.

matches

public boolean matches(JotMethod method,
                       java.lang.String name,
                       java.lang.String[] parameterTypes)
Gets whether a method matches a signature.

Parameters:
method - A Jot method.
name - The signature method name.
parameterTypes - The signature parameter types, an array of fully- qualified names, empty or null if no parameters.

getDeclaredMethod

public JotMethod getDeclaredMethod(JotClass type,
                                   java.lang.String name,
                                   java.lang.String[] parameterTypes)
Gets the method declared by a type that matches a signature, or null if no matching method is declared in the type. Superclasses and supertypes are not searched.

Parameters:
type - A Jot class.
name - The name of the method.
parameterTypes - An array of fully-qualified parameter type names.

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.