001package com.thetransactioncompany.util;
002
003
004/**
005 * Thrown on a property parse exception. Intended to report missing or invalid
006 * properties.
007 *
008 * @see com.thetransactioncompany.util.PropertyRetriever
009 *
010 * @author Vladimir Dzhuvinov
011 */
012public class PropertyParseException
013        extends Exception {
014        
015        
016        /**
017         * The key of the property that caused the exception, {@code null} if
018         * unknown or not applicable.
019         */
020        private final String propertyKey;
021        
022        
023        /**
024         * The value of the property that caused the exception, {@code null} if
025         * unknown or not applicable.
026         */
027        private final String propertyValue;
028        
029        
030        /**
031         * Creates a new property parse exception with the specified message.
032         *
033         * @param message The exception message.
034         */
035        public PropertyParseException(final String message) {
036        
037                super(message);
038                propertyKey = null;
039                propertyValue = null;
040        }
041        
042        
043        /**
044         * Creates a new property parse exception with the specified message and
045         * property key.
046         *
047         * @param message     The exception message.
048         * @param propertyKey The key of the property that caused the exception,
049         *                    {@code null} if unknown or not applicable.
050         */
051        public PropertyParseException(final String message, final String propertyKey) {
052        
053                super(message);
054                this.propertyKey = propertyKey;
055                propertyValue = null;
056        }
057        
058        
059        /**
060         * Creates a new property parse exception with the specified message,
061         * property key and property value.
062         *
063         * @param message       The exception message.
064         * @param propertyKey   The key of the property that caused the
065         *                      exception, {@code null} if unknown or not
066         *                      applicable.
067         * @param propertyValue The value of the property that caused the
068         *                      exception, {@code null} if unknown or not
069         *                      applicable.
070         */
071        public PropertyParseException(final String message, final String propertyKey, final String propertyValue) {
072        
073                super(message);
074                this.propertyKey = propertyKey;
075                this.propertyValue = propertyValue;
076        }
077        
078        
079        /**
080         * Returns the key of the property that caused the exception, 
081         * {@code null} if unknown or not applicable.
082         * 
083         * @return The key of the offending property.
084         */
085        public String getPropertyKey() {
086        
087                return propertyKey;
088        }
089        
090        
091        /**
092         * Returns the value of the property that caused the exception,
093         * {@code null} if unknown or not applicable.
094         *
095         * @return The value of the offending property.
096         */
097        public String getPropertyValue() {
098        
099                return propertyValue;
100        }
101}