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 ValueFormatException extends RuntimeException { 028 029 /** 030 */ 031 private static final long serialVersionUID = 1L; 032 033 private final Object value; 034 private final PropertyType targetType; 035 036 /** 037 * @param value the value that was not able to be converted 038 * @param targetType the {@link PropertyType} to which the value was being converted 039 */ 040 public ValueFormatException( Object value, 041 PropertyType targetType ) { 042 this.value = value; 043 this.targetType = targetType; 044 } 045 046 /** 047 * @param value the value that was not able to be converted 048 * @param targetType the {@link PropertyType} to which the value was being converted 049 * @param message the message 050 */ 051 public ValueFormatException( Object value, 052 PropertyType targetType, 053 String message ) { 054 super(message); 055 this.value = value; 056 this.targetType = targetType; 057 } 058 059 /** 060 * @param value the value that was not able to be converted 061 * @param targetType the {@link PropertyType} to which the value was being converted 062 * @param cause the cause of the exception 063 */ 064 public ValueFormatException( Object value, 065 PropertyType targetType, 066 Throwable cause ) { 067 super(cause); 068 this.value = value; 069 this.targetType = targetType; 070 } 071 072 /** 073 * @param value the value that was not able to be converted 074 * @param targetType the {@link PropertyType} to which the value was being converted 075 * @param message the message 076 * @param cause the cause of the exception 077 */ 078 public ValueFormatException( Object value, 079 PropertyType targetType, 080 String message, 081 Throwable cause ) { 082 super(message, cause); 083 this.value = value; 084 this.targetType = targetType; 085 } 086 087 /** 088 * {@inheritDoc} 089 */ 090 @Override 091 public String toString() { 092 return super.toString(); 093 } 094 095 /** 096 * Get the {@link PropertyType} to which the {@link #getValue() value} was being converted. 097 * 098 * @return the target type 099 */ 100 public PropertyType getTargetType() { 101 return targetType; 102 } 103 104 /** 105 * Get the original value that was being converted. 106 * 107 * @return the value 108 */ 109 public Object getValue() { 110 return value; 111 } 112 }