|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1) E13403-04 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.jdeveloper.audit.extension.ExtensionBean oracle.jdeveloper.audit.transform.Transform
public abstract class Transform
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 Rule
s, 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 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.
Localization
For declarative tranforms, see the audit-hook schema (TODO link this) for how to supply localized strings.
For programmatically created transforms, localized label, tool tip, and
description strings are returned by this class using the Localizer
supplied to the constructor and the following keys:
See
"transform." + name() + ".label"
"transform." + name() + ".context.label"
"transform." + name() + ".tip"
"transform." + name() + ".context.tip"
"transform." + name() + ".description"
ExtensionBean.labelOrId()
, boundLabel(TransformContext)
, ExtensionBean.description()
.
Field Summary | |
---|---|
static java.lang.String |
BOUND_LABEL_KEY
The key for the bound label of a transform. |
Fields inherited from class oracle.jdeveloper.audit.extension.ExtensionBean |
---|
DESCRIPTION_KEY, LABEL_KEY, SHORT_LABEL_KEY, TIP_KEY |
Constructor Summary | |
---|---|
protected |
Transform(java.lang.String id,
java.lang.String extensionId,
TransformAdapter adapter)
Creates a transform. |
protected |
Transform(TransformAdapter adapter)
Creates a transform. |
protected |
Transform(TransformAdapter adapter,
java.lang.String name)
Creates a transform. |
protected |
Transform(TransformAdapter adapter,
java.lang.String name,
Localizer localizer)
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.IdentityHashMap<java.lang.Object,java.lang.Object> 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. |
boolean |
isEnabled()
Gets whether this transform is enabled. |
Localizer |
localizer()
Gets the localizer which supplies localized strings for this transform. |
void |
setEnabled(boolean enabled)
Sets whether this transform is enabled. |
java.lang.String |
unboundLabel()
ExtensionBean.label() , but erases missing parameters,
making it possible to reuse a transform label, which uses parameters
supplied from a violation, as generic label in the Audit profile panel. |
Methods inherited from class oracle.jdeveloper.audit.extension.ExtensionBean |
---|
addPropertyChangeListener, addPropertyChangeListener, createCopy, description, equals, extensionId, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, formattedString, formattedString, hashCode, id, label, labelOrId, logError, logWarning, propertyDescription, propertyLabel, propertyString, propertyTip, removePropertyChangeListener, removePropertyChangeListener, setCompatibilityBundle, setStrings, setters, shortLabel, string, strings, tip |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String BOUND_LABEL_KEY
boundLabel(oracle.jdeveloper.audit.transform.TransformContext)
,
Constant Field ValuesConstructor Detail |
---|
protected Transform(TransformAdapter adapter)
ExtensionBean.id
, ExtensionBean.extensionId
, condition
, and ExtensionBean.setters
fields.
adapter
- The adapter for the mutation model used by this transform.protected Transform(TransformAdapter adapter, java.lang.String name)
adapter
- The adapter for the mutation model used by this transform.name
- The unlocalized name of this transform.protected Transform(java.lang.String id, java.lang.String extensionId, TransformAdapter adapter)
id
- The id of this transform.extensionId
- The id of the extension that defined this transform.adapter
- The adapter for the mutation model used by this transform.protected Transform(TransformAdapter adapter, java.lang.String name, Localizer localizer)
adapter
- The adapter for the mutation model used by this transform.name
- The unlocalized name of this transform.localizer
- The localizer which supplies localized strings for this
transform.Method Detail |
---|
protected void copyInternalState(ExtensionBean bean, java.util.IdentityHashMap<java.lang.Object,java.lang.Object> context) throws java.lang.reflect.InvocationTargetException
ExtensionBean
copyInternalState
in class ExtensionBean
bean
- The partially initialized copy.context
- A map which allows subclasses to preserve object identity
when copying a graph of extension beans.
java.lang.reflect.InvocationTargetException
ExtensionBean.createCopy(java.util.IdentityHashMap)
public TransformContext[] createContexts(Violation violation)
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.
public TransformAdapter adapter()
public DeferredExpression condition()
public boolean isEnabled()
public void setEnabled(boolean enabled)
public Localizer localizer()
public java.lang.String unboundLabel()
ExtensionBean.label()
, but erases missing parameters,
making it possible to reuse a transform label, which uses parameters
supplied from a violation, as generic label in the Audit profile panel.
public java.lang.String boundLabel(TransformContext context)
Transform
implementation invokes the Localizer
using the first defined of these keys:
"transform." + name() + ".context.label"
"transform." + name() + ".label"
The text 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:
transform.rename-field.label=Rename Field
transform.rename-field.context.label=Rename Field "{name}" to "{suggestedName}"
Localizer
,
ExtensionBean.labelOrId()
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1) E13403-04 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |