KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > lib > math > MalformedExpressionException


1 package com.teamkonzept.lib.math;
2
3
4 public class MalformedExpressionException extends Exception JavaDoc{
5
6     final static int SYNTAX_ERROR = 0;
7     final static int MISSING_OPENING_PAREN = 1;
8     final static int MISSING_CLOSING_PAREN = 2;
9     final static int UNKNOWN_RESULT = 3;
10     
11     int type;
12     int position;
13
14     public MalformedExpressionException(int type, int position){
15     this.type = type;
16     this.position = position;
17     }
18
19     public String JavaDoc toString(){
20     String JavaDoc res;
21     switch ( type ){
22     case SYNTAX_ERROR:
23         res = "syntax error";
24         break;
25     case MISSING_OPENING_PAREN:
26         res = "missing opening paren";
27         break;
28     case MISSING_CLOSING_PAREN:
29         res = "missing closing paren";
30         break;
31     case UNKNOWN_RESULT:
32         res = "result has wrong type";
33         break;
34     default:
35         res = "syntax error";
36     }
37     return res + " at position " + position;
38     }
39 }
40
Popular Tags