Revision 11157

View differences:

trunk/libraries/libGPE-KML/.classpath
3 3
	<classpathentry kind="src" path="src"/>
4 4
	<classpathentry kind="src" path="src-test"/>
5 5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6
	<classpathentry combineaccessrules="false" kind="src" path="/libGPE-GML"/>
7 6
	<classpathentry kind="lib" path="/libRemoteServices/lib/gvsig-exceptions.jar"/>
8 7
	<classpathentry kind="lib" path="/libRemoteServices/lib/kxml2.jar"/>
9 8
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
9
	<classpathentry combineaccessrules="false" kind="src" path="/libGPE"/>
10
	<classpathentry combineaccessrules="false" kind="src" path="/libGPE-GML"/>
10 11
	<classpathentry kind="output" path="bin"/>
11 12
</classpath>
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/warnings/IWarningsContainer.java
1
package org.gvsig.gpe.kml.warnings;
2

  
3
import org.gvsig.exceptions.BaseException;
4
import org.gvsig.exceptions.ListBaseException;
5

  
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$
50
 * $Log$
51
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
52
 * Add the writers
53
 *
54
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
55
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
56
 *
57
 * Revision 1.1  2007/02/28 11:48:31  csanchez
58
 * *** empty log message ***
59
 *
60
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
61
 * Añadidos los proyectos de kml y gml antiguos
62
 *
63
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
64
 * A?adido el driver de KML
65
 *
66
 *
67
 */
68
/**
69
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
70
 */
71
public interface IWarningsContainer {
72
	/**
73
	 * This method return true if there aren't warnings else returns false 
74
	 * @return boolean
75
	 */
76
	public boolean areWarnings();
77
	/**
78
	 * This method return the list of warnings parsing the file 
79
	 * @return ArrayList of warnings
80
	 */
81
	public ListBaseException getWarningList();
82
	
83
	/**
84
	 * This method inserts a new warning into the list 
85
	 * @args int new warning
86
	 */
87
	public void setElement(BaseException war);
88
	/**
89
	 * This method returns a warning from the list 
90
	 * @args int index
91
	 * @return int warning
92
	 */
93
	public BaseException getElement(int index, ListBaseException war);
94
	
95
	/**
96
	 * This method inserts a new warning list 
97
	 * @args int new warning
98
	 */
99
	public void setWarningList(ListBaseException war);
100
}
0 101

  
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/warnings/VersionNotFoundWarning.java
1
package org.gvsig.gpe.kml.warnings;
2

  
3
import java.io.File;
4
import java.util.Hashtable;
5
import java.util.Map;
6

  
7
import org.gvsig.exceptions.BaseException;
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$
52
 * $Log$
53
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
54
 * Add the writers
55
 *
56
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
57
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
58
 *
59
 * Revision 1.1  2007/02/28 11:48:31  csanchez
60
 * *** empty log message ***
61
 *
62
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
63
 * Añadidos los proyectos de kml y gml antiguos
64
 *
65
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
66
 * A?adido el driver de KML
67
 *
68
 *
69
 */
70
/**
71
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
72
 */
73
public class VersionNotFoundWarning extends BaseException{
74
	private static final long serialVersionUID = -7929656757664427123L;
75
	private File m_File = null;
76
	
77
	public VersionNotFoundWarning() {		
78
		init();		
79
	}
80
	
81
	public VersionNotFoundWarning(Throwable exception) {
82
		init();
83
		initCause(exception);
84
	}
85
	
86
	private void init() {
87
		messageKey = "warning_kml_versionNotFound";
88
		formatString = "The lm? version number is not specified";
89
		code = serialVersionUID;		
90
	}
91

  
92
	protected Map values() {
93
		return new Hashtable();
94
	}
95
}
0 96

  
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/warnings/WarningsContainer.java
1
package org.gvsig.gpe.kml.warnings;
2

  
3
import org.gvsig.exceptions.BaseException;
4
import org.gvsig.exceptions.ListBaseException;
5

  
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$
50
 * $Log$
51
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
52
 * Add the writers
53
 *
54
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
55
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
56
 *
57
 * Revision 1.1  2007/02/28 11:48:31  csanchez
58
 * *** empty log message ***
59
 *
60
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
61
 * Añadidos los proyectos de kml y gml antiguos
62
 *
63
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
64
 * A?adido el driver de KML
65
 *
66
 *
67
 */
68
/**
69
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
70
 */
71
public class WarningsContainer implements IWarningsContainer{
72
	private ListBaseException warning = null;
73
	
74
	public WarningsContainer(){
75
		warning = new WarningList();
76
	}
77
	
78
	/*
79
	 *  (non-Javadoc)
80
	 * @see org.gvsig.remoteClient.kml.warnings.IWarningsContainer#areWarnings()
81
	 */
82
	public boolean areWarnings() {
83
		if (warning.isEmpty()){
84
			return false;						
85
		}
86
		return true;
87
	}
88

  
89
	/*
90
	 *  (non-Javadoc)
91
	 * @see org.gvsig.remoteClient.kml.warnings.IWarningsContainer#getWarningList()
92
	 */
93
	public ListBaseException getWarningList() {
94
		return warning;
95
	}
96

  
97
	/*
98
	 *  (non-Javadoc)
99
	 * @see org.gvsig.remoteClient.kml.warnings.IWarningsContainer#setElement(org.gvsig.exceptions.BaseException)
100
	 */
101
	public void setElement(BaseException war) {
102
//		Only we add a warning when it is new
103
		if (warning.contains(war)==false)
104
		{
105
			warning.add((war));
106
		}
107
	}
108

  
109
	/*
110
	 *  (non-Javadoc)
111
	 * @see org.gvsig.remoteClient.kml.warnings.IWarningsContainer#getElement(int, org.gvsig.exceptions.ListBaseException)
112
	 */
113
	public BaseException getElement(int index, ListBaseException war) {
114
//		it returns the int value of a warning or 0 if it doesn't exists
115
		if (war.isEmpty()==false)
116
		{
117
			if (index < war.size()){
118
				return (BaseException)war.get(index);
119
			}
120
		}
121
		return null;
122
	}
123

  
124
	/*
125
	 *  (non-Javadoc)
126
	 * @see org.gvsig.remoteClient.kml.warnings.IWarningsContainer#setWarningList(org.gvsig.exceptions.ListBaseException)
127
	 */
128
	public void setWarningList(ListBaseException war) {
129
		int i=0;
130
		BaseException info;
131
		while(i < war.size()){
132
			info = this.getElement(i,war);
133
			if (info != null)
134
			{
135
				this.setElement(info);
136
			}
137
			i++;
138
		}
139
	}
140
}
0 141

  
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/warnings/NotNamespaceParserWarning.java
1
package org.gvsig.gpe.kml.warnings;
2

  
3
import java.util.Hashtable;
4
import java.util.Map;
5

  
6
import org.gvsig.exceptions.BaseException;
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id$
51
 * $Log$
52
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
53
 * Add the writers
54
 *
55
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
56
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
57
 *
58
 * Revision 1.1  2007/02/28 11:48:31  csanchez
59
 * *** empty log message ***
60
 *
61
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
62
 * Añadidos los proyectos de kml y gml antiguos
63
 *
64
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
65
 * A?adido el driver de KML
66
 *
67
 *
68
 */
69
/**
70
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
71
 */
72
public class NotNamespaceParserWarning extends BaseException{ 
73
	private static final long serialVersionUID = -5950402725537407038L;
74
	private String nameSpace = null;
75
	
76
	public NotNamespaceParserWarning(String nameSpace) {
77
		this.nameSpace = nameSpace;
78
		init();		
79
	}
80
	
81
	public NotNamespaceParserWarning(String nameSpace,Throwable exception) {
82
		this.nameSpace = nameSpace;
83
		init();
84
		initCause(exception);
85
	}
86
	
87
	private void init() {
88
		messageKey = "error_kml_notParserForNamespace";
89
		formatString = "The namespace %(namespace) is not recognized. Anyway, the system will be try to parse";
90
		code = serialVersionUID;		
91
	}
92
	
93
	protected Map values() {
94
		Hashtable params = new Hashtable();
95
		params.put("nameSpace",nameSpace);
96
		return params;		
97
	}
98
}
0 99

  
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/warnings/WarningList.java
1
package org.gvsig.gpe.kml.warnings;
2

  
3
import java.util.Map;
4

  
5
import org.gvsig.exceptions.ListBaseException;
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$
50
 * $Log$
51
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
52
 * Add the writers
53
 *
54
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
55
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
56
 *
57
 * Revision 1.1  2007/02/28 11:48:31  csanchez
58
 * *** empty log message ***
59
 *
60
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
61
 * Añadidos los proyectos de kml y gml antiguos
62
 *
63
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
64
 * A?adido el driver de KML
65
 *
66
 *
67
 */
68
/**
69
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
70
 */
71
public class WarningList extends ListBaseException {
72

  
73
	protected Map values() {
74
		// TODO Auto-generated method stub
75
		return null;
76
	}
77

  
78
	
79

  
80
}
0 81

  
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/KmlParsersFactory.java
8 8
import org.gvsig.gpe.kml.engine.IFeaturesParser;
9 9
import org.gvsig.gpe.kml.engine.IReaderFile;
10 10
import org.gvsig.gpe.kml.exceptions.KmlImpossibleCreateParser;
11
import org.gvsig.gpe.kml.warnings.NotNamespaceParserWarning;
12
import org.gvsig.gpe.kml.warnings.WarningsContainer;
11 13

  
12
import warnings.NotNamespaceParserWarning;
13
import warnings.WarningsContainer;
14 14

  
15 15
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16 16
 *
......
56 56
 *
57 57
 * $Id$
58 58
 * $Log$
59
 * Revision 1.1  2007-03-07 08:19:10  jorpiell
59
 * Revision 1.2  2007-04-12 10:21:52  jorpiell
60
 * Add the writers
61
 *
62
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
60 63
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
61 64
 *
62 65
 * Revision 1.1  2007/02/28 11:48:31  csanchez
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/GPEKmlParser.java
1
package org.gvsig.gpe.kml;
2

  
3
import java.io.BufferedInputStream;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileNotFoundException;
7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.util.zip.ZipEntry;
10
import java.util.zip.ZipException;
11
import java.util.zip.ZipFile;
12
import java.util.zip.ZipInputStream;
13

  
14
import org.gvsig.gpe.GPEContentHandler;
15
import org.gvsig.gpe.GPEErrorHandler;
16
import org.gvsig.gpe.GPEParser;
17
import org.gvsig.gpe.kml.exceptions.KmlException;
18
import org.gvsig.gpe.kml.writer.GPEKmlWriterHandler;
19
import org.gvsig.gpe.writer.IGPEWriterHandler;
20
import org.gvsig.gpe.xml.GPEXmlParser;
21

  
22
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
23
 *
24
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
25
 *
26
 * This program is free software; you can redistribute it and/or
27
 * modify it under the terms of the GNU General Public License
28
 * as published by the Free Software Foundation; either version 2
29
 * of the License, or (at your option) any later version.
30
 *
31
 * This program is distributed in the hope that it will be useful,
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
 * GNU General Public License for more details.
35
 *
36
 * You should have received a copy of the GNU General Public License
37
 * along with this program; if not, write to the Free Software
38
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
39
 *
40
 * For more information, contact:
41
 *
42
 *  Generalitat Valenciana
43
 *   Conselleria d'Infraestructures i Transport
44
 *   Av. Blasco Ib??ez, 50
45
 *   46010 VALENCIA
46
 *   SPAIN
47
 *
48
 *      +34 963862235
49
 *   gvsig@gva.es
50
 *      www.gvsig.gva.es
51
 *
52
 *    or
53
 *
54
 *   IVER T.I. S.A
55
 *   Salamanca 50
56
 *   46005 Valencia
57
 *   Spain
58
 *
59
 *   +34 963163400
60
 *   dac@iver.es
61
 */
62
/* CVS MESSAGES:
63
 *
64
 * $Id$
65
 * $Log$
66
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
67
 * Add the writers
68
 *
69
 *
70
 */
71
/**
72
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
73
 */
74
public class GPEKmlParser extends GPEXmlParser {
75

  
76
	public GPEKmlParser(GPEContentHandler contentHandler,GPEErrorHandler errorHandler) {
77
		super(contentHandler,errorHandler);		
78
	}
79

  
80
	/*
81
	 * (non-Javadoc)
82
	 * @see org.gvsig.gpe.GPEParser#accept(java.io.File)
83
	 */
84
	public boolean accept(File file) {
85
		if ((file.getName().toUpperCase().endsWith("KML")) ||
86
				(file.getName().toUpperCase().endsWith("KMZ"))){
87
			return true;
88
		}
89
		return false;
90
	}
91
	
92
	/*
93
	 * (non-Javadoc)
94
	 * @see org.gvsig.gpe.GPEParser#getFormats()
95
	 */
96
	public String[] getFormats() {
97
		String[] formats = new String[2];
98
		formats[0] = "KML";
99
		formats[1] = "KMZ";
100
		return formats;
101
	}
102

  
103
	/*
104
	 * (non-Javadoc)
105
	 * @see org.gvsig.gpe.GPEParser#getWriter(java.lang.String, java.lang.String)
106
	 */
107
	public IGPEWriterHandler getWriter(String format, File file) throws IOException {
108
		return new GPEKmlWriterHandler(format,file);
109
	}
110
	
111
	
112
	/**
113
	 * It creates an InputStream. The Kml file can have the
114
	 * KML or the KMZ extension
115
	 * @return
116
	 * @throws KmlException
117
	 */
118
	protected InputStream createInputStream(File file){
119
		try {
120
			if (file.getName().toUpperCase().endsWith("KML")){
121
				return new FileInputStream(file);
122
			}else if(file.getName().toUpperCase().endsWith("KMZ")){
123
				FileInputStream fis = new FileInputStream(file);
124
				ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
125
				ZipEntry entry = null;
126
				while((entry = zis.getNextEntry()) != null){
127
					if (!entry.isDirectory()){
128
						ZipFile fz = new ZipFile(file);
129
						return fz.getInputStream(entry);
130
					}
131
				}
132
			}
133
		} catch (FileNotFoundException e) {
134
			// TODO Auto-generated catch block
135
			e.printStackTrace();
136
		} catch (ZipException e) {
137
			// TODO Auto-generated catch block
138
			e.printStackTrace();
139
		} catch (IOException e) {
140
			// TODO Auto-generated catch block
141
			e.printStackTrace();
142
		}	
143
		return null;
144
	}
145

  
146
	/*
147
	 * (non-Javadoc)
148
	 * @see org.gvsig.gpe.xml.GPEXmlParser#initParse()
149
	 */
150
	protected void initParse() {
151
				
152
	}
153
}
0 154

  
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/writer/GPEKmlWriterHandler.java
1
package org.gvsig.gpe.kml.writer;
2

  
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileNotFoundException;
6
import java.io.FileOutputStream;
7
import java.io.FileWriter;
8
import java.io.IOException;
9
import java.io.OutputStream;
10
import java.io.Writer;
11

  
12
import org.gvsig.gpe.writer.GPEWriterHandler;
13
import org.gvsig.gpe.xml.writer.GPEXmlWriterHandler;
14

  
15
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id$
58
 * $Log$
59
 * Revision 1.1  2007-04-12 10:21:52  jorpiell
60
 * Add the writers
61
 *
62
 *
63
 */
64
/**
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public class GPEKmlWriterHandler extends GPEXmlWriterHandler{
68

  
69
	public GPEKmlWriterHandler(String format, File file) throws IOException {
70
		super(format, file);		
71
	}
72

  
73
	/*
74
	 * (non-Javadoc)
75
	 * @see org.gvsig.gpe.xml.writer.GPEXmlWriterHandler#createOutputStream()
76
	 */
77
	protected Writer createWriter() throws IOException {
78
		if(getFile().getName().toUpperCase().endsWith("KMZ")){
79
			//TODO: Create the KMZ outputStream
80
		}
81
		return new FileWriter(getFile());	 
82
	}
83

  
84
}
0 85

  

Also available in: Unified diff