1 /* 2 * Zemucan: A Syntax Assistant for DB2 3 * Copyright (C) 2009, 2010 Andres Gomez Casanova 4 * 5 * This file is part of Zemucan. 6 * 7 * Zemucan is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * Zemucan is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this library; if not, see <http://www.gnu.org/licenses/>. 19 * 20 * Contact: 21 * a n g o c a at y a h o o dot c o m 22 * Cra. 45 No 61 - 31, Bogota, Colombia. 23 * 24 * Author: $LastChangedBy: angoca $: 25 * Date: $LastChangedDate: 2011-03-06 09:19:05 -0500 (dom, 06 mar 2011) $: 26 * Revision: $LastChangedRevision: 1910 $: 27 * URL: $HeadURL: https://zemucan.svn.sourceforge.net/svnroot/zemucan/branches/zemucan_v1/source-code/graph/src/main/java/name/angoca/zemucan/core/graph/model/DuplicatedNodeNameException.java $: 28 */ 29 package name.angoca.zemucan.core.graph.model; 30 31 import name.angoca.zemucan.tools.messages.Messages; 32 33 import org.slf4j.Logger; 34 import org.slf4j.LoggerFactory; 35 36 /** 37 * This exception is thrown when the grammar file has two nodes with the same 38 * name for the same parent node. 39 * <p> 40 * <b>Control Version</b> 41 * <p> 42 * <ul> 43 * <li>1.0.0 Class creation.</li> 44 * <li>1.1.0 Two nodes.</li> 45 * </ul> 46 * 47 * @author Andres Gomez Casanova <a 48 * href="mailto:a n g o c a at y a h o o dot c o m" >(AngocA)</a> 49 * @version 1.1.0 2010-08-29 50 */ 51 public class DuplicatedNodeNameException extends AbstractGraphException { 52 53 /** 54 * Logger. 55 */ 56 private static final Logger LOGGER = LoggerFactory 57 .getLogger(DuplicatedNodeNameException.class); 58 59 /** 60 * ID of the exception. 61 */ 62 private static final long serialVersionUID = -8965829310898508013L; 63 64 /** 65 * First child that has the same name. 66 */ 67 private final String childNode1; 68 /** 69 * Second child that has the same name. 70 */ 71 private final String childNode2; 72 73 /** 74 * Duplicated node name. 75 */ 76 private final String name; 77 78 /** 79 * Parent node name. 80 */ 81 private final String parentNodeName; 82 83 /** 84 * Constructor with the duplicated name. 85 * 86 * @param parentNode 87 * Node that contains the two nodes repeated. 88 * @param name 89 * Duplicated name. 90 * @param childNode1 91 * First node repeated. 92 * @param childNode2 93 * Seconde node repeated. 94 */ 95 public DuplicatedNodeNameException(final String/* ! */parentNode, 96 final String /* ! */name, final String childNode1, final String childNode2) { 97 super(); 98 assert parentNode != null; 99 assert name != null; 100 assert childNode1 != null; 101 assert childNode2 != null; 102 103 this.parentNodeName = parentNode; 104 this.name = name; 105 this.childNode1 = childNode1; 106 this.childNode2 = childNode2; 107 DuplicatedNodeNameException.LOGGER 108 .debug(DuplicatedNodeNameException.class.getName() 109 + " created."); //$NON-NLS-1$ 110 } 111 112 /** 113 * Retrieves the first node with id repeated. 114 * 115 * @return Repeated name. 116 */ 117 public final String/* ! */getChildNode1() { 118 return this.childNode1; 119 } 120 121 /** 122 * Retrieves the second node with id repeated. 123 * 124 * @return Repeated name. 125 */ 126 public final String/* ! */getChildNode2() { 127 return this.childNode2; 128 } 129 130 /** 131 * Retrieves the name of the duplicated Node. 132 * 133 * @return name of the node. 134 */ 135 public final String/* ! */getChildNodeName() { 136 return this.name; 137 } 138 139 /** 140 * Returns a message indicating the node that is repeated. 141 * 142 * @return Descriptive message. 143 */ 144 @Override 145 public final String/* ! */getMessage() { 146 return Messages.getString("DuplicatedNodeNameException" //$NON-NLS-1$ 147 + ".GRPH25-DuplicatedNameForSameParent") + this.name //$NON-NLS-1$ 148 + Messages.getString("DuplicatedNodeNameException" //$NON-NLS-1$ 149 + ".GRPH25-DuplicatedNameForSameParentFrom") //$NON-NLS-1$ 150 + this.parentNodeName + " (" + this.childNode1 + ", " 151 + this.childNode2 + ")"; 152 } 153 154 /** 155 * Retrieves the name of the parent of the node. 156 * 157 * @return name of the parent node. 158 */ 159 public final String /* ! */getParentNodeName() { 160 return this.parentNodeName; 161 } 162 }