Revision 11265

View differences:

trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPELayerHeaderTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import java.io.File;
4 3

  
5
import org.gvsig.gpe.GPEErrorHandler;
6

  
7 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8 5
 *
9 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
48 45
 *
49 46
 * $Id$
50 47
 * $Log$
51
 * Revision 1.2  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.3  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
52 52
 * Add the container classes
53 53
 *
54 54
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPELinearRingLayerTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import java.io.File;
4
import java.io.IOException;
5 3

  
6
import org.gvsig.gpe.GPEErrorHandler;
7

  
8 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9 5
 *
10 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
49 45
 *
50 46
 * $Id$
51 47
 * $Log$
52
 * Revision 1.2  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.3  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
53 52
 * Add the container classes
54 53
 *
55 54
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEPolygonsLayerTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import java.io.File;
4
import java.io.IOException;
5 3

  
6
import org.gvsig.gpe.GPEErrorHandler;
7

  
8 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9 5
 *
10 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
49 45
 *
50 46
 * $Id$
51 47
 * $Log$
52
 * Revision 1.3  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.4  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.3  2007/04/14 16:06:35  jorpiell
53 52
 * Add the container classes
54 53
 *
55 54
 * Revision 1.2  2007/04/13 13:14:55  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEWriterBaseTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3 3
import java.io.File;
4
import java.io.IOException;
5
import java.lang.reflect.InvocationTargetException;
6 4
import java.util.ArrayList;
7 5

  
8 6
import junit.framework.TestCase;
......
60 58
 *
61 59
 * $Id$
62 60
 * $Log$
63
 * Revision 1.4  2007-04-19 07:23:20  jorpiell
61
 * Revision 1.5  2007-04-19 11:50:20  csanchez
62
 * Actualizacion protoripo libGPE
63
 *
64
 * Revision 1.4  2007/04/19 07:23:20  jorpiell
64 65
 * Add the add methods to teh contenhandler and change the register mode
65 66
 *
66 67
 * Revision 1.3  2007/04/17 06:27:20  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEPointsLayerTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import java.io.File;
4

  
5
import org.gvsig.gpe.GPEErrorHandler;
6 3
import org.gvsig.gpe.containers.Element;
7 4
import org.gvsig.gpe.containers.Feature;
8 5
import org.gvsig.gpe.containers.Layer;
......
51 48
 *
52 49
 * $Id$
53 50
 * $Log$
54
 * Revision 1.3  2007-04-19 07:23:20  jorpiell
51
 * Revision 1.4  2007-04-19 11:50:20  csanchez
52
 * Actualizacion protoripo libGPE
53
 *
54
 * Revision 1.3  2007/04/19 07:23:20  jorpiell
55 55
 * Add the add methods to teh contenhandler and change the register mode
56 56
 *
57 57
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPELineStringLayerTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import java.io.File;
4 3

  
5
import org.gvsig.gpe.GPEErrorHandler;
6

  
7 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8 5
 *
9 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
48 45
 *
49 46
 * $Id$
50 47
 * $Log$
51
 * Revision 1.2  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.3  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
52 52
 * Add the container classes
53 53
 *
54 54
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEMultiPolygonLayerTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import java.io.File;
4
import java.io.IOException;
5 3

  
6
import org.gvsig.gpe.GPEErrorHandler;
7

  
8 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9 5
 *
10 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
49 45
 *
50 46
 * $Id$
51 47
 * $Log$
52
 * Revision 1.2  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.3  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
53 52
 * Add the container classes
54 53
 *
55 54
 * Revision 1.1  2007/04/13 13:14:55  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/GPEMultiPointLayerTest.java
1 1
package org.gvsig.gpe.writers;
2 2

  
3
import org.gvsig.gpe.containers.Layer;
4 3

  
5 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6 5
 *
......
46 45
 *
47 46
 * $Id$
48 47
 * $Log$
49
 * Revision 1.2  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.3  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
50 52
 * Add the container classes
51 53
 *
52 54
 * Revision 1.1  2007/04/13 13:14:55  jorpiell
trunk/libraries/libGPE/src-test/org/gvsig/gpe/containers/Element.java
1 1
package org.gvsig.gpe.containers;
2 2

  
3
import java.util.ArrayList;
4 3

  
5 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6 5
 *
......
46 45
 *
47 46
 * $Id$
48 47
 * $Log$
49
 * Revision 1.1  2007-04-14 16:06:35  jorpiell
48
 * Revision 1.2  2007-04-19 11:50:20  csanchez
49
 * Actualizacion protoripo libGPE
50
 *
51
 * Revision 1.1  2007/04/14 16:06:35  jorpiell
50 52
 * Add the container classes
51 53
 *
52 54
 *
trunk/libraries/libGPE/src-test/org/gvsig/gpe/readers/GPEReaderBaseTest.java
1 1
package org.gvsig.gpe.readers;
2 2

  
3 3
import java.io.File;
4
import java.lang.reflect.InvocationTargetException;
5 4
import java.util.ArrayList;
6 5

  
6
import junit.framework.TestCase;
7

  
7 8
import org.gvsig.gpe.GPEContentHandler;
8 9
import org.gvsig.gpe.GPEContentHandlerTest;
9 10
import org.gvsig.gpe.GPEErrorHandler;
......
12 13
import org.gvsig.gpe.GPERegister;
13 14
import org.gvsig.gpe.containers.Layer;
14 15

  
15
import junit.framework.TestCase;
16

  
17 16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18 17
 *
19 18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
58 57
 *
59 58
 * $Id$
60 59
 * $Log$
61
 * Revision 1.4  2007-04-19 07:23:20  jorpiell
60
 * Revision 1.5  2007-04-19 11:50:20  csanchez
61
 * Actualizacion protoripo libGPE
62
 *
63
 * Revision 1.4  2007/04/19 07:23:20  jorpiell
62 64
 * Add the add methods to teh contenhandler and change the register mode
63 65
 *
64 66
 * Revision 1.3  2007/04/14 16:06:35  jorpiell
......
82 84
	private GPEParser parser = null;
83 85
	private GPEContentHandler contenHandler = null;
84 86
	private GPEErrorHandler errorHandler = null;
87
	private String parserName="FORMAT VERSION";
88
	private String parserDescription="default parser description";
85 89
	
90
	
86 91
	public void setUp() throws Exception{
87 92
		//Register the parser
88 93
		GPERegister.addGpeParser(getGPEParserName(), 
......
117 122
	 * process
118 123
	 */
119 124
	public String getGPEParserName(){
120
		return "FORMAT VERSION";
125
		return parserName;
121 126
	}
122 127
	
123 128
	/**
......
126 131
	 * process
127 132
	 */
128 133
	public String getGPEParserDescription(){
129
		return "default parser description";
134
		return parserDescription ;
130 135
	}
136
	/**
137
	 * Each test must to return its parser name
138
	 * to register it before to start the parsing
139
	 * process
140
	 */
141
	public void setGPEParserName(String name){
142
		parserName=name;
143
	}
131 144
	
132 145
	/**
146
	 * Each test must to return its parser description
147
	 * to register it before to start the parsing
148
	 * process
149
	 */
150
	public void setGPEParserDescription(String description){
151
		parserDescription=description;
152
	}
153
	/**
133 154
	 * Each test must to return its parser class
134 155
	 * that will be used to create new parsers.
135 156
	 */
trunk/libraries/libGPE/src/org/gvsig/gpe/writers/GPEWriterHandler.java
4 4

  
5 5
import org.gvsig.gpe.GPEDefaults;
6 6
import org.gvsig.gpe.GPEErrorHandler;
7
import org.gvsig.gpe.IGPEContentHandler;
8
import org.xml.sax.ErrorHandler;
9 7

  
10 8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11 9
 *
......
51 49
 *
52 50
 * $Id$
53 51
 * $Log$
54
 * Revision 1.4  2007-04-19 07:23:20  jorpiell
52
 * Revision 1.5  2007-04-19 11:50:20  csanchez
53
 * Actualizacion protoripo libGPE
54
 *
55
 * Revision 1.4  2007/04/19 07:23:20  jorpiell
55 56
 * Add the add methods to teh contenhandler and change the register mode
56 57
 *
57 58
 * Revision 1.3  2007/04/14 16:06:13  jorpiell
trunk/libraries/libGPE/src/org/gvsig/gpe/GPERegister.java
2 2

  
3 3
import java.io.File;
4 4
import java.lang.reflect.InvocationTargetException;
5
import java.util.ArrayList;
6 5
import java.util.Hashtable;
7 6
import java.util.Iterator;
8 7

  
......
52 51
 *
53 52
 * $Id$
54 53
 * $Log$
55
 * Revision 1.9  2007-04-19 07:23:20  jorpiell
54
 * Revision 1.10  2007-04-19 11:50:20  csanchez
55
 * Actualizacion protoripo libGPE
56
 *
57
 * Revision 1.9  2007/04/19 07:23:20  jorpiell
56 58
 * Add the add methods to teh contenhandler and change the register mode
57 59
 *
58 60
 * Revision 1.8  2007/04/18 12:54:45  csanchez
trunk/libraries/libGPE/src/org/gvsig/gpe/GPEDefaults.java
2 2

  
3 3
import java.util.Properties;
4 4

  
5
import org.apache.xml.utils.NameSpace;
6

  
7 5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8 6
 *
9 7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
48 46
 *
49 47
 * $Id$
50 48
 * $Log$
51
 * Revision 1.4  2007-04-18 11:03:36  jorpiell
49
 * Revision 1.5  2007-04-19 11:50:20  csanchez
50
 * Actualizacion protoripo libGPE
51
 *
52
 * Revision 1.4  2007/04/18 11:03:36  jorpiell
52 53
 * Add the default schema property
53 54
 *
54 55
 * Revision 1.3  2007/04/14 16:06:13  jorpiell
trunk/libraries/libGPE/src/org/gvsig/gpe/GPEParser.java
1 1
package org.gvsig.gpe;
2 2
import java.io.File;
3
import java.io.FileNotFoundException;
4
import java.io.IOException;
5 3

  
6
import org.gvsig.gpe.writers.GPEWriterHandler;
7 4

  
8

  
9 5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
10 6
 *
11 7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
50 46
 *
51 47
 * $Id$
52 48
 * $Log$
53
 * Revision 1.8  2007-04-19 07:23:20  jorpiell
49
 * Revision 1.9  2007-04-19 11:50:20  csanchez
50
 * Actualizacion protoripo libGPE
51
 *
52
 * Revision 1.8  2007/04/19 07:23:20  jorpiell
54 53
 * Add the add methods to teh contenhandler and change the register mode
55 54
 *
56 55
 * Revision 1.7  2007/04/14 16:06:13  jorpiell
trunk/libraries/libGPE-GML/src-test/testParserGML.java
1
import java.io.File;
2 1
import java.lang.reflect.InvocationTargetException;
3 2

  
4
import org.gvsig.gpe.GPEContentHandler;
5
import org.gvsig.gpe.GPEErrorHandler;
6
import org.gvsig.gpe.GPEParser;
7
import org.gvsig.gpe.GPERegister;
8

  
9
import junit.framework.TestCase;
3
import org.gvsig.gpe.readers.GPEReaderBaseTest;
10 4
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11 5
 *
12 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
51 45
 *
52 46
 * $Id$
53 47
 * $Log$
54
 * Revision 1.1  2007-04-18 12:54:45  csanchez
48
 * Revision 1.2  2007-04-19 11:51:43  csanchez
55 49
 * Actualizacion protoripo libGPE
56 50
 *
51
 * Revision 1.1  2007/04/18 12:54:45  csanchez
52
 * Actualizacion protoripo libGPE
57 53
 *
54
 *
58 55
 */
59 56
/**
60 57
 * @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
61 58
 */
62
public class testParserGML extends TestCase {
59
public class testParserGML extends GPEReaderBaseTest {
63 60

  
64 61
	public void setUp() throws IllegalArgumentException, SecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException{
65
		GPEContentHandler content=null;
66
		GPEErrorHandler errors=null;
67
		//Para registrar un driver... con los handlers de prueba de la aplicaci?n.
68
		GPERegister.addGpeDriver("GMLParser",content,errors);		
62
		
63
		//Para registrar un driver... necesitamos un nombre una descripci?n 
64
		//y la ruta de la librer?a junto con la clase que la implementa.
65
		this.setGPEParserName("GMLParser");
66
		this.setGPEParserDescription("parser de GML versi?n 2.x");
67
			
69 68
	}
70
	public void testLineas(){
71
		File ficherin = new File("testdata/GML-lines.gml");
72
		GPEParser parser= null;
69
	
70
	//Comprobaciones de lectura
71
	public void makeAsserts() {
72
		// TODO Ap?ndice de m?todo generado autom?ticamente
73 73
		
74
		//El accept es una utilidad para comprobar si est? registrado el parser para ese formato
75
		assertEquals(GPERegister.accept(ficherin),true);
76
		//El GPERegister devuelve el parser (del tipo GPEParser) para el formato correcto si existe.
77
		try {
78
			parser=GPERegister.getParser(ficherin);
79
		} catch (Exception e) {
80
			// TODO Bloque catch generado autom?ticamente
81
			e.printStackTrace();
82
		}
83
		//ya podemos arrancar el parser que me devolver? eventos
84
		try {
85
			parser.parse(ficherin);
86
		} catch (Exception e) {
87
			// TODO Bloque catch generado autom?ticamente
88
			e.printStackTrace();
89
		}
90 74
	}
75
	//Aqui se le pasa la clase 
76
	public Class getGPEParserClass() {
77
		// TODO Ap?ndice de m?todo generado autom?ticamente
78
		return org.gvsig.gpe.gml.GPEGmlParser.class;
79
	}
80
	//Aqui se le pasa el fichero a usar por el test
81
	public String getFile() {
82
		// TODO Ap?ndice de m?todo generado autom?ticamente
83
		return "testdata/GML-lines.gml";
84
	}
85
	
91 86
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLLineStringLayerTest.java
55 55
 *
56 56
 * $Id$
57 57
 * $Log$
58
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
58
 * Revision 1.3  2007-04-19 11:51:43  csanchez
59
 * Actualizacion protoripo libGPE
60
 *
61
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
59 62
 * The writer has been created
60 63
 *
61 64
 * Revision 1.1  2007/04/13 07:17:57  jorpiell
......
87 90
		return "org.gvsig.gpe.gml.GPEGmlParser";
88 91
	}
89 92

  
93
	public Class getGPEWriterHandlerClass() {
94
		// TODO Ap?ndice de m?todo generado autom?ticamente
95
		return null;
96
	}
97

  
98
	public Class getGPEParserClass() {
99
		// TODO Ap?ndice de m?todo generado autom?ticamente
100
		return null;
101
	}
102

  
90 103
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLMultiPolygonLayerTest.java
53 53
 *
54 54
 * $Id$
55 55
 * $Log$
56
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
56
 * Revision 1.3  2007-04-19 11:51:43  csanchez
57
 * Actualizacion protoripo libGPE
58
 *
59
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
57 60
 * The writer has been created
58 61
 *
59 62
 * Revision 1.1  2007/04/13 13:16:00  jorpiell
......
81 84
	public String getGPEParserName() {
82 85
		return "org.gvsig.gpe.gml.GPEGmlParser";
83 86
	}
87

  
88
	public Class getGPEWriterHandlerClass() {
89
		// TODO Ap?ndice de m?todo generado autom?ticamente
90
		return null;
91
	}
92

  
93
	public Class getGPEParserClass() {
94
		// TODO Ap?ndice de m?todo generado autom?ticamente
95
		return null;
96
	}
84 97
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLMultiPointLayerTest.java
52 52
 *
53 53
 * $Id$
54 54
 * $Log$
55
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
55
 * Revision 1.3  2007-04-19 11:51:43  csanchez
56
 * Actualizacion protoripo libGPE
57
 *
58
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
56 59
 * The writer has been created
57 60
 *
58 61
 * Revision 1.1  2007/04/13 13:16:00  jorpiell
......
79 82
	public String getGPEParserName() {
80 83
		return "org.gvsig.gpe.gml.GPEGmlParser";
81 84
	}
85

  
86
	public Class getGPEWriterHandlerClass() {
87
		// TODO Ap?ndice de m?todo generado autom?ticamente
88
		return null;
89
	}
90

  
91
	public Class getGPEParserClass() {
92
		// TODO Ap?ndice de m?todo generado autom?ticamente
93
		return null;
94
	}
82 95
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLPolygonLayerTest.java
52 52
 *
53 53
 * $Id$
54 54
 * $Log$
55
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
55
 * Revision 1.3  2007-04-19 11:51:43  csanchez
56
 * Actualizacion protoripo libGPE
57
 *
58
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
56 59
 * The writer has been created
57 60
 *
58 61
 * Revision 1.1  2007/04/13 07:17:57  jorpiell
......
80 83
	public String getGPEParserName() {
81 84
		return "org.gvsig.gpe.gml.GPEGmlParser";
82 85
	}
86

  
87
	public Class getGPEWriterHandlerClass() {
88
		// TODO Ap?ndice de m?todo generado autom?ticamente
89
		return null;
90
	}
91

  
92
	public Class getGPEParserClass() {
93
		// TODO Ap?ndice de m?todo generado autom?ticamente
94
		return null;
95
	}
83 96
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLLayerHeaderTest.java
56 56
 *
57 57
 * $Id$
58 58
 * $Log$
59
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
59
 * Revision 1.3  2007-04-19 11:51:43  csanchez
60
 * Actualizacion protoripo libGPE
61
 *
62
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
60 63
 * The writer has been created
61 64
 *
62 65
 * Revision 1.1  2007/04/13 07:17:57  jorpiell
......
87 90
	public String getGPEParserName() {
88 91
		return "org.gvsig.gpe.gml.GPEGmlParser";
89 92
	}
93

  
94
	public Class getGPEWriterHandlerClass() {
95
		// TODO Ap?ndice de m?todo generado autom?ticamente
96
		return null;
97
	}
98

  
99
	public Class getGPEParserClass() {
100
		// TODO Ap?ndice de m?todo generado autom?ticamente
101
		return null;
102
	}
90 103
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLMultiLineStringLayerTest.java
52 52
 *
53 53
 * $Id$
54 54
 * $Log$
55
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
55
 * Revision 1.3  2007-04-19 11:51:43  csanchez
56
 * Actualizacion protoripo libGPE
57
 *
58
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
56 59
 * The writer has been created
57 60
 *
58 61
 * Revision 1.1  2007/04/13 13:16:00  jorpiell
......
80 83
	public String getGPEParserName() {
81 84
		return "org.gvsig.gpe.gml.GPEGmlParser";
82 85
	}
86

  
87
	public Class getGPEWriterHandlerClass() {
88
		// TODO Ap?ndice de m?todo generado autom?ticamente
89
		return null;
90
	}
91

  
92
	public Class getGPEParserClass() {
93
		// TODO Ap?ndice de m?todo generado autom?ticamente
94
		return null;
95
	}
83 96
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLLinearRingLayerTest.java
52 52
 *
53 53
 * $Id$
54 54
 * $Log$
55
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
55
 * Revision 1.3  2007-04-19 11:51:43  csanchez
56
 * Actualizacion protoripo libGPE
57
 *
58
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
56 59
 * The writer has been created
57 60
 *
58 61
 * Revision 1.1  2007/04/13 07:17:57  jorpiell
......
81 84
		return "org.gvsig.gpe.gml.GPEGmlParser";
82 85
	}
83 86

  
87
	public Class getGPEWriterHandlerClass() {
88
		// TODO Ap?ndice de m?todo generado autom?ticamente
89
		return null;
90
	}
91

  
92
	public Class getGPEParserClass() {
93
		// TODO Ap?ndice de m?todo generado autom?ticamente
94
		return null;
95
	}
96

  
84 97
}
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/gml/writers/GMLPointsLayerTest.java
55 55
 *
56 56
 * $Id$
57 57
 * $Log$
58
 * Revision 1.2  2007-04-14 16:07:30  jorpiell
58
 * Revision 1.3  2007-04-19 11:51:43  csanchez
59
 * Actualizacion protoripo libGPE
60
 *
61
 * Revision 1.2  2007/04/14 16:07:30  jorpiell
59 62
 * The writer has been created
60 63
 *
61 64
 * Revision 1.1  2007/04/13 07:17:57  jorpiell
......
86 89
	public String getGPEParserName() {
87 90
		return "org.gvsig.gpe.gml.GPEGmlParser";
88 91
	}
92

  
93
	public Class getGPEWriterHandlerClass() {
94
		// TODO Ap?ndice de m?todo generado autom?ticamente
95
		return null;
96
	}
97

  
98
	public Class getGPEParserClass() {
99
		// TODO Ap?ndice de m?todo generado autom?ticamente
100
		return null;
101
	}
89 102
	
90 103
}
trunk/libraries/libGPE-GML/src/GPEGmlParser.java
1
import java.io.File;
2
import java.io.FileInputStream;
3
import java.io.FileNotFoundException;
4
import java.io.IOException;
5
import java.io.InputStream;
6

  
7
import org.gvsig.gpe.GPEContentHandler;
8
import org.gvsig.gpe.GPEErrorHandler;
9
import org.gvsig.gpe.gml.writer.GPEGmlWriterHandler;
10
import org.gvsig.gpe.writers.GPEWriterHandler;
11
import org.gvsig.gpe.xml.GPEXmlParser;
12
import org.xmlpull.v1.XmlPullParserException;
13

  
14
import com.sun.xml.xsom.parser.XSOMParser;
15

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

  
70
	private XSOMParser SchemaParser = null;
71
	
72
	public GPEGmlParser(GPEContentHandler contents, GPEErrorHandler errors) {
73
		super(contents, errors);
74
		// TODO Ap?ndice de constructor generado autom?ticamente
75
	}
76
	
77
	/*
78
	 * (non-Javadoc)
79
	 * @see org.gvsig.gpe.GPEParser#getFormats()
80
	 */
81
	public String[] getFormats() {
82
		String[] formats = new String[2];
83
		formats[0] = "GML";
84
		formats[1] = "XML";
85
		return formats;
86
	}
87

  
88
//	/*
89
//	 * (non-Javadoc)
90
//	 * @see org.gvsig.gpe.GPEParser#getWriter(java.lang.String, java.lang.String)
91
//	 */
92
//	 public IGPEContentHandler getHandler(String format, File file) throws IOException {
93
//		return new GPEContentHandler(format,file);
94
//	}
95

  
96
	/** 
97
	 * 
98
	 * AQUI SE IMPLEMENTA LA BASE PARA PODER PARSEAR CUALQUIER FICHERO GML:
99
	 * -COMPROBAR SI EXISTE
100
	 * -COMPROBAR CODIFICACI?N DEL XML
101
	 * -ABRIR EN MODO LECTURA CON LA CODIFICACI?N CORRECTA
102
	 * -CREAR EL PARSER DE XML ?"XSOM"?
103
	 * -DETECTAR FORMATO FICHERO Y VERSI?N ?"EST? REGISTRADO"?
104
	 * -SI EXISTE, LLAMADA AL PARSER DEL FORMATO CONCRETO
105
	 *
106
	 **/
107
	
108
	public boolean accept(File file) {
109
		if ((file.getName().toUpperCase().endsWith("GML"))
110
				|| (file.getName().toUpperCase().endsWith("XML"))) {
111
			return true;
112
		}
113
		return false;
114
	}
115

  
116
	protected InputStream createInputStream(File file) throws FileNotFoundException {
117
		// TODO Ap?ndice de m?todo generado autom?ticamente
118
		return new FileInputStream(file);
119
	}
120

  
121
	protected void initParse() {
122
		
123
	}
124
	/*
125
	 * (non-Javadoc)
126
	 * @see org.gvsig.gpe.GPEParser#getWriter(java.lang.String)
127
	 */
128
	public GPEWriterHandler getWriter(String format) {
129
		return new GPEGmlWriterHandler(format, getErrorHandler());
130
	}
131

  
132
}
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/xml/GPEXmlParser.java
6 6
import java.io.InputStream;
7 7
import java.lang.reflect.InvocationTargetException;
8 8

  
9
import org.gvsig.gpe.GPEContentHandler;
10
import org.gvsig.gpe.GPEErrorHandler;
11 9
import org.gvsig.gpe.GPEParser;
12 10
import org.xmlpull.v1.XmlPullParser;
13 11
import org.xmlpull.v1.XmlPullParserException;
......
56 54
 *
57 55
 * $Id$
58 56
 * $Log$
59
 * Revision 1.4  2007-04-19 07:30:40  jorpiell
57
 * Revision 1.5  2007-04-19 11:56:03  csanchez
58
 * Actualizacion protoripo libGPE
59
 *
60
 * Revision 1.4  2007/04/19 07:30:40  jorpiell
60 61
 * Add the add methods to teh contenhandler and change the register mode
61 62
 *
62 63
 * Revision 1.3  2007/04/18 12:54:45  csanchez
......
77 78
 */
78 79
public abstract class GPEXmlParser extends GPEParser {
79 80
	private InputStream inputStream = null;
80
	protected XmlPullParser parser = null;
81
	private XmlPullParser parser = null;
81 82
	
82 83
	public GPEXmlParser() {
83 84
		super();		
......
143 144
	protected abstract void initParse();
144 145
	
145 146
	/**
146
	 * @return Returns the encoding.
147
	 * @return Returns the encoding or UTF-8 encoding by default.
147 148
	 * @throws IOException 
148 149
	 * @throws KmlException 
149 150
	 */
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/GPEGmlParser.java
1 1
package org.gvsig.gpe.gml;
2

  
3 2
import java.io.File;
4 3
import java.io.FileInputStream;
5 4
import java.io.FileNotFoundException;
6 5
import java.io.IOException;
7 6
import java.io.InputStream;
7
import java.net.ConnectException;
8
import java.net.MalformedURLException;
9
import java.net.URL;
10
import java.net.UnknownHostException;
11
import java.util.StringTokenizer;
8 12

  
9
import org.gvsig.gpe.GPEContentHandler;
10
import org.gvsig.gpe.GPEErrorHandler;
13
import org.gvsig.exceptions.BaseException;
14
import org.gvsig.gpe.gml.factories.XMLSchemasFactory;
15
import org.gvsig.gpe.gml.utils.Utilities;
11 16
import org.gvsig.gpe.gml.writer.GPEGmlWriterHandler;
12 17
import org.gvsig.gpe.writers.GPEWriterHandler;
13 18
import org.gvsig.gpe.xml.GPEXmlParser;
19
import org.xml.sax.SAXException;
20
import org.xmlpull.v1.XmlPullParser;
14 21
import org.xmlpull.v1.XmlPullParserException;
15 22

  
23
import com.sun.xml.xsom.parser.XSOMParser;
24

  
16 25
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17 26
 *
18 27
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
57 66
 *
58 67
 * $Id$
59 68
 * $Log$
60
 * Revision 1.3  2007-04-18 12:57:13  csanchez
69
 * Revision 1.4  2007-04-19 11:51:43  csanchez
61 70
 * Actualizacion protoripo libGPE
62 71
 *
63
 * Revision 1.2  2007/04/18 12:54:45  csanchez
72
 * Revision 1.1  2007/04/18 12:54:45  csanchez
64 73
 * Actualizacion protoripo libGPE
65 74
 *
66
 * Revision 1.1  2007/04/14 16:07:30  jorpiell
67
 * The writer has been created
68 75
 *
69
 *
70 76
 */
71 77
/**
72
 * Esta clase ha sido creada solo por necesidad. Debe
73
 * ser sustituida por la de Carlos
74
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
78
 * @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
75 79
 */
76
public class GPEGmlParser extends GPEXmlParser {
80
public class GPEGmlParser extends GPEXmlParser{
77 81

  
78
	public GPEGmlParser(GPEContentHandler contents, GPEErrorHandler errors) {
79
		super(contents, errors);
82
	private XSOMParser schemaParser = null;
83
	private XmlPullParser fileParser = null;
84
	private String mainTag = null;
85
	private File mainFile = null;
86
	private File schemaFile = null;
87
	private int no_schema = 1;
88
	
89
	public GPEGmlParser() {
90
		//First, it gets the file parser.
91
		fileParser = getParser();
92
		// TODO Ap?ndice de constructor generado autom?ticamente
80 93
	}
81

  
94
	
82 95
	/*
83 96
	 * (non-Javadoc)
84
	 * @see org.gvsig.gpe.xml.GPEXmlParser#createInputStream(java.io.File)
97
	 * @see org.gvsig.gpe.GPEParser#getFormats()
85 98
	 */
99
	public String[] getFormats() {
100
		String[] formats = new String[2];
101
		formats[0] = "GML";
102
		formats[1] = "XML";
103
		return formats;
104
	}
105

  
106
	public boolean accept(File file) {
107
		this.mainFile = file;
108
		if ((file.getName().toUpperCase().endsWith("GML"))
109
				|| (file.getName().toUpperCase().endsWith("XML"))) {
110
			return true;
111
		}
112
		return false;
113
	}
114

  
86 115
	protected InputStream createInputStream(File file) throws FileNotFoundException {
116
		// TODO Ap?ndice de m?todo generado autom?ticamente
87 117
		return new FileInputStream(file);
88 118
	}
89

  
119
	/** 
120
	 * 
121
	 * AQUI SE IMPLEMENTA LA BASE PARA PODER PARSEAR CUALQUIER FICHERO GML:
122
	 * -PARTIMOS DE QUE TENEMOS EL FICHERO ABIERTO EN MODO LECTURA Y UN FILE PARSER
123
	 * -
124
	 * -ABRIR EN MODO LECTURA CON LA CODIFICACI?N CORRECTA
125
	 * -CREAR EL PARSER DE XML ?"XSOM"?
126
	 * -DETECTAR FORMATO FICHERO Y VERSI?N ?"EST? REGISTRADO"?
127
	 * -SI EXISTE, LLAMADA AL PARSER DEL FORMATO CONCRETO
128
	 *
129
	 **/
130
	protected void initParse() {
131
		//First of all it has to parse the head 
132
		parseHead();
133
	}
90 134
	/*
91 135
	 * (non-Javadoc)
92
	 * @see org.gvsig.gpe.xml.GPEXmlParser#initParse()
136
	 * @see org.gvsig.gpe.GPEParser#getWriter(java.lang.String)
93 137
	 */
94
	protected void initParse() {
138
	public GPEWriterHandler getWriter(String format) {
139
		return new GPEGmlWriterHandler();
140
	}
141

  
142
	public String[] getVersions() {
143
		// TODO Ap?ndice de m?todo generado autom?ticamente
144
		return null;
145
	}
146
	private void parseHead(){
147
		//nextTag() --> Method from KXML library to get next full tag
95 148
		try {
96
			parser.next();
149
			fileParser.nextTag();
97 150
		} catch (XmlPullParserException e) {
98 151
			// TODO Bloque catch generado autom?ticamente
99
			e.printStackTrace();
152
			System.out.println("Error en XmlPullParser al intentar obtener la siguiente etiqueta: "+e.getMessage());
153
			
100 154
		} catch (IOException e) {
101 155
			// TODO Bloque catch generado autom?ticamente
102
			e.printStackTrace();
156
			System.out.println("Error al leer la siguiente etiqueta en XmlPullParser: "+e.getMessage());
157
			
103 158
		}
104
			// TODO Auto-generated method stub
159
		//It keeps the name of the start tag to compare with the close tag later
160
		mainTag = fileParser.getName();
161
		//If it has namespace before the ":" we keep the maintag without namespace 
162
		int pos = mainTag.indexOf(":");
163
		if (pos > 0){
164
			mainTag = mainTag.substring(mainTag.indexOf(":") + 1,mainTag.length());
165
		}
166
		//It start to get all the attributes and values from the header tag
167
		for (int i = 0 ; i < fileParser.getAttributeCount() ; i++){
168
			String attName = fileParser.getAttributeName(i);
169
			String attValue = fileParser.getAttributeValue(i);
170
			
171
						
172
			//it splits the attributes names at the both sides from ":"
173
			String[] ns = attName.split(":");
174
			
175
			//If it founds the 'xmlns' is a new namespace declaration and it has to parse it
176
			if ((ns.length>1) && (ns[0].compareTo(GMLTags.XML_NAMESPACE)==0)){
177
				parseNameSpace(ns[1],attValue);
178
			}
179
			
180
			//If its the "SCHEMA LOCATION" attribute, it means that there are schema and it tries to parse it
181
			if ((ns.length>1) && (ns[1].compareTo(GMLTags.XML_SCHEMA_LOCATION)==0)){
182
				no_schema=0;
183
				parseSchemaLocation(ns[0],attValue);
184
			}
185
		}
186
		if (no_schema==1){
187
			//Alert that th GML File hasn't schema but it tries to parse
188
			//warnings.setElement(new GMLWarningNoSchema());
189
		}
105 190
	}
106

  
107
	/*
108
	 * (non-Javadoc)
109
	 * @see org.gvsig.gpe.GPEParser#accept(java.io.File)
191
	/**
192
	 * It downloads the schema's file and parse it
193
	 * @param xmlnsName : Alias
194
	 * @param xmlnsValue: URI 
110 195
	 */
111
	public boolean accept(File file) {
112
		if ((file.getName().toUpperCase().endsWith("GML"))
113
				|| (file.getName().toUpperCase().endsWith("XML"))) {
114
			return true;
115
		}
116
		return false;
196
	private void parseSchemaLocation(String schemaAlias, String schemaURI){
197
		//It take the name of the schemas file to open or downlad 
198
		StringTokenizer tokenizer = new StringTokenizer(schemaURI, " \t");
199
        while (tokenizer.hasMoreTokens()){
200
            String URI = tokenizer.nextToken();
201
            if (!tokenizer.hasMoreTokens()){
202
            		//If it hasn't the name of the schemas file or dont find it,
203
            		//it exits, and tries to parse without schema
204
            		//warnings.setElement(new GMLWarningNotFound(null,null));
205
            		System.out.println("Error, esquema no encontrado.PARSEO SIN ESQUEMA ");
206
    			
207
            }
208
            else
209
            {
210
            		String schemaLocation = tokenizer.nextToken();
211
            		//It add the schemaLocation to the hashtable
212
            		try {
213
					XMLSchemasFactory.addSchemaLocation(schemaAlias,URI,schemaLocation);
214
				} 
215
				catch (BaseException e) {
216
					// TODO Auto-generated catch block
217
					//warnings.setElement(new GMLWarningMalformed());
218
					System.out.println("Error al a?adir el esquema o esquema mal formado: "+e.getMessage());
219
				}
220
				//It downloads the schema if it's a remote schema
221
				schemaFile = getSchemaFile(schemaLocation);
222
            		//It parses the schema.
223
				schemaParser = new XSOMParser();
224
				try {
225
					schemaParser.parse(schemaFile);
226
				} catch (SAXException e) {
227
					// TODO Bloque catch generado autom?ticamente
228
					System.out.println("Error al parsear el Schema: "+e.getMessage());
229
				} catch (IOException e) {
230
					// TODO Bloque catch generado autom?ticamente
231
					System.out.println("Error de lectura/escritura del esquema: "+e.getMessage());
232
				}
233
            }
234
        }
117 235
	}
118

  
119
	/*
120
	 * (non-Javadoc)
121
	 * @see org.gvsig.gpe.GPEParser#getFormats()
236
	/**
237
	 * It adds an XML namespace tag to the hashtable
238
	 * @param xmlnsName : Namespace
239
	 * @param xmlnsValue: URI 
122 240
	 */
123
	public String[] getFormats() {
124
		String[] formats = new String[2];
125
		formats[0] = "GML";
126
		formats[1] = "XML";
127
		return formats;
241
	private void parseNameSpace(String xmlnsName,String xmlnsValue){
242
		XMLSchemasFactory.addType(xmlnsName,xmlnsValue);		
128 243
	}
129

  
130
	/*
131
	 * (non-Javadoc)
132
	 * @see org.gvsig.gpe.GPEParser#getWriter(java.lang.String)
244
	/**
245
	 * It downloads the schema if it's a remote schema
246
	 * else it tries to open a local file and return if it's succesfull
247
	 * @param String : schemaLocation
133 248
	 */
134
	public GPEWriterHandler getWriter(String format) {
135
		return new GPEGmlWriterHandler(format, getErrorHandler());
249
	private File getSchemaFile(String schemaLocation){
250
		File f = null;
251
		
252
		//If it is a local file, it has to construct the absolute route
253
		if (schemaLocation.indexOf("http://") != 0){
254
			f = new File(schemaLocation);
255
			if (!(f.isAbsolute())){
256
				schemaLocation = mainFile.getParentFile().getAbsolutePath() + File.separator +  schemaLocation;
257
				f = new File(schemaLocation);
258
			}
259
			return f;
260
		}
261
		//Else it is an URL direction and it has to download it.
262
		else {
263
			URL url;
264
		
265
			try {
266
				url = new URL(schemaLocation);
267
				//Download the schema without cancel option.
268
				f = Utilities.downloadFile(url,"gml_schmema.xsd");				
269
			} catch (MalformedURLException e) {
270
				// TODO Bloque catch generado autom?ticamente
271
				System.out.println("Error, URL del esquema mal formada: "+e.getMessage());
272
			} catch (ConnectException e) {
273
				// TODO Bloque catch generado autom?ticamente
274
				System.out.println("Error al descargar esquema, Imposible conectar: "+e.getMessage());
275
			} catch (UnknownHostException e) {
276
				// TODO Bloque catch generado autom?ticamente
277
				System.out.println("Error al descargar esquema, Host desconocido: "+e.getMessage());
278
			} catch (IOException e) {
279
				// TODO Bloque catch generado autom?ticamente
280
				System.out.println("Erroral descargar esquema, Fallo de lectura/escritura: "+e.getMessage());
281
			}
282
			return f;	
283
		}
136 284
	}
137

  
138 285
}

Also available in: Unified diff