KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > util > ErrorStruct


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.util;
11
12 /**
13  * Class for storing error information useful in parsing.
14  * Information that can be stored includes the error type, column and
15  * line number of the parsed text where the error occurred, and a message.
16  * used by the {@link org.mmbase.module.Config} module when parsing XML files.
17  *
18  * @application Config
19  * @author vpro
20  * @version $Id: ErrorStruct.java,v 1.5 2004/09/29 14:29:23 pierre Exp $
21  */

22 public class ErrorStruct {
23
24     // error type
25
String JavaDoc errorType;
26     // line number
27
int line;
28     // column number
29
int col;
30     // error message
31
String JavaDoc msg;
32
33     /**
34      * Creates an error structure, with errortype "none".
35      * @param line the line number where the error occurred
36      * @param col the column number where the error occurred
37      * @param msg the error message
38      */

39     public ErrorStruct(int line, int col, String JavaDoc msg) {
40     this("none",line,col,msg);
41     }
42
43     /**
44      * Creates an error structure.
45      * @param errorType the type of error,
46      * @param line the line number where the error occurred
47      * @param col the column number where the error occurred
48      * @param msg the error message
49      */

50     public ErrorStruct(String JavaDoc errorType, int line, int col, String JavaDoc msg) {
51     this.errorType = errorType;
52     this.line = line;
53     this.col = col;
54     this.msg = msg;
55     }
56
57     /**
58      * Returns the error type.
59      * Values that might be expected are "warning", "error" and "fatal".
60      */

61     public String JavaDoc getErrorType() {
62     return errorType;
63     }
64
65     /**
66      * Returns the line number in the parsed source (file or textbuffer)
67      * where the error occurred.
68      */

69     public int getLineNumber() {
70     return line;
71     }
72
73     /**
74      * Returns the column number in the parsed source (file or textbuffer)
75      * where the error occurred.
76      */

77     public int getColumnNumber() {
78     return col;
79     }
80
81     /**
82      * Returns a more detailed error message.
83      */

84     public String JavaDoc getMessage() {
85     return msg;
86     }
87
88     /**
89      * prints the ErrorStruct
90      */

91     public String JavaDoc toString() {
92         return "ErrorStruct: type="+errorType+" line="+line+" position="+col+" message="+msg;
93     }
94 }
95
Popular Tags