Extension SDK 9.0.5

oracle.jdeveloper.audit.transform
Class Transform

java.lang.Object
  extended byoracle.jdeveloper.audit.transform.Transform
Direct Known Subclasses:
CompositeTransform, SetVisibilityTransform

public abstract class Transform
extends java.lang.Object

A source code transform. Concrete subclasses of this class implement single source transformations at one or more source locations. It is sufficient for a subclass to implement only the method which actually changes the source code, apply(). HOwever, if a subclass also overrides isApplicable() and/or isApplied(), the framework can give better feedback to the user.

A single tranform instance can be applied in many source code contexts, so a transform cannot be created with knowledge of a particular source context. Before Audit invokes any methods of a transform, therefore, it must first bind the transform to a source location. The implementing methods of the transform access the source location through the getLocation() and getConstruct() methods. If a transform needs additional information to configure itself, it can define additional bean properties and the analyzers which create the violation can supply values for those properties as parameters to the violation.

Localized label and strings are returned by this class using the Localizer supplied to the constructor. See label().


Constructor Summary
protected Transform(java.lang.String name, Localizer localizer)
          Creates a transform.
 
Method Summary
abstract  void apply()
          Applies this transform.
 java.lang.Object getConstruct()
          Gets the construct to which the transform is bound.
 Location getLocation()
          Gets the location to which the transform is bound.
 boolean isApplicable()
          Gets whether applying this transform is likely to succeed.
 boolean isApplied()
          Gets whether this transform appears to have been already applied (whether because apply was invoked or because another agent caused the same effect).
 java.lang.String label()
          Gets the localized label text for this transform from its localizer using the key "transform." + name() + ".label" if not bound, and "transform." + name() + ".bound.label" if bound.
 java.lang.String name()
          Gets the unlocalized name of this transform.
 void setLocation(Location location)
          Sets the location to which this transform is bound.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transform

protected Transform(java.lang.String name,
                    Localizer localizer)
Creates a transform.

Parameters:
name - The unlocalized name of this transform.
localizer - The localizer which supplies localized strings for this transform.
Method Detail

name

public java.lang.String name()
Gets the unlocalized name of this transform.


setLocation

public void setLocation(Location location)
Sets the location to which this transform is bound. This method is used by the framework to bind and unbind (setLocation(null)) this transform.


getLocation

public Location getLocation()
Gets the location to which the transform is bound.

Throws:
java.lang.IllegalStateException - if this transform is not bound.

getConstruct

public java.lang.Object getConstruct()
Gets the construct to which the transform is bound.

Throws:
java.lang.IllegalStateException - if this transform is not bound.

isApplicable

public boolean isApplicable()
Gets whether applying this transform is likely to succeed. The framework invokes this method inside a read lock on the document containing the transform location. The default Transform implementation returns true. If a subclass can test for situations where apply is sure to fail, it can override this method to make the test and return false if it fails. Note that the Audit framework handles the case of unmodifiable documents.

Throws:
java.lang.IllegalStateException - if this transform is not bound.

apply

public abstract void apply()
Applies this transform. The framework invokes this method inside a write lock on the document containing the transform location, only if isApplicable() returns true and isApplied() returns false.

Throws:
java.lang.IllegalStateException - if this transform is not bound.

isApplied

public boolean isApplied()
Gets whether this transform appears to have been already applied (whether because apply was invoked or because another agent caused the same effect). The framework invokes this method inside a read lock on the document containing the transform location. The default Transform implementation returns false.

Throws:
java.lang.IllegalStateException - if this transform is not bound.

label

public java.lang.String label()
Gets the localized label text for this transform from its localizer using the key "transform." + name() + ".label" if not bound, and "transform." + name() + ".bound.label" if bound. This text can refer to properties of this transform using the property name enclosed in braces. For example, a concrete Transform named "rename-field" which has name and suggestedName properties (populated only when the transform is bound) might have the following in its resource bundle:
   transform.rename-field.label=Rename Field
   transform.rename-field.bound.label=Rename field "{name}" to "{suggestedName}"
 

See Also:
Localizer

Extension SDK

 

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