| 1 20 package net.sf.clirr.core.internal; 21 22 import net.sf.clirr.core.ApiDifference; 23 import net.sf.clirr.core.Severity; 24 import net.sf.clirr.core.Message; 25 import net.sf.clirr.core.spi.JavaType; 26 import net.sf.clirr.core.spi.Field; 27 import net.sf.clirr.core.spi.Method; 28 import net.sf.clirr.core.spi.Scope; 29 30 public abstract class AbstractDiffReporter 31 { 32 private static final Message MSG_UNABLE_TO_DETERMINE_CLASS_SCOPE = new Message(9000); 33 34 private ApiDiffDispatcher dispatcher; 35 36 public AbstractDiffReporter(ApiDiffDispatcher dispatcher) 37 { 38 this.dispatcher = dispatcher; 39 } 40 41 protected final ApiDiffDispatcher getApiDiffDispatcher() 42 { 43 return dispatcher; 44 } 45 46 protected final void log( 47 Message msg, 48 Severity severity, 49 String clazz, Method method, Field field, 50 String [] args) 51 { 52 final ApiDifference diff = new ApiDifference( 53 msg, severity, clazz, null, null, args); 54 getApiDiffDispatcher().fireDiff(diff); 55 } 56 57 75 protected final Severity getSeverity(JavaType clazz, Severity sev) 76 { 77 Scope scope = clazz.getEffectiveScope(); 78 79 if (scope.isLessVisibleThan(Scope.PROTECTED)) 80 { 81 return Severity.INFO; 82 } 83 else 84 { 85 return sev; 86 } 87 } 88 89 113 protected final Severity getSeverity(JavaType clazz, Method method, Severity sev) 114 { 115 116 if (!method.getDeclaredScope().isLessVisibleThan(Scope.PROTECTED)) 117 { 118 return getSeverity(clazz, sev); 119 } 120 else 121 { 122 return Severity.INFO; 123 } 124 } 125 126 150 protected final Severity getSeverity(JavaType clazz, Field field, Severity sev) 151 { 152 if (!field.getDeclaredScope().isLessVisibleThan(Scope.PROTECTED)) 153 { 154 return getSeverity(clazz, sev); 155 } 156 else 157 { 158 return Severity.INFO; 159 } 160 } 161 } 162 | Popular Tags |