<s> package org . eclipse . jdt . internal . compiler . problem ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . util . Messages ; import org . eclipse . jdt . internal . compiler . util . Util ; public class DefaultProblem extends CategorizedProblem { private char [ ] fileName ; private int id ; private int startPosition ; private int endPosition ; private int line ; public int column ; private int severity ; private String [ ] arguments ; private String message ; private static final String MARKER_TYPE_PROBLEM = "" ; private static final String MARKER_TYPE_TASK = "" ; public static final Object [ ] EMPTY_VALUES = { } ; public DefaultProblem ( char [ ] originatingFileName , String message , int id , String [ ] stringArguments , int severity , int startPosition , int endPosition , int line , int column ) { this . fileName = originatingFileName ; this . message = message ; this . id = id ; this . arguments = stringArguments ; this . severity = severity ; this . startPosition = startPosition ; this . endPosition = endPosition ; this . line = line ; this . column = column ; } public String errorReportSource ( char [ ] unitSource ) { if ( ( this . startPosition > this . endPosition ) || ( ( this . startPosition < 0 ) && ( this . endPosition < 0 ) ) || unitSource . length == 0 ) return Messages . problem_noSourceInformation ; StringBuffer errorBuffer = new StringBuffer ( ) ; errorBuffer . append ( ' ' ) . append ( Messages . bind ( Messages . problem_atLine , String . valueOf ( this . line ) ) ) ; errorBuffer . append ( Util . LINE_SEPARATOR ) ; errorBuffer . append ( '\t' ) ; char c ; final char SPACE = ' ' ; final char MARK = '^' ; final char TAB = '\t' ; int length = unitSource . length , begin , end ; for ( begin = this . startPosition >= length ? length - 1 : this . startPosition ; begin > 0 ; begin -- ) { if ( ( c = unitSource [ begin - 1 ] ) == '\n' || c == '\r' ) break ; } for ( end = this . endPosition >= length ? length - 1 : this . endPosition ; end + 1 < length ; end ++ ) { if ( ( c = unitSource [ end + 1 ] ) == '\r' || c == '\n' ) break ; } while ( ( c = unitSource [ begin ] ) == ' ' || c == '\t' ) begin ++ ; errorBuffer . append ( unitSource , begin , end - begin + 1 ) ; errorBuffer . append ( Util . LINE_SEPARATOR ) . append ( "t" ) ; for ( int i = begin ; i < this . startPosition ; i ++ ) { errorBuffer . append ( ( unitSource [ i ] == TAB ) ? TAB : SPACE ) ; } for ( int i = this . startPosition ; i <= ( this . endPosition >= length ? length - 1 : this . endPosition ) ; i ++ ) { errorBuffer . append ( MARK ) ; } return errorBuffer . toString ( ) ; } public String [ ] getArguments ( ) { return this . arguments ; } public int getCategoryID ( ) { return ProblemReporter . getProblemCategory ( this . severity , this . id ) ; } public int getID ( ) { return this . id ; } public String getInternalCategoryMessage ( ) { switch ( getCategoryID ( ) ) { case CAT_UNSPECIFIED : return "unspecified" ; case CAT_BUILDPATH : return "buildpath" ; case CAT_SYNTAX : return "syntax" ; case CAT_IMPORT : return "import" ; case CAT_TYPE : return "type" ; case CAT_MEMBER : return "member" ; case CAT_INTERNAL : return "internal" ; case CAT_JAVADOC : return "javadoc" ; case CAT_CODE_STYLE : return "code style" ; case CAT_POTENTIAL_PROGRAMMING_PROBLEM : return "" ; case CAT_NAME_SHADOWING_CONFLICT : return "" ; case CAT_DEPRECATION : return "deprecation" ; case CAT_UNNECESSARY_CODE : return "" ; case CAT_UNCHECKED_RAW : return "" ; case CAT_NLS : return "nls" ; case CAT_RESTRICTION : return "restriction" ; } return null ; } public String getMarkerType ( ) { return this . id == IProblem . Task ? MARKER_TYPE_TASK : MARKER_TYPE_PROBLEM ; } public String getMessage ( ) { return this . message ; } public char [ ] getOriginatingFileName ( ) { return this . fileName ; } public int getSourceEnd ( ) { return this . endPosition ; } public int getSourceColumnNumber ( ) { return this . column ; } public int getSourceLineNumber ( ) { return this . line ; } public int getSourceStart ( ) { return this . startPosition ; } public boolean isError ( ) { return ( this . severity & ProblemSeverities . Error ) != 0 ; } public boolean isWarning ( ) { return ( this . severity & ProblemSeverities . Error ) == 0 ; } public void setOriginatingFileName ( char [ ] fileName ) { this . fileName = fileName ; } public void setSourceEnd ( int sourceEnd ) { this . endPosition = sourceEnd ; } public void setSourceLineNumber ( int lineNumber ) { this . line = lineNumber ; } public void setSourceStart ( int sourceStart ) { this . startPosition = sourceStart ; } public String toString ( ) { String s = "Pb(" + ( this . id & IProblem . IgnoreCategoriesMask ) + ") " ; if ( this . message != null ) { s += this . message ; } else { if ( this . arguments != null ) for ( int i = 0 ; i < this . arguments . length ; i ++ ) s += " " + this . arguments [ i ] ; } return s ; } } </s>