Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.jdeveloper.audit.transform
Class Transform

java.lang.Object
  extended by oracle.jdeveloper.audit.extension.ExtensionBean
      extended by oracle.jdeveloper.audit.transform.Transform

Direct Known Subclasses:
CompositeTransform

public abstract class Transform
extends ExtensionBean

A source code transform. Concrete subclasses of this class implement single source transformations at one or more source locations. This base class supplies name and label methods which allow the Audit framework to describe the transform. Concrete subclasses must supply one or more apply methods that apply the transform, and can supply isApplicable methods that evaluate whether the transform is currently applicable, query methods that query the user for transforms that require user input, and isQueryRequired methods that, when a query method is present, evaluate whether the user really needs to be queried. The Audit framework discovers transforms through their attachment to Rules, and uses introspection to find the apply, isApplicable, isQueryRequired, and query methods they declare.

Transforms are stateless objects. The Audit framework creates only one instance of each kind of transform. Transform methods rely on a context argument supplied by the Audit framework to supply the state they need. That state always includes the issue which the transform addresses; transform methods can share state through the context when necessary. Transform should not have instance fields.

A transform addresses a single violation and each violation is associated with a construct in an object model. Different object models handle the details of mutating an object model (locks, transaction, and so forth) differently, so the Audit framework delegates this to an implementation of the abstract TransformAdapter class. A transform is constructed with an appropriate transform adapter; for example, a transform for the JDeveloper Java model (oracle.javatools.parser.java.v2.model) would be constructed with a oracle.jdeveloper.audit.java.JavaTransformAdapter. The apply, isApplicable, isQueryRequired, and query methods all require access to the construct, and to parameters of the violation, so they take two arguments, a TransformContext argument, and a construct argument. The actual declared class of the transform context argument can be a subclass of TransformContext, and the actual declared class of the construct argument can be its class or any supertype of its class. If more than one apply, isApplicable, isQueryRequired, or query method is present, the one with the most specific matching construct type is invoked.

isApplicable, isQueryRequired, query, and apply Methods
An isApplicable(context,construct) method, if matched, should return whether the transform can be applied in the context to the construct. If no isApplicable method is matched, the transform is assumed to be applicable.

An isQueryRequired(context,construct) method, if matched, should return whether the corresponding query method should be invoked to query the user. If no isQueryRequired method is matched, a query is assumed to be required only if a corresponding query method is present.

A query(context,construct) should query the user using a Swing dialog and return true unless the user cancels. It should use TransformContext.setAttribute(java.lang.String, java.lang.Object) to save query results for apply to use.

An apply(context,construct) method should apply the transform in the context. It can assume that any conditions tested isApplicable are still true. If a query was required, it should use TransformContext.getAttribute(java.lang.String) to get the query results.

Composite Transforms Some transforms require modifying a file other than the one containing the violation, modifying more than one file, chaining to another transform, and/or using more than one kind of transform adapter. That can be handled by overriding createContexts(oracle.jdeveloper.audit.service.Violation) to return one or more alternate contexts in which to apply the tranform. Each TransformContext can call out a different Location, Transform, and/or TransformAdapter. When applying a transform, the framework first call all the iisApplicaable methods in the order returned from createContexts. If all are true, it then calls all the isQueryRequired/query methods, if any, in order. If not cancelled, it then calls all the apply methods in order. If any fail, the partial applies are rolled back.


Field Summary
static java.lang.String BOUND_LABEL_KEY
          The name for the bound label of a transform.

 

Fields inherited from class oracle.jdeveloper.audit.extension.ExtensionBean
DESCRIPTION_KEY, LABEL_KEY

 

Constructor Summary
protected Transform(TransformAdapter adapter)
          Creates a transform.

 

Method Summary
 TransformAdapter adapter()
          Gets the transform adapter used by this transform.
 java.lang.String boundLabel(TransformContext context)
          Gets the contextual localized label text for this transform.
 DeferredExpression condition()
          Gets the condition for this transform, or null if none.
protected  void copyInternalState(ExtensionBean bean, java.util.Map<java.lang.String,ExtensionBean> context)
          Copies internal subclass state as part of creating a copy of this bean.
 TransformContext[] createContexts(Violation violation)
          Creates the transform contexts for this transform, or null or an empty array if the contexts cannot be created.
 TransformDefinition definition()
          Gets the definition of this bean.
 boolean isEnabled()
          Gets whether this transform is enabled.
 void setEnabled(boolean enabled)
          Sets whether this transform is enabled.
 java.lang.String unboundLabel()
          Gets the localized ExtensionBean.label() for this transform, but erases missing parameters.
 java.util.Collection<java.lang.String> variations()
          Gets the variations for this transform, or null if none.

 

Methods inherited from class oracle.jdeveloper.audit.extension.ExtensionBean
addPropertyChangeListener, addPropertyChangeListener, createCopy, description, equals, extensionId, extensionLine, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, formattedString, formattedString, formattedString, hashCode, id, key, label, labelOrId, logError, logError, logWarning, name, propertyDescription, propertyLabel, removePropertyChangeListener, removePropertyChangeListener, setters, string

 

Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

BOUND_LABEL_KEY

public static final java.lang.String BOUND_LABEL_KEY
The name for the bound label of a transform.
See Also:
boundLabel(oracle.jdeveloper.audit.transform.TransformContext), Constant Field Values

Constructor Detail

Transform

protected Transform(TransformAdapter adapter)
Creates a transform. This constructor is for subclasses declared in an extension manifest. The Audit framework injects the values of the ExtensionBean.id(), ExtensionBean.extensionId(), (@link variations}, condition, and ExtensionBean.setters fields.
Parameters:
adapter - The adapter for the mutation model used by this transform.

Method Detail

copyInternalState

protected void copyInternalState(ExtensionBean bean,
                                 java.util.Map<java.lang.String,ExtensionBean> context)
                          throws java.lang.reflect.InvocationTargetException
Description copied from class: ExtensionBean
Copies internal subclass state as part of creating a copy of this bean.
Overrides:
copyInternalState in class ExtensionBean
Parameters:
bean - The partially initialized copy.
context - A map which allows subclasses to preserve object identity when copying a graph of extension beans.
Throws:
java.lang.reflect.InvocationTargetException
See Also:
ExtensionBean.createCopy(java.util.Map<java.lang.String, oracle.jdeveloper.audit.extension.ExtensionBean>)

createContexts

public TransformContext[] createContexts(Violation violation)
Creates the transform contexts for this transform, or null or an empty array if the contexts cannot be created.

The default Transform implementation invokes the TransformAdapter.createContext(oracle.jdeveloper.audit.transform.Transform, oracle.jdeveloper.audit.service.Violation, oracle.jdeveloper.audit.model.Location) method of its transform adapter to create a context for this transform at the violation location, i.e.:

   adapter().createContext(this, violation, violation.getLocation())
 

A transform can override this method to delegate to a different transform at a different location, or this transform at several locations, etcetera. The Audit framework will aggregate the transform isApplicable, query, and apply methods.


definition

public TransformDefinition definition()
Gets the definition of this bean.
Overrides:
definition in class ExtensionBean

adapter

public TransformAdapter adapter()
Gets the transform adapter used by this transform.

variations

public java.util.Collection<java.lang.String> variations()
Gets the variations for this transform, or null if none.

condition

public DeferredExpression condition()
Gets the condition for this transform, or null if none.

isEnabled

public boolean isEnabled()
Gets whether this transform is enabled. A disabled transform will not be exposed to a user outside of the profile user interface.

setEnabled

public void setEnabled(boolean enabled)
Sets whether this transform is enabled. A disabled transform will not be exposed to a user outside of the profile user interface.

unboundLabel

public java.lang.String unboundLabel()
Gets the localized ExtensionBean.label() for this transform, but erases missing parameters. This allows a transform label which uses parameters supplied from a violation to also serve as a generic label in the Audit profile panel.

boundLabel

public java.lang.String boundLabel(TransformContext context)
Gets the contextual localized label text for this transform. The default Transform implementation invokes the ExtensionBean.formattedString(java.lang.String) method using the first defined of these names: using the first defined of these keys:
 "bound.label"
 "label"
 
The message template can reference parameters of the violation and properties of the transform.

For example, a concrete Transform named "rename-field" for which the violation is expected to have name and suggestedName parameters might have the following in its resource bundle:

 rename-field.label=Rename Field
 transform.rename-field.bound-label=Rename Field "{name}" to "{suggestedName}"
 
See Also:
ExtensionBean.labelOrId()

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


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