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 / operation / GeometryOperationNotSupportedException.java @ 40559
History | View | Annotate | Download (2.86 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 |
package org.gvsig.fmap.geom.operation; |
25 |
|
26 |
import java.util.HashMap; |
27 |
import java.util.Map; |
28 |
|
29 |
import org.gvsig.fmap.geom.type.GeometryType; |
30 |
import org.gvsig.tools.exception.BaseException; |
31 |
|
32 |
public class GeometryOperationNotSupportedException extends BaseException { |
33 |
|
34 |
/**
|
35 |
* Generated UID
|
36 |
*/
|
37 |
private static final long serialVersionUID = -8394502194572892834L; |
38 |
|
39 |
/**
|
40 |
* Constants specific to this BaseException subclass
|
41 |
*/
|
42 |
private static final String MESSAGE_KEY = "Operation_opCode_is_not_registered_for_geomTypeName_type"; |
43 |
private static final String FORMAT_STRING = "Operation %(opCode)s is not registered for '%(geomTypeName)s' type."; |
44 |
|
45 |
private String geomTypeName = null; |
46 |
private int opCode = -1; |
47 |
|
48 |
/**
|
49 |
* Constructor with the operation code of a common operation.
|
50 |
* @param opCode
|
51 |
*/
|
52 |
public GeometryOperationNotSupportedException(int opCode) { |
53 |
this(opCode, null); |
54 |
} |
55 |
|
56 |
/**
|
57 |
* Constructor with the operation code related to a geometry type
|
58 |
* @param opCode
|
59 |
* @param geomType
|
60 |
*/
|
61 |
public GeometryOperationNotSupportedException(int opCode, GeometryType geomType) { |
62 |
this(opCode, geomType, null); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* Constructor to use when <code>this</code> is caused by another Exception
|
67 |
* but there is not further context data available.
|
68 |
* @param e
|
69 |
*/
|
70 |
public GeometryOperationNotSupportedException(Exception e) { |
71 |
this(-1, null, e); |
72 |
} |
73 |
|
74 |
/**
|
75 |
* Main constructor
|
76 |
* @param opCode
|
77 |
* @param geomType
|
78 |
* @param e
|
79 |
*/
|
80 |
public GeometryOperationNotSupportedException(int opCode, GeometryType geomType, Exception e) { |
81 |
messageKey = MESSAGE_KEY; |
82 |
formatString = FORMAT_STRING; |
83 |
code = serialVersionUID; |
84 |
|
85 |
if (e != null) { |
86 |
initCause(e); |
87 |
} |
88 |
if (geomType != null) { |
89 |
geomTypeName = geomType.getName(); |
90 |
} else {
|
91 |
geomTypeName = "ANY";
|
92 |
} |
93 |
this.opCode = opCode;
|
94 |
} |
95 |
|
96 |
protected Map values() { |
97 |
HashMap map = new HashMap(); |
98 |
map.put("opCode", Integer.toString(opCode)); |
99 |
map.put("geomTypeName", geomTypeName);
|
100 |
return map;
|
101 |
} |
102 |
|
103 |
} |