01: /*
02: * Created on Oct 21, 2004
03: *
04: */
05: package org.hammurapi.inspectors;
06:
07: import org.hammurapi.InspectorBase;
08:
09: import com.pavelvlasov.jsel.JselException;
10: import com.pavelvlasov.jsel.LanguageElement;
11: import com.pavelvlasov.jsel.VariableDefinition;
12: import com.pavelvlasov.review.SourceMarker;
13:
14: /**
15: * @author Johannes Bellert
16: */
17: public class SqlStatementAsInstanceVariableRule extends InspectorBase {
18:
19: public void visit(final VariableDefinition varDef) {
20: try {
21: if (varDef.getTypeSpecification().isKindOf(
22: "java.sql.Statement")
23: || varDef.getTypeSpecification().isKindOf(
24: "java.sql.PreparedStatement")
25: || varDef.getTypeSpecification().isKindOf(
26: "java.sql.ResultSet")) {
27: LanguageElement le = varDef.getParent();
28: if (le instanceof com.pavelvlasov.jsel.impl.ClassImpl) {
29: context.reportViolation((SourceMarker) varDef);
30: }
31: }
32: } catch (JselException e) {
33: context.warn((SourceMarker) varDef, e);
34: }
35: }
36: }
|