    001    package escjava;
    002
    003    import java.awt.Color;
    004
    005    public class Status {
    006        final static public int ILLEGAL = -1; // A value that should only be used
    007                                              // for temporary initialization
    008        final static public int NOTPROCESSED = 0;
    009        final static public int RESOLVED_OK = 1;
    010        final static public int RESOLVED_CAUTION = 2;
    011        final static public int RESOLVED_ERROR = 3;
    012        final static public int RESOLVED_COMPLETE = RESOLVED_ERROR;
    013        final static public int PARSED_OK = 4;
    014        final static public int PARSED_CAUTION = 5;
    015        final static public int PARSED_ERROR = 6;
    016        final static public int PARSING_COMPLETE = PARSED_ERROR;
    017        final static public int TYPECHECKED_ERROR = 7;
    018        final static public int TYPECHECKED_CAUTION = 8;
    019        final static public int TYPECHECKED_WAITING = 9;
    020        final static public int TYPECHECKED_OK = 10;
    021        final static public int TYPECHECK_COMPLETE = TYPECHECKED_OK;
    022        final static public int STATICCHECKED_ERROR = 11;
    023        final static public int STATICCHECKED_CAUTION = 12;
    024        final static public int STATICCHECKED_OK = 13;
    025        final static public int STATICCHECKED_PASSEDIMMED = 14;
    026        final static public int STATICCHECKED_TIMEOUT = 15;
    027        final static public int CHILDERROR = 16;
    028
    029        public static boolean isOK(int s) {
    030            return  s == RESOLVED_OK || s == PARSED_OK
    031                    || s == TYPECHECKED_OK || s == STATICCHECKED_OK
    032                    || s == TYPECHECKED_WAITING
    033                    || s == STATICCHECKED_PASSEDIMMED;
    034        }
    035
    036        public static boolean isError(int s) {
    037            return s == RESOLVED_ERROR || s == PARSED_ERROR
    038                    || s == TYPECHECKED_ERROR || s == STATICCHECKED_TIMEOUT
    039                    || s == STATICCHECKED_ERROR;
    040        }
    041
    042        final static public boolean checkComplete(int s) {
    043            return s > TYPECHECK_COMPLETE;
    044        }
    045
    046        final static public boolean typecheckComplete(int s) {
    047            return s > PARSING_COMPLETE;
    048        }
    049
    050        final static public boolean parsingComplete(int s) {
    051            return s > RESOLVED_COMPLETE;
    052        }
    053
    054        final static public boolean resolved(int s) {
    055            return s > NOTPROCESSED;
    056        }
    057
    058        static public /*@ non_null @*/ String toString(int status) {
    059            switch (status) {
    060                case NOTPROCESSED: return "Not Processed";
    061                case RESOLVED_OK: return "Resolved OK";
    062                case RESOLVED_CAUTION: return "Resolved with Cautions";
    063                case RESOLVED_ERROR: return "Resolved with Errors";
    064                case PARSED_OK: return "Parsed OK";
    065                case PARSED_CAUTION: return "Parsed with Cautions";
    066                case PARSED_ERROR: return "Parsed with Errors";
    067                case TYPECHECKED_ERROR: return "Typechecked with Errors";
    068                case TYPECHECKED_CAUTION: return "Typechecked with Cautions";
    069                case TYPECHECKED_WAITING: return "Typechecking children";
    070                case TYPECHECKED_OK: return "Typechecked OK";
    071                case STATICCHECKED_ERROR: return "Static checked with Warnings";
    072                case STATICCHECKED_CAUTION: return "Static checked with Cautions";
    073                case STATICCHECKED_OK: return "Static checked OK";
    074                case STATICCHECKED_TIMEOUT: return "Static checking timed out";
    075                case STATICCHECKED_PASSEDIMMED: return "Static checking passed - no body to check";
    076                case CHILDERROR: return "Child node has an error";
    077            }
    078            return "ILLEGAL VALUE";
    079        }
    080
    081        static public Color toColor(int status) {
    082            switch (status) {
    083                case TYPECHECKED_WAITING:
    084                case NOTPROCESSED: return null;
    085                case RESOLVED_ERROR:
    086                case PARSED_ERROR: return ColorOptions.typecheckError;
    087                case RESOLVED_CAUTION:
    088                case PARSED_CAUTION: return ColorOptions.typecheckCaution;
    089                case RESOLVED_OK:
    090                case PARSED_OK: return ColorOptions.typecheckOK;
    091                case TYPECHECKED_ERROR: return ColorOptions.typecheckError;
    092                case TYPECHECKED_CAUTION: return ColorOptions.typecheckCaution;
    093                case TYPECHECKED_OK: return ColorOptions.typecheckOK;
    094                case STATICCHECKED_ERROR: return ColorOptions.staticcheckError;
    095                case STATICCHECKED_CAUTION: return ColorOptions.typecheckCaution;
    096                case STATICCHECKED_PASSEDIMMED: return ColorOptions.staticcheckOK;
    097                case STATICCHECKED_OK: return ColorOptions.staticcheckOK;
    098                case STATICCHECKED_TIMEOUT: return ColorOptions.staticcheckTimeout;
    099                case CHILDERROR: return ColorOptions.childError;
    100            }
    101            return null;
    102        }
    103    }