| 1 | /*
|
| 2 | * ViolationSummary.java
|
| 3 | *
|
| 4 | *
|
| 5 | */
|
| 6 |
|
| 7 | package ua.gradsoft.javachecker;
|
| 8 |
|
| 9 | import java.io.*;
|
| 10 | import java.util.Collections;
|
| 11 | import java.util.Set;
|
| 12 |
|
| 13 | /**
|
| 14 | * Type of violation
|
| 15 | */
|
| 16 | public class TypeOfViolation extends StatisticItem
|
| 17 | {
|
| 18 |
|
| 19 | /** Creates a new instance of ViolationSummary
|
| 20 | *@param name - name of such statistics
|
| 21 | *@param category - category of checks.
|
| 22 | */
|
| 23 | public TypeOfViolation(String name, String category, String description, boolean enabledByDefault, boolean show, Statistics statistics) {
|
| 24 | super(name,category,description,enabledByDefault,show,statistics);
|
| 25 | counters_=new int[StatisticScope.values().length];
|
| 26 | }
|
| 27 |
|
| 28 | public void readPreferences(JavaFacts facts)
|
| 29 | {
|
| 30 | enabled_=facts.isCheckEnabled(name_);
|
| 31 | }
|
| 32 |
|
| 33 | @Deprecated
|
| 34 | public int getCounter()
|
| 35 | { return counters_[StatisticScope.ALL.ordinal()]; }
|
| 36 |
|
| 37 | public int getCounter(StatisticScope scope)
|
| 38 | { return counters_[scope.ordinal()]; }
|
| 39 |
|
| 40 |
|
| 41 | public void increment()
|
| 42 | {
|
| 43 | for(int i=0; i<counters_.length; ++i) {
|
| 44 | ++counters_[i];
|
| 45 | }
|
| 46 | if (!name_.equals("*")) {
|
| 47 | ((TypeOfViolation)owner_.getItem("*")).increment();
|
| 48 | }
|
| 49 | }
|
| 50 |
|
| 51 | @Override
|
| 52 | public double getValue(StatisticScope scope)
|
| 53 | {
|
| 54 | return counters_[scope.ordinal()];
|
| 55 | }
|
| 56 |
|
| 57 | @Override
|
| 58 | public double endScope(StatisticScope scope)
|
| 59 | {
|
| 60 | double retval = counters_[scope.ordinal()];
|
| 61 | counters_[scope.ordinal()]=0;
|
| 62 | return retval;
|
| 63 | }
|
| 64 |
|
| 65 | @Override
|
| 66 | public Set<String> getDependencies()
|
| 67 | {
|
| 68 | return Collections.<String>emptySet();
|
| 69 | }
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 | private int[] counters_;
|
| 74 |
|
| 75 |
|
| 76 | }
|