Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / type / GeometryTypeNotSupportedException.java @ 40767

History | View | Annotate | Download (3.35 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25

    
26
package org.gvsig.fmap.geom.type;
27

    
28
import java.util.HashMap;
29
import java.util.Map;
30

    
31
import org.gvsig.fmap.geom.GeometryException;
32

    
33
/**
34
 * This exception is raised when the someone tries to access a geometry 
35
 * type that is not supported.
36
 * 
37
 * @author jiyarza
38
 */
39
public class GeometryTypeNotSupportedException extends GeometryException {
40

    
41
        /**
42
         * Generated serial version UID 
43
         */
44
        private static final long serialVersionUID = -196778635358286969L;
45

    
46
        /**
47
         * Key to retrieve this exception's message
48
         */
49
        private static final String MESSAGE_KEY = "geometry_type_not_supported_exception";
50
        /**
51
         * This exception's message. Substitution fields follow the format %(fieldName) and 
52
         * must be stored in the Map returned by the values() method. 
53
         */
54
        private static final String FORMAT_STRING = 
55
                "The geometry class %(geomClassName) is not registered.";
56
        
57
        /**
58
         * Class name of the geometry type. Should never be null in this exception
59
         */
60
        private String geomClassName = null;
61
        
62
        
63
        /**
64
         * Constructor with some context data for cases in which the root cause of 
65
         * <code>this</code> is internal (usually an unsatisfied logic rule).
66
         * @param geomClass geometry class
67
         */
68
        public GeometryTypeNotSupportedException(Class geomClass){
69
                this(geomClass, null);
70
        }
71
        
72
        /**
73
         * Constructor to use when <code>this</code> is caused by another Exception 
74
         * but there is not further context data available.
75
         * @param e cause exception
76
         */
77
        public GeometryTypeNotSupportedException(Exception e) {
78
                this(null, e);
79
        }
80
        
81
        public GeometryTypeNotSupportedException(int type, int subType){
82
            super(
83
                "Geometry type %(type), %(subType) not supported.",
84
            "_geometry_type_XtypeX_XsubTypeX_not_supported",
85
                serialVersionUID
86
             );
87
                setValue("type", new Integer(type));
88
        setValue("subType", new Integer(subType));
89
        }
90
        
91
        public GeometryTypeNotSupportedException(String geomClassName){
92
        super(FORMAT_STRING, MESSAGE_KEY, serialVersionUID);
93
        
94
        if (geomClassName != null) {
95
            setValue("geomClassName", geomClassName);
96
        }
97
        }
98
        
99
        /**
100
         * Main constructor that provides both context data and a cause Exception
101
         * @param geomClass geometry class 
102
         * @param e cause exception
103
         */
104
        public GeometryTypeNotSupportedException(Class geomClass, Exception e) {
105
                super(FORMAT_STRING, e, MESSAGE_KEY, serialVersionUID);
106
                
107
                if (geomClass != null) {
108
                    setValue("geomClassName", geomClass.getName());
109
                }
110
        }
111
}