1 /* 2 * Copyright (c) 2004-2007 Creative Sphere Limited. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * 10 * Creative Sphere - initial API and implementation 11 * 12 */ 13 package org.abstracthorizon.mercury.imap.util; 14 15 16 /** 17 * Parser exception 18 * 19 * @author Daniel Sendula 20 */ 21 public class ParserException extends Exception { 22 23 /** 24 * Constructor 25 */ 26 public ParserException() { 27 super(); 28 } 29 30 /** 31 * Constructor 32 * @param msg message 33 */ 34 public ParserException(String msg) { 35 this(true, "Syntax error - expected <"+msg+">"); 36 } 37 38 /** 39 * Constructor 40 * @param missing is missing keyword exception 41 * @param msg keyword 42 */ 43 public ParserException(boolean missing, String msg) { 44 super(compose(missing, msg)); 45 } 46 47 /** 48 * Composes string 49 * @param missing is missing keyword or should this method just return message 50 * @param msg keyword or message 51 * @return composed stirng 52 */ 53 protected static String compose(boolean missing, String msg) { 54 if (missing) { 55 return "Syntax error - expected "+msg; 56 } else { 57 return msg; 58 } 59 } 60 }