FindBugs™ 1.3.9

edu.umd.cs.findbugs.ba.bcp
Class MatchAny

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.bcp.PatternElement
      extended by edu.umd.cs.findbugs.ba.bcp.MatchAny

public class MatchAny
extends PatternElement

A "meta" PatternElement that matches any of a list of other child PatternElements. An example of how this is useful is that you might want to match invocations of any of a number of different methods. To do this, you can create a MatchAny with some number of Invoke elements as children.

Note that the minOccur() and maxOccur() counts of the child PatternElements are ignored. A MatchAny element always matches exactly one instruction.

Author:
David Hovemeyer
See Also:
PatternElement

Constructor Summary
MatchAny(PatternElement[] childList)
          Constructor.
 
Method Summary
 boolean acceptBranch(Edge edge, org.apache.bcel.generic.InstructionHandle source)
          Return whether or not it is acceptable to take the given branch.
 PatternElement label(java.lang.String label)
          Set a label for this PatternElement.
 MatchResult match(org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet)
          Return whether or not this element matches the given instruction with the given Bindings in effect.
 int maxOccur()
          Return the maximum number of instructions this PatternElement must match in the ByteCodePattern.
 int minOccur()
          Return the minimum number of instructions this PatternElement must match in the ByteCodePattern.
 PatternElement setAllowTrailingEdges(boolean allowTrailingEdges)
          Set whether or not this PatternElement allows trailing edges to be matched.
 
Methods inherited from class edu.umd.cs.findbugs.ba.bcp.PatternElement
addOrCheckDefinition, allowTrailingEdges, dominatedBy, getDominatedBy, getLabel, getNext, lookup, setIndex, setNext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MatchAny

public MatchAny(PatternElement[] childList)
Constructor.

Parameters:
childList - list of child PatternElements
Method Detail

label

public PatternElement label(java.lang.String label)
Description copied from class: PatternElement
Set a label for this PatternElement.

Overrides:
label in class PatternElement
Parameters:
label - the label
Returns:
this object

setAllowTrailingEdges

public PatternElement setAllowTrailingEdges(boolean allowTrailingEdges)
Description copied from class: PatternElement
Set whether or not this PatternElement allows trailing edges to be matched. By default, trailing edges may be matched. When this value is set to false, it ensures that the successor instruction must be in the same basic block.

Overrides:
setAllowTrailingEdges in class PatternElement
Parameters:
allowTrailingEdges - true if trailing edges may be matched, false if trailing edges will never be matched

match

public MatchResult match(org.apache.bcel.generic.InstructionHandle handle,
                         org.apache.bcel.generic.ConstantPoolGen cpg,
                         ValueNumberFrame before,
                         ValueNumberFrame after,
                         BindingSet bindingSet)
                  throws DataflowAnalysisException
Description copied from class: PatternElement
Return whether or not this element matches the given instruction with the given Bindings in effect.

Specified by:
match in class PatternElement
Parameters:
handle - the instruction
cpg - the ConstantPoolGen from the method
before - the ValueNumberFrame representing values in the Java stack frame just before the execution of the instruction
after - the ValueNumberFrame representing values in the Java stack frame just after the execution of the instruction
bindingSet - the set of Bindings
Returns:
if the match is successful, returns a MatchResult with the PatternElement and BindingSet; if the match is not successful, returns null
Throws:
DataflowAnalysisException

acceptBranch

public boolean acceptBranch(Edge edge,
                            org.apache.bcel.generic.InstructionHandle source)
Description copied from class: PatternElement
Return whether or not it is acceptable to take the given branch.

Specified by:
acceptBranch in class PatternElement
Parameters:
edge - the Edge representing the branch
source - the source instruction of the branch
Returns:
true if the Edge is acceptable, false if not

minOccur

public int minOccur()
Description copied from class: PatternElement
Return the minimum number of instructions this PatternElement must match in the ByteCodePattern.

Specified by:
minOccur in class PatternElement

maxOccur

public int maxOccur()
Description copied from class: PatternElement
Return the maximum number of instructions this PatternElement must match in the ByteCodePattern.

Specified by:
maxOccur in class PatternElement

FindBugs™ 1.3.9

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.