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 /** 025 * @author Randall Hauch 026 */ 027 public class PathNotFoundException extends RuntimeException { 028 029 /** 030 */ 031 private static final long serialVersionUID = -3703984046286975978L; 032 033 private final Path path; 034 private final Path lowestAncestorThatDoesExist; 035 036 /** 037 * @param path 038 * @param lowestAncestorThatDoesExist 039 */ 040 public PathNotFoundException( Path path, Path lowestAncestorThatDoesExist ) { 041 this.path = path; 042 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist; 043 } 044 045 /** 046 * @param path 047 * @param lowestAncestorThatDoesExist 048 * @param message 049 */ 050 public PathNotFoundException( Path path, Path lowestAncestorThatDoesExist, 051 String message ) { 052 super(message); 053 this.path = path; 054 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist; 055 } 056 057 /** 058 * @param path 059 * @param lowestAncestorThatDoesExist 060 * @param cause 061 */ 062 public PathNotFoundException( Path path, Path lowestAncestorThatDoesExist, 063 Throwable cause ) { 064 super(cause); 065 this.path = path; 066 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist; 067 } 068 069 /** 070 * @param path 071 * @param lowestAncestorThatDoesExist 072 * @param message 073 * @param cause 074 */ 075 public PathNotFoundException( Path path, Path lowestAncestorThatDoesExist, 076 String message, 077 Throwable cause ) { 078 super(message, cause); 079 this.path = path; 080 this.lowestAncestorThatDoesExist = lowestAncestorThatDoesExist; 081 } 082 083 /** 084 * {@inheritDoc} 085 */ 086 @Override 087 public String toString() { 088 return super.toString(); 089 } 090 091 /** 092 * Get the path that was not found 093 * 094 * @return the path that was not found 095 */ 096 public Path getPath() { 097 return path; 098 } 099 100 /** 101 * Get the lowest (closest) existing {@link Path#getParent() ancestor} of the {@link #getPath() non-existant path}. 102 * @return the lowest ancestor that does exist 103 */ 104 public Path getLowestAncestorThatDoesExist() { 105 return lowestAncestorThatDoesExist; 106 } 107 }