svn-gvsig-desktop / tags / v1_0_RELEASE / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / WFSException.java @ 9167
History | View | Annotate | Download (3.67 KB)
1 |
package com.iver.cit.gvsig.fmap.drivers; |
---|---|
2 |
|
3 |
import com.iver.andami.PluginServices; |
4 |
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
/* CVS MESSAGES:
|
46 |
*
|
47 |
* $Id: WFSException.java 9167 2006-12-04 16:01:24Z $
|
48 |
* $Log$
|
49 |
* Revision 1.3 2006-09-05 15:41:51 jorpiell
|
50 |
* A?adida la funcionalidad de cargar WFS desde el cat?logo
|
51 |
*
|
52 |
* Revision 1.2 2006/05/23 13:20:46 jorpiell
|
53 |
* Modificado el mensaje en blanco
|
54 |
*
|
55 |
* Revision 1.1 2006/04/19 12:50:16 jorpiell
|
56 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
|
57 |
*
|
58 |
*
|
59 |
*/
|
60 |
/**
|
61 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
62 |
*/
|
63 |
public class WFSException extends Exception{ |
64 |
public static final String EXC_LAYER_DOESNT_EXIST = "cantLoad"; |
65 |
private String message = ""; |
66 |
|
67 |
public String getMessage() { |
68 |
return PluginServices.getText(this, "wfs_server_error")+"\n"+ format(message, 200); |
69 |
} |
70 |
|
71 |
/**
|
72 |
*
|
73 |
*/
|
74 |
public WFSException() {
|
75 |
super();
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* Crea WFSException.
|
80 |
*
|
81 |
* @param message
|
82 |
*/
|
83 |
public WFSException(String message) { |
84 |
super();
|
85 |
this.message = message;
|
86 |
} |
87 |
|
88 |
|
89 |
/**
|
90 |
* Crea WMSException.
|
91 |
*
|
92 |
* @param cause
|
93 |
*/
|
94 |
public WFSException(Throwable cause) { |
95 |
super(cause);
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Cuts the message text to force its lines to be shorter or equal to
|
100 |
* lineLength.
|
101 |
* @param message, the message.
|
102 |
* @param lineLength, the max line length in number of characters.
|
103 |
* @return the formated message.
|
104 |
*/
|
105 |
private static String format(String message, int lineLength){ |
106 |
if (message.length() <= lineLength) return message; |
107 |
String[] lines = message.split("\n"); |
108 |
String theMessage = ""; |
109 |
for (int i = 0; i < lines.length; i++) { |
110 |
String line = lines[i].trim();
|
111 |
if (line.length()<lineLength)
|
112 |
theMessage += line+"\n";
|
113 |
else {
|
114 |
String[] chunks = line.split(" "); |
115 |
String newLine = ""; |
116 |
for (int j = 0; j < chunks.length; j++) { |
117 |
int currentLength = newLine.length();
|
118 |
chunks[j] = chunks[j].trim(); |
119 |
if (chunks[j].length()==0) |
120 |
continue;
|
121 |
if ((currentLength + chunks[j].length() + " ".length()) <= lineLength) |
122 |
newLine += chunks[j] + " ";
|
123 |
else {
|
124 |
newLine += "\n"+chunks[j]+" "; |
125 |
theMessage += newLine; |
126 |
newLine = "";
|
127 |
} |
128 |
} |
129 |
|
130 |
} |
131 |
} |
132 |
return theMessage;
|
133 |
} |
134 |
|
135 |
|
136 |
} |