View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: ErrorInfo.java
13   * Created: 2008-05-07
14   * Author: entrop, kpietak
15   * $Id: ErrorInfo.java 2308 2009-01-12 22:33:45Z kpietak $
16   */
17  
18  package pl.edu.agh.cast.rawdata.stat;
19  
20  import org.eclipse.osgi.util.NLS;
21  
22  import pl.edu.agh.cast.rawdata.DataRow;
23  
24  /**
25   * Represents information about cell error. Should be connected with one cell. Can contain parameters connected with one
26   * cell (eg. row & column number)
27   * 
28   * @author AGH CAST Team
29   * 
30   */
31  public class ErrorInfo {
32  	private ErrorType type;
33  
34  	private String[] params;
35  
36  	private DataRow relatedRow;
37  
38  	/**
39  	 * Constructor with given error type.
40  	 * 
41  	 * @param type
42  	 *            error type
43  	 */
44  	public ErrorInfo(ErrorType type) {
45  		this.type = type;
46  		this.params = null;
47  	}
48  
49  	/**
50  	 * Constructor with given error type and parameters.
51  	 * 
52  	 * @param type
53  	 *            error type
54  	 * @param params
55  	 *            parameters table
56  	 */
57  	public ErrorInfo(ErrorType type, String[] params) {
58  		this(type);
59  		this.params = params;
60  	}
61  
62  	/**
63  	 * Constructor with given error, parameters and related row.
64  	 * 
65  	 * @param type
66  	 *            error type
67  	 * @param params
68  	 *            parameters table
69  	 * @param relatedRow
70  	 *            related row
71  	 */
72  	public ErrorInfo(ErrorType type, String[] params, DataRow relatedRow) {
73  		this(type, params);
74  		this.relatedRow = relatedRow;
75  	}
76  
77  	/**
78  	 * Returns localised error description.
79  	 * 
80  	 * @return localised error description.
81  	 */
82  	public String getMessage() {
83  		if (params != null && params.length > 0) {
84  			return NLS.bind(type.getMessage(), params);
85  		} else {
86  			return type.getMessage();
87  		}
88  	}
89  
90  	public ErrorSeverity getSeverity() {
91  		return type.getSeverity();
92  	}
93  
94  	public ErrorType getType() {
95  		return type;
96  	}
97  
98  	public DataRow getRelatedRow() {
99  		return relatedRow;
100 	}
101 }