001 /*
002 * JBoss, Home of Professional Open Source.
003 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
004 * as indicated by the @author tags. See the copyright.txt file in the
005 * distribution for a full listing of individual contributors.
006 *
007 * This is free software; you can redistribute it and/or modify it
008 * under the terms of the GNU Lesser General Public License as
009 * published by the Free Software Foundation; either version 2.1 of
010 * the License, or (at your option) any later version.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022 package org.jboss.dna.graph.properties;
023
024 import org.jboss.dna.graph.Location;
025
026 /**
027 * @author Randall Hauch
028 */
029 public class PathNotFoundException extends RuntimeException {
030
031 /**
032 */
033 private static final long serialVersionUID = -3703984046286975978L;
034
035 private final Location location;
036 private final Path lowestAncestorThatDoesExist;
037
038 /**
039 * @param location the location of the node that does not exist
040 * @param lowestAncestorThatDoesExist the path of the lowest (closest) ancestor that does exist
041 */
042 public PathNotFoundException( Location location,
043 Path lowestAncestorThatDoesExist ) {
044 this.location = location;
045 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist;
046 }
047
048 /**
049 * @param location the location of the node that does not exist
050 * @param lowestAncestorThatDoesExist the path of the lowest (closest) ancestor that does exist
051 * @param message
052 */
053 public PathNotFoundException( Location location,
054 Path lowestAncestorThatDoesExist,
055 String message ) {
056 super(message);
057 this.location = location;
058 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist;
059 }
060
061 /**
062 * @param location the location of the node that does not exist
063 * @param lowestAncestorThatDoesExist the path of the lowest (closest) ancestor that does exist
064 * @param cause
065 */
066 public PathNotFoundException( Location location,
067 Path lowestAncestorThatDoesExist,
068 Throwable cause ) {
069 super(cause);
070 this.location = location;
071 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist;
072 }
073
074 /**
075 * @param location the location of the node that does not exist
076 * @param lowestAncestorThatDoesExist the path of the lowest (closest) ancestor that does exist
077 * @param message
078 * @param cause
079 */
080 public PathNotFoundException( Location location,
081 Path lowestAncestorThatDoesExist,
082 String message,
083 Throwable cause ) {
084 super(message, cause);
085 this.location = location;
086 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist;
087 }
088
089 /**
090 * {@inheritDoc}
091 */
092 @Override
093 public String toString() {
094 return super.toString();
095 }
096
097 /**
098 * Get the path that was not found
099 *
100 * @return the path that was not found
101 */
102 public Location getLocation() {
103 return location;
104 }
105
106 /**
107 * Get the lowest (closest) existing {@link Path#getParent() ancestor} of the {@link #getLocation() non-existant location}.
108 *
109 * @return the lowest ancestor that does exist
110 */
111 public Path getLowestAncestorThatDoesExist() {
112 return lowestAncestorThatDoesExist;
113 }
114 }