KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > bcp > OneVariableInstruction


1 /*
2  * Bytecode Analysis Framework
3  * Copyright (C) 2003,2004 University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.ba.bcp;
21
22 /**
23  * Abstract PatternElement subclass for matching single instructions which have
24  * a single Variable.
25  *
26  * @see PatternElement
27  */

28 public abstract class OneVariableInstruction extends SingleInstruction {
29     private String JavaDoc varName;
30
31     /**
32      * Constructor.
33      *
34      * @param varName the name of the Variable used in this instruction
35      */

36     public OneVariableInstruction(String JavaDoc varName) {
37         this.varName = varName;
38     }
39
40     /**
41      * Add a variable definition to the given BindingSet, or if
42      * there is an existing definition, make sure it is consistent with
43      * the new definition.
44      *
45      * @param variable the Variable which should be added or checked for consistency
46      * @param bindingSet the existing set of bindings
47      * @return a MatchResult containing the updated BindingSet (if the variable is consistent with the
48      * previous bindings), or null if the new variable is inconsistent with
49      * the previous bindings
50      */

51     protected MatchResult addOrCheckDefinition(Variable variable, BindingSet bindingSet) {
52         bindingSet = addOrCheckDefinition(varName, variable, bindingSet);
53         return bindingSet != null
54                 ? new MatchResult(this, bindingSet)
55                 : null;
56     }
57
58 }
59
60 // vim:ts=4
61
Popular Tags