001    package echopoint.util.throwable;
002    
003    
004    /*
005     * This file is part of the Echo Point Project.  This project is a collection
006     * of Components that have extended the Echo Web Application Framework.
007     *
008     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
009     *
010     * The contents of this file are subject to the Mozilla Public License Version
011     * 1.1 (the "License"); you may not use this file except in compliance with
012     * the License. You may obtain a copy of the License at
013     * http://www.mozilla.org/MPL/
014     *
015     * Software distributed under the License is distributed on an "AS IS" basis,
016     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
017     * for the specific language governing rights and limitations under the
018     * License.
019     *
020     * Alternatively, the contents of this file may be used under the terms of
021     * either the GNU General Public License Version 2 or later (the "GPL"), or
022     * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
023     * in which case the provisions of the GPL or the LGPL are applicable instead
024     * of those above. If you wish to allow use of your version of this file only
025     * under the terms of either the GPL or the LGPL, and not to allow others to
026     * use your version of this file under the terms of the MPL, indicate your
027     * decision by deleting the provisions above and replace them with the notice
028     * and other provisions required by the GPL or the LGPL. If you do not delete
029     * the provisions above, a recipient may use your version of this file under
030     * the terms of any one of the MPL, the GPL or the LGPL.
031     */
032    
033    import java.io.Serializable;
034    
035    /**
036     * <code>ThrowablePropertyDescriptor</code> describes a property
037     * of an Throwable
038     */
039    public class ThrowablePropertyDescriptor implements Serializable {
040            private Class type;
041            private String name;
042            private Object value;
043            private int     modifiers;
044    
045    
046            /**
047             * Constructs an empty <code>ThrowablePropertyDescriptor</code>
048             */
049            ThrowablePropertyDescriptor() {
050            }
051    
052            /**
053             * Constructs a <code>ThrowablePropertyDescriptor</code> with the name, type and value.
054             *
055             * @param type  - the type of the Throwable property
056             * @param name  - the name of the Throwable property
057             * @param value - the value of the Throwable property
058             */
059            ThrowablePropertyDescriptor(Class type, String name, Object value, int modifiers) {
060                    this.type = type;
061                    this.name = name;
062                    this.value = value;
063                    this.modifiers = modifiers;
064            }
065            /**
066             * Returns the name of the Throwable property
067             * @return the name of the Throwable property
068             */
069            public String getName() {
070                    return name;
071            }
072    
073            /**
074             * Returns the modifiers of the Throwable property
075             * @return the modifiers of the Throwable property
076             */
077            public int getModifiers() {
078                    return modifiers;
079            }
080    
081            /**
082             * Returns the type of the Throwable property
083             * @return the type of the Throwable property
084             */
085            public Class getType() {
086                    return type;
087            }
088    
089            /**
090             * Returns the value of the Throwable property
091             * @return the value of the Throwable property
092             */
093            public Object getValue() {
094                    return value;
095            }
096    
097            /**
098             * Returns a trimmed String representation of the
099             * value of the Throwable property or null.
100             *
101             * @return a trimmed String representation of the
102             * value of the Throwable property or null.
103             */
104            public String getValueAsString() {
105                    if (value == null)
106                            return null;
107                    return value.toString();
108            }
109    
110            /**
111             * Sets the type of the Throwable property
112             * @param type - the name of the Throwable property
113             */
114            void setType(Class type) {
115                    this.type = type;
116            }
117    
118            /**
119             * Sets the name of the Throwable property
120             * @param name - the name of the Throwable property
121             */
122            void setName(String name) {
123                    this.name = name;
124            }
125    
126            /**
127             * Sets the modifiers of the Throwable property
128             * @param modifiers - the modifiers of the Throwable property
129             */
130            void setModifiers(int modifiers) {
131                    this.modifiers = modifiers;
132            }
133    
134    
135            /**
136             * Sets the value of the Throwable property
137             * @param value - the value of the Throwable property
138             */
139            void setValue(Object value) {
140                    this.value = value;
141            }
142    
143    }
144