001 /* 002 * JBoss DNA (http://www.jboss.org/dna) 003 * See the COPYRIGHT.txt file distributed with this work for information 004 * regarding copyright ownership. Some portions may be licensed 005 * to Red Hat, Inc. under one or more contributor license agreements. 006 * See the AUTHORS.txt file in the distribution for a full listing of 007 * individual contributors. 008 * 009 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA 010 * is licensed to you under the terms of the GNU Lesser General Public License as 011 * published by the Free Software Foundation; either version 2.1 of 012 * the License, or (at your option) any later version. 013 * 014 * JBoss DNA is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 017 * Lesser General Public License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this software; if not, write to the Free 021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 023 */ 024 package org.jboss.dna.graph.property; 025 026 /** 027 * @author Randall Hauch 028 */ 029 public class ValueFormatException extends RuntimeException { 030 031 /** 032 */ 033 private static final long serialVersionUID = 1L; 034 035 private final Object value; 036 private final PropertyType targetType; 037 038 /** 039 * @param value the value that was not able to be converted 040 * @param targetType the {@link PropertyType} to which the value was being converted 041 */ 042 public ValueFormatException( Object value, 043 PropertyType targetType ) { 044 this.value = value; 045 this.targetType = targetType; 046 } 047 048 /** 049 * @param value the value that was not able to be converted 050 * @param targetType the {@link PropertyType} to which the value was being converted 051 * @param message the message 052 */ 053 public ValueFormatException( Object value, 054 PropertyType targetType, 055 String message ) { 056 super(message); 057 this.value = value; 058 this.targetType = targetType; 059 } 060 061 /** 062 * @param value the value that was not able to be converted 063 * @param targetType the {@link PropertyType} to which the value was being converted 064 * @param cause the cause of the exception 065 */ 066 public ValueFormatException( Object value, 067 PropertyType targetType, 068 Throwable cause ) { 069 super(cause); 070 this.value = value; 071 this.targetType = targetType; 072 } 073 074 /** 075 * @param value the value that was not able to be converted 076 * @param targetType the {@link PropertyType} to which the value was being converted 077 * @param message the message 078 * @param cause the cause of the exception 079 */ 080 public ValueFormatException( Object value, 081 PropertyType targetType, 082 String message, 083 Throwable cause ) { 084 super(message, cause); 085 this.value = value; 086 this.targetType = targetType; 087 } 088 089 /** 090 * {@inheritDoc} 091 */ 092 @Override 093 public String toString() { 094 return super.toString(); 095 } 096 097 /** 098 * Get the {@link PropertyType} to which the {@link #getValue() value} was being converted. 099 * 100 * @return the target type 101 */ 102 public PropertyType getTargetType() { 103 return targetType; 104 } 105 106 /** 107 * Get the original value that was being converted. 108 * 109 * @return the value 110 */ 111 public Object getValue() { 112 return value; 113 } 114 }