Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libGPE-XML / src / org / gvsig / gpe / xml / writer / GPEXmlWriterHandlerImplementor.java @ 28113

History | View | Annotate | Download (4.8 KB)

1
package org.gvsig.gpe.xml.writer;
2

    
3
import org.gvsig.gpe.writer.GPEWriterHandlerImplementor;
4
import org.gvsig.gpe.xml.XmlProperties;
5
import org.gvsig.gpe.xml.parser.GPEXmlParserFactory;
6
import org.gvsig.gpe.xml.stream.IXmlStreamWriter;
7
import org.gvsig.gpe.xml.stream.XmlStreamException;
8

    
9
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
10
 *
11
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
12
 *
13
 * This program is free software; you can redistribute it and/or
14
 * modify it under the terms of the GNU General Public License
15
 * as published by the Free Software Foundation; either version 2
16
 * of the License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
26
 *
27
 * For more information, contact:
28
 *
29
 *  Generalitat Valenciana
30
 *   Conselleria d'Infraestructures i Transport
31
 *   Av. Blasco Ib??ez, 50
32
 *   46010 VALENCIA
33
 *   SPAIN
34
 *
35
 *      +34 963862235
36
 *   gvsig@gva.es
37
 *      www.gvsig.gva.es
38
 *
39
 *    or
40
 *
41
 *   IVER T.I. S.A
42
 *   Salamanca 50
43
 *   46005 Valencia
44
 *   Spain
45
 *
46
 *   +34 963163400
47
 *   dac@iver.es
48
 */
49
/* CVS MESSAGES:
50
 *
51
 * $Id: GPEXmlWriterHandlerImplementor.java 350 2008-01-09 12:53:07Z jpiera $
52
 * $Log$
53
 * Revision 1.12  2007/06/28 13:05:09  jorpiell
54
 * The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
55
 *
56
 * Revision 1.11  2007/06/22 12:22:40  jorpiell
57
 * The typeNotFoundException has been deleted. It never was thrown
58
 *
59
 * Revision 1.10  2007/06/14 13:50:05  jorpiell
60
 * The schema jar name has been changed
61
 *
62
 * Revision 1.9  2007/06/07 14:53:30  jorpiell
63
 * Add the schema support
64
 *
65
 * Revision 1.8  2007/05/07 07:07:04  jorpiell
66
 * Add a constructor with the name and the description fields
67
 *
68
 * Revision 1.7  2007/04/26 14:40:03  jorpiell
69
 * Some writer handler methods updated
70
 *
71
 * Revision 1.6  2007/04/19 07:25:49  jorpiell
72
 * Add the add methods to teh contenhandler and change the register mode
73
 *
74
 * Revision 1.5  2007/04/17 10:30:11  jorpiell
75
 * Add a method to compress a file
76
 *
77
 * Revision 1.4  2007/04/14 16:07:30  jorpiell
78
 * The writer has been created
79
 *
80
 * Revision 1.3  2007/04/13 07:17:57  jorpiell
81
 * Add the writting tests for the simple geometries
82
 *
83
 * Revision 1.2  2007/04/12 17:06:44  jorpiell
84
 * First GML writing tests
85
 *
86
 * Revision 1.1  2007/04/12 10:23:41  jorpiell
87
 * Add some writers and the GPEXml parser
88
 *
89
 *
90
 */
91
/**
92
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
93
 */
94
public abstract class GPEXmlWriterHandlerImplementor extends GPEWriterHandlerImplementor {
95
        protected IXmlStreamWriter writer = null;
96
        //private String targetNamespace = null;
97
        private String targetNamespacePrefix = null;
98
        
99
        public GPEXmlWriterHandlerImplementor() {
100
                super();                
101
        }        
102
        
103
        /* (non-Javadoc)
104
         * @see org.gvsig.gpe.writer.GPEWriterHandlerImplementor#initialize()
105
         */
106
        public void initialize() {
107
                super.initialize();
108
                try {
109
                        writer = GPEXmlParserFactory.getWriter(getFormat(), getOutputStream());
110
                } catch (IllegalArgumentException e) {
111
                        getErrorHandler().addError(e);
112
                } catch (XmlStreamException e) {
113
                        getErrorHandler().addError(e);
114
                }
115
        }        
116
        
117
        /**
118
         * @return the schemaLocation tag
119
         */
120
        protected String getSchemaLocations(){
121
                StringBuffer schemaLocation = new StringBuffer();
122
//                Enumeration uris = getSchemaDocument().getURIs();
123
//                int i = 0;
124
//                while (uris.hasMoreElements()){
125
//                        if (i > 0){
126
//                                schemaLocation.append("\b");
127
//                        }
128
//                        URI uri = (URI)uris.nextElement();
129
//                        IXSSchema schema = getSchemaDocument().getSchema(uri);
130
//                        schemaLocation.append(schema.getTargetNamespace());
131
//                        schemaLocation.append(" ");
132
//                        schemaLocation.append(getSchemaDocument().getSchemaLocation(uri));
133
//                        i++;
134
//                }
135
                return schemaLocation.toString();
136
        }        
137
        
138
        
139
        
140
        /**
141
         * Returns the selected target namespace prefix. If
142
         * the namespace doesn't exists it returns the 
143
         * default Namespace prefix; 
144
         * @return the namespace prefix
145
         */
146
        protected String getTargetNamespacePrefix() {
147
                if (targetNamespacePrefix == null){
148
                        String prefix = null;
149
//                        if (getSchemaDocument().getTargetNamespace() != null){
150
//                                prefix = getSchemaDocument().getNamespacePrefix(
151
//                                                getSchemaDocument().getTargetNamespace());
152
//                        }else{
153
                                prefix = getGpeManager().getStringProperty(XmlProperties.DEFAULT_NAMESPACE_PREFIX);
154
//                        }
155
                        if (prefix != null){
156
                                targetNamespacePrefix = prefix + ":";
157
                        }else{
158
                                targetNamespacePrefix = "";
159
                        }
160
                }
161
                return targetNamespacePrefix;
162
        }                
163
        
164
}
165
        
166