Statistics
| Revision:

svn-gvsig-desktop / import / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / WFSDriverException.java @ 18320

History | View | Annotate | Download (3.75 KB)

1
package com.iver.cit.gvsig.fmap.drivers;
2

    
3
import org.gvsig.remoteClient.wfs.exceptions.WFSException;
4

    
5
import com.iver.andami.PluginServices;
6

    
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id: WFSDriverException.java 18320 2008-01-25 13:16:03Z jpiera $
50
 * $Log$
51
 * Revision 1.3  2006-09-05 15:41:51  jorpiell
52
 * A?adida la funcionalidad de cargar WFS desde el cat?logo
53
 *
54
 * Revision 1.2  2006/05/23 13:20:46  jorpiell
55
 * Modificado el mensaje en blanco
56
 *
57
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
58
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
59
 *
60
 *
61
 */
62
/**
63
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
64
 */
65
public class WFSDriverException extends WFSException{
66
        public static final String EXC_LAYER_DOESNT_EXIST = "cantLoad";
67
        private String message = "";
68
        
69
        public String getMessage() {
70
                return PluginServices.getText(this, "wfs_server_error")+"\n"+ format(message, 200);
71
        }
72

    
73
        /**
74
         *
75
         */
76
        public WFSDriverException() {
77
                super();
78
        }
79

    
80
        /**
81
         * Crea WFSException.
82
         *
83
         * @param message
84
         */
85
        public WFSDriverException(String message) {
86
        super();
87
        this.message = message;
88
        }
89
        
90

    
91
        /**
92
          * Crea WMSException.
93
         *
94
         * @param cause
95
         */
96
        public WFSDriverException(Throwable cause) {
97
                super(cause);
98
        }
99
        
100
         /**
101
     * Cuts the message text to force its lines to be shorter or equal to 
102
     * lineLength.
103
     * @param message, the message.
104
     * @param lineLength, the max line length in number of characters.
105
     * @return the formated message.
106
     */
107
    private static String format(String message, int lineLength){
108
               if (message.length() <= lineLength) return message;
109
        String[] lines = message.split("\n");
110
        String theMessage = "";
111
        for (int i = 0; i < lines.length; i++) {
112
            String line = lines[i].trim();
113
            if (line.length()<lineLength)
114
                theMessage += line+"\n";
115
            else {
116
                String[] chunks = line.split(" ");
117
                String newLine = "";
118
                for (int j = 0; j < chunks.length; j++) {
119
                    int currentLength = newLine.length();
120
                    chunks[j] = chunks[j].trim();
121
                    if (chunks[j].length()==0)
122
                        continue;
123
                    if ((currentLength + chunks[j].length() + " ".length()) <= lineLength)
124
                        newLine += chunks[j] + " ";
125
                    else {
126
                        newLine += "\n"+chunks[j]+" ";
127
                        theMessage += newLine;
128
                        newLine = "";
129
                    }
130
                }
131
                
132
            }
133
        }
134
        return theMessage;
135
    }
136

    
137

    
138
}