<s> package org . eclipse . jdt . internal . eval ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; public class EvaluationResult { static final CategorizedProblem [ ] NO_PROBLEMS = new CategorizedProblem [ 0 ] ; char [ ] evaluationID ; int evaluationType ; CategorizedProblem [ ] problems ; char [ ] displayString ; char [ ] typeName ; public static final int T_VARIABLE = 1 ; public static final int T_CODE_SNIPPET = 2 ; public static final int T_IMPORT = 3 ; public static final int T_PACKAGE = 4 ; public static final int T_INTERNAL = 5 ; public EvaluationResult ( char [ ] evaluationID , int evaluationType , char [ ] displayString , char [ ] typeName ) { this . evaluationID = evaluationID ; this . evaluationType = evaluationType ; this . displayString = displayString ; this . typeName = typeName ; this . problems = NO_PROBLEMS ; } public EvaluationResult ( char [ ] evaluationID , int evaluationType , CategorizedProblem [ ] problems ) { this . evaluationID = evaluationID ; this . evaluationType = evaluationType ; this . problems = problems ; } void addProblem ( CategorizedProblem problem ) { CategorizedProblem [ ] existingProblems = this . problems ; int existingLength = existingProblems . length ; this . problems = new CategorizedProblem [ existingLength + 1 ] ; System . arraycopy ( existingProblems , 0 , this . problems , 0 , existingLength ) ; this . problems [ existingLength ] = problem ; } public char [ ] getEvaluationID ( ) { return this . evaluationID ; } public int getEvaluationType ( ) { return this . evaluationType ; } public CategorizedProblem [ ] getProblems ( ) { return this . problems ; } public Object getValue ( ) { return null ; } public char [ ] getValueDisplayString ( ) { return this . displayString ; } public char [ ] getValueTypeName ( ) { return this . typeName ; } public boolean hasErrors ( ) { if ( this . problems == null ) { return false ; } else { for ( int i = 0 ; i < this . problems . length ; i ++ ) { if ( this . problems [ i ] . isError ( ) ) { return true ; } } return false ; } } public boolean hasProblems ( ) { return ( this . problems != null ) && ( this . problems . length != 0 ) ; } public boolean hasValue ( ) { return this . displayString != null ; } public boolean hasWarnings ( ) { if ( this . problems == null ) { return false ; } else { for ( int i = 0 ; i < this . problems . length ; i ++ ) { if ( this . problems [ i ] . isWarning ( ) ) { return true ; } } return false ; } } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; switch ( this . evaluationType ) { case T_CODE_SNIPPET : buffer . append ( "Code snippet" ) ; break ; case T_IMPORT : buffer . append ( "Import" ) ; break ; case T_INTERNAL : buffer . append ( "" ) ; break ; case T_PACKAGE : buffer . append ( "Package" ) ; break ; case T_VARIABLE : buffer . append ( "" ) ; break ; } buffer . append ( ": " ) ; buffer . append ( this . evaluationID == null ? "<unknown>" . toCharArray ( ) : this . evaluationID ) ; buffer . append ( "n" ) ; if ( hasProblems ( ) ) { buffer . append ( "Problems:n" ) ; for ( int i = 0 ; i < this . problems . length ; i ++ ) { buffer . append ( this . problems [ i ] . toString ( ) ) ; } } else { if ( hasValue ( ) ) { buffer . append ( "(" ) ; buffer . append ( this . typeName ) ; buffer . append ( ") " ) ; buffer . append ( this . displayString ) ; } else { buffer . append ( "" ) ; } } return buffer . toString ( ) ; } } </s>