oracle.jdeveloper.audit.analyzer
Class Rule
java.lang.Object
oracle.jdeveloper.audit.extension.ExtensionBean
oracle.jdeveloper.audit.analyzer.Rule
public class Rule
- extends ExtensionBean
An Audit rule. A rule reifies a condition in source code which Audit
can report. (A particular occurrence of such a condition is an
Issue
or violation
:
Audit originally used the term violation but that does not fit
advisories and incompletes, so issue is now preferred.)
Rules are defined in extension manifests by elements of
an . The definition specifies id, category, severity, and
enabled properties. The id and category are immutable properties. The id
uniquely identifies the rule. The Audit profile panel allows the user to
change the enabled and severity properties. The definition of a
rule can additionally specify a Rule
subclass for the rule and
define additional properties which the user will also be allowed to change.
These properties should be bound properties, which in practice means
that the setters should invoke the appropriate ExtensionBean.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
method.
The definition defines, implicitly or explicitly, label and
description strings for the rule. See ExtensionBean.labelOrId()
and
ExtensionBean.description()
. The object which supplies properties for these strings
is the Rule instance.
The definition also defines, implicitly or explicitly, the message string
used to describe an issue. See message(Violation)
. The object which
supplies properties for message strings is a Violation
instance.
For some rules, not all violations of the rule can be described by the
same message format string. A variation name can be set on a violation which
will cause a variation key to be tried before the default tree.
- See Also:
Violation
Field Summary |
static java.lang.String |
HTML_MESSAGE_KEY
The key for the message text of a rule. |
static int |
MAX_TRANSFORM_COUNT
The maximum number of transforms allowed by a rule. |
static java.lang.String |
MESSAGE_KEY
The key for the message text of a rule. |
Constructor Summary |
Rule()
Creates a rule. |
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, wait, wait, wait |
MESSAGE_KEY
public static final java.lang.String MESSAGE_KEY
- The key for the message text of a rule.
- See Also:
message()
,
Constant Field Values
HTML_MESSAGE_KEY
public static final java.lang.String HTML_MESSAGE_KEY
- The key for the message text of a rule.
- See Also:
htmlMessage(oracle.jdeveloper.audit.service.Violation)
,
Constant Field Values
MAX_TRANSFORM_COUNT
public static final int MAX_TRANSFORM_COUNT
- The maximum number of transforms allowed by a rule.
- See Also:
- Constant Field Values
Rule
public Rule()
- Creates a rule.
The Audit framework uses this constructor for rules declared in an
extension manifest, and then injects values for the
ExtensionBean.id()
,
ExtensionBean.extensionId()
, category
, variations
,
parameters
transforms
, and defaultTransform
fields.
copyInternalState
protected void copyInternalState(ExtensionBean copy,
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:
copy
- 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)
definition
public RuleDefinition definition()
- Gets the definition of this bean.
- Overrides:
definition
in class ExtensionBean
assist
public final boolean assist()
- Gets whether this rule is an assist.
category
public Category category()
- Gets the category of this rule.
parameters
public Rule.Parameter[] parameters()
- Gets the parameters declared by this rule, or an empty array if none.
variations
public java.lang.String[] variations()
- Gets the variations supported by this rule, or an empty array if none.
message
public java.lang.String message()
- Gets the unformatted template for the message which reports a violation of
this rule.
message
public java.lang.String message(Violation violation)
- Gets the localized violation message for a violation of this rule from its
localizer using this key for a default (null) variation:
"rule." + getName() + ".message"
and the first defined of these keys for a named variation:
"rule." + getName() + "." + violation.getVariation() + ".message"
"rule." + getName() + ".message"
- Parameters:
violation
- The violation for which to get a message.
htmlMessage
public java.lang.String htmlMessage(Violation violation)
- Gets the localized HTML violation message for a violation of this rule
from its localizer using this key for a default (null) variation:
"rule." + getName() + ".html-message"
and the first defined of these keys for a named variation:
"rule." + getName() + "." + violation.getVariation() + ".html-message"
"rule." + getName() + ".message"
- Parameters:
violation
- The violation for which to get a message.
getDefaultTransform
public final Transform getDefaultTransform()
- Gets the default transform for this rule, or null if none.
setDefaultTransformName
public void setDefaultTransformName(java.lang.String newName)
- Sets the default transform for this rule by its name. This method exists
only to support saving and restoring profiles.
- Parameters:
newName
- The name of a transform of this rule, or null.
getDefaultTransformName
public java.lang.String getDefaultTransformName()
- Gets the name of the default transform of this rule, or null if none.
This method exists to support saving and restoring profiles.
isEnabled
public final boolean isEnabled()
- Gets whether this rule is enabled.
setEnabled
public final void setEnabled(boolean newValue)
- Sets whether this rule is enabled.
getSeverity
public final Severity getSeverity()
- Gets the severity of this rule.
setSeverity
public final void setSeverity(Severity newValue)
getStyle
public final StyleCategory getStyle()
- Gets the style of this rule.
setStyle
public final void setStyle(StyleCategory newValue)
- Sets the style of this rule.
- Parameters:
newValue
- The new style of this rule.
getTransforms
public final Transform[] getTransforms()
- Gets the transforms which can be applied to violations of this rule.
- Returns:
- An array of
Transform
s. - See Also:
getDefaultTransform()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Copyright © 1997, 2011, Oracle. All rights reserved.