Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / WFSException.java @ 5306

History | View | Annotate | Download (3.4 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 4886 2006-04-19 12:50:16Z jorpiell $
48
 * $Log$
49
 * Revision 1.1  2006-04-19 12:50:16  jorpiell
50
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
51
 *
52
 *
53
 */
54
/**
55
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
56
 */
57
public class WFSException extends Exception{
58

    
59
String message;
60
        
61
        public String getMessage() {
62
                return PluginServices.getText(this, "wfs_server_error")+"\n"+ format(message, 200);
63
        }
64

    
65
        /**
66
         *
67
         */
68
        public WFSException() {
69
                super();
70
        }
71

    
72
        /**
73
         * Crea WFSException.
74
         *
75
         * @param message
76
         */
77
        public WFSException(String message) {
78
        super();
79
        this.message = message;
80
        }
81
        
82

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

    
129

    
130
}