svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / fmap / drivers / WPSException.java @ 26601
History | View | Annotate | Download (2.17 KB)
1 |
package es.logex.gvsig.fmap.drivers; |
---|---|
2 |
|
3 |
import com.iver.andami.PluginServices; |
4 |
|
5 |
public class WPSException extends Exception { |
6 |
|
7 |
/**
|
8 |
*
|
9 |
*/
|
10 |
private static final long serialVersionUID = -2696087802051634058L; |
11 |
public static final String EXC_LAYER_DOESNT_EXIST = "cantLoad"; |
12 |
public static final String EXC_PROCESS_DOESNT_EXIST = "cantLoad"; |
13 |
|
14 |
private String message = ""; |
15 |
|
16 |
public String getMessage() { |
17 |
return PluginServices.getText(this, "wps_server_error")+"\n"+ format(message, 200); |
18 |
} |
19 |
|
20 |
/**
|
21 |
*
|
22 |
*/
|
23 |
public WPSException() {
|
24 |
super();
|
25 |
} |
26 |
|
27 |
/**
|
28 |
* Crea WFSException.
|
29 |
*
|
30 |
* @param message
|
31 |
*/
|
32 |
public WPSException(String message) { |
33 |
super();
|
34 |
this.message = message;
|
35 |
} |
36 |
|
37 |
|
38 |
/**
|
39 |
* Crea WMSException.
|
40 |
*
|
41 |
* @param cause
|
42 |
*/
|
43 |
public WPSException(Throwable cause) { |
44 |
super(cause);
|
45 |
} |
46 |
|
47 |
/**
|
48 |
* Cuts the message text to force its lines to be shorter or equal to
|
49 |
* lineLength.
|
50 |
* @param message, the message.
|
51 |
* @param lineLength, the max line length in number of characters.
|
52 |
* @return the formated message.
|
53 |
*/
|
54 |
private static String format(String message, int lineLength){ |
55 |
if (message.length() <= lineLength) return message; |
56 |
String[] lines = message.split("\n"); |
57 |
String theMessage = ""; |
58 |
for (int i = 0; i < lines.length; i++) { |
59 |
String line = lines[i].trim();
|
60 |
if (line.length()<lineLength)
|
61 |
theMessage += line+"\n";
|
62 |
else {
|
63 |
String[] chunks = line.split(" "); |
64 |
String newLine = ""; |
65 |
for (int j = 0; j < chunks.length; j++) { |
66 |
int currentLength = newLine.length();
|
67 |
chunks[j] = chunks[j].trim(); |
68 |
if (chunks[j].length()==0) |
69 |
continue;
|
70 |
if ((currentLength + chunks[j].length() + " ".length()) <= lineLength) |
71 |
newLine += chunks[j] + " ";
|
72 |
else {
|
73 |
newLine += "\n"+chunks[j]+" "; |
74 |
theMessage += newLine; |
75 |
newLine = "";
|
76 |
} |
77 |
} |
78 |
|
79 |
} |
80 |
} |
81 |
return theMessage;
|
82 |
} |
83 |
|
84 |
} |