01: /*
02: * Bytecode Analysis Framework
03: * Copyright (C) 2003,2004 University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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 varName;
30:
31: /**
32: * Constructor.
33: *
34: * @param varName the name of the Variable used in this instruction
35: */
36: public OneVariableInstruction(String 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,
52: BindingSet bindingSet) {
53: bindingSet = addOrCheckDefinition(varName, variable, bindingSet);
54: return bindingSet != null ? new MatchResult(this , bindingSet)
55: : null;
56: }
57:
58: }
59:
60: // vim:ts=4
|