1 23 package org.hammurapi; 24 25 import java.util.Collection ; 26 import java.util.LinkedList ; 27 28 import com.pavelvlasov.config.ConfigurationException; 29 import com.pavelvlasov.config.RuntimeConfigurationException; 30 31 36 public class SelfDescribingInspectorProxy implements InspectorDescriptor { 37 private InspectorDescriptor sourceDescriptor; 38 39 private InspectorDescriptor ruleDescriptor=new InspectorDescriptor() { 40 public String getDescription() { return null; } 41 public Boolean isEnabled() { return null; } 42 public String getName() { return null; } 43 public Integer getSeverity() { return null; } 44 public Integer getOrder() { return null; } 45 public String getRationale() { return null; } 46 public String getViolationSample() { return null; } 47 public String getFixSample() { return null; } 48 public String getResources() { return null; } 49 public String getMessage() { return null; } 50 public Inspector getInspector() { return null; } 51 public Collection getParameters() { return null; } 52 public String getMessage(String key) { return null; } 53 public Boolean isWaivable() { return null; } 54 public Collection getWaiveCases() { return new LinkedList (); } 55 public String getWaivedInspectorName(String inspectorKey) { return null; } 56 public String getWaiveReason(String inspectorKey) { return null; } 57 public Collection getWaivedInspectorNames() { return null; } 58 public String getCategory() { return null; } 59 public Collection getFilteredInspectorDesriptors(InspectorSet inspectorSet, Collection chain) { 60 return chain; 61 } 62 public Collection getAfterInspectorNames() { return null; } 63 }; 65 private boolean ruleInstantiated=false; 66 67 public SelfDescribingInspectorProxy(InspectorDescriptor descriptor) { 68 super(); 69 sourceDescriptor=descriptor; 70 } 71 72 private InspectorDescriptor getInspectorDescriptor() { 73 if (!ruleInstantiated) { 74 try { 75 Inspector rule=sourceDescriptor.getInspector(); 76 if (rule instanceof InspectorDescriptor) { 77 ruleDescriptor=(InspectorDescriptor) rule; 78 } 79 ruleInstantiated=true; 80 } catch (ConfigurationException e) { 81 throw new RuntimeConfigurationException("Can't instantiate inspector", e); 82 } 83 } 84 return ruleDescriptor; 85 } 86 87 public String getCategory() { 88 return getInspectorDescriptor().getCategory(); 89 } 90 91 public String getDescription() { 92 return getInspectorDescriptor().getDescription(); 93 } 94 95 public Boolean isEnabled() { 96 return getInspectorDescriptor().isEnabled(); 97 } 98 99 public String getName() { 100 return getInspectorDescriptor().getName(); 101 } 102 103 public Integer getSeverity() { 104 return getInspectorDescriptor().getSeverity(); 105 } 106 107 public Integer getOrder() { 108 return getInspectorDescriptor().getOrder(); 109 } 110 111 public String getRationale() { 112 return getInspectorDescriptor().getRationale(); 113 } 114 115 public String getViolationSample() { 116 return getInspectorDescriptor().getViolationSample(); 117 } 118 119 public String getFixSample() { 120 return getInspectorDescriptor().getFixSample(); 121 } 122 123 public String getResources() { 124 return getInspectorDescriptor().getResources(); 125 } 126 127 public String getMessage() { 128 return getInspectorDescriptor().getMessage(); 129 } 130 131 public Inspector getInspector() throws ConfigurationException { 132 return getInspectorDescriptor().getInspector(); 133 } 134 135 public Collection getParameters() { 136 return getInspectorDescriptor().getParameters(); 137 } 138 139 public String getMessage(String key) { 140 return getInspectorDescriptor().getMessage(key); 141 } 142 143 public Boolean isWaivable() { 144 return getInspectorDescriptor().isWaivable(); 145 } 146 147 public Collection getWaiveCases() { 148 return getInspectorDescriptor().getWaiveCases(); 149 } 150 151 public String getWaivedInspectorName(String inspectorKey) { 152 return getInspectorDescriptor().getWaivedInspectorName(inspectorKey); 153 } 154 155 public String getWaiveReason(String inspectorKey) { 156 return getInspectorDescriptor().getWaiveReason(inspectorKey); 157 } 158 159 public Collection getWaivedInspectorNames() { 160 return getInspectorDescriptor().getWaivedInspectorNames(); 161 } 162 163 public Collection getFilteredInspectorDesriptors(InspectorSet inspectorSet, Collection chain) { 164 return getInspectorDescriptor().getFilteredInspectorDesriptors(inspectorSet, chain); 165 } 166 167 public Collection getAfterInspectorNames() { 168 return getInspectorDescriptor().getAfterInspectorNames(); 169 } 170 } 171 | Popular Tags |