1 /********************************************** 2 * Copyright (C) 2011 Lukas Laag 3 * This file is part of svgreal. 4 * 5 * svgreal is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * svgreal is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with svgreal. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 package org.vectomatic.svg.edit.client.model; 19 20 import com.extjs.gxt.ui.client.util.Format; 21 22 /** 23 * Class to represent a validation error or warning. 24 * @author laaglu 25 */ 26 public class ValidationError { 27 /** 28 * Enum to represent the severity of an error 29 */ 30 public enum Severity { 31 WARNING, 32 ERROR 33 } 34 /** 35 * The error severity 36 */ 37 protected Severity severity; 38 /** 39 * The error message before arguments substitution 40 */ 41 protected String message; 42 /** 43 * Args of the error message 44 */ 45 protected Object[] args; 46 /** 47 * Constructor 48 * @param severity 49 * The error severity 50 * @param message 51 * The error message before arguments substitution 52 */ 53 public ValidationError(Severity severity, String message) { 54 this(severity, message, null); 55 } 56 /** 57 * Constructor 58 * @param severity 59 * The error severity 60 * @param message 61 * The error message before arguments substitution 62 * @param args 63 * Args of the error message 64 */ 65 public ValidationError(Severity severity, String message, Object[] args) { 66 this.severity = severity; 67 this.message = message; 68 this.args = args; 69 } 70 /** 71 * Returns the error severity 72 * @return 73 * The error severity 74 */ 75 public Severity getSeverity() { 76 return severity; 77 } 78 /** 79 * Returns a localized error message for this error. 80 * @return a localized error message for this error. 81 */ 82 public String getMessage() { 83 return (args == null) ? message : Format.substitute(message, args); 84 } 85 } 86