Revision 939

View differences:

org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.spi/src/main/java/org/gvsig/xmlpull/lib/spi/XmlPullProviderManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.spi;
29

  
30
import java.io.InputStream;
31
import java.io.OutputStream;
32

  
33
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader;
34
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReaderFactory;
35
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriter;
36
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriterFactory;
37
import org.gvsig.xmlpull.lib.api.stream.XmlStreamException;
38

  
39

  
40

  
41
/**
42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
43
 */
44
public interface XmlPullProviderManager {
45
	
46
	public void registerXMLStreamReaderFactory(IXmlStreamReaderFactory xmlStreamReaderFactory);
47
		
48
	public void registerXMLStreamWriterFactory(IXmlStreamWriterFactory xmlStreamWriterFactory);
49
	
50
	public IXmlStreamReader createStreamReader(String mimeType, InputStream is) throws XmlStreamException, IllegalArgumentException;
51
	
52
	public IXmlStreamWriter createStreamWriter(String mimeType, OutputStream os) throws XmlStreamException, IllegalArgumentException;
53
}
54

  
0 55

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.spi/src/main/java/org/gvsig/xmlpull/lib/spi/XmlPullProviderLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.spi;
29

  
30
import org.gvsig.tools.locator.AbstractLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

  
34
/**
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class XmlPullProviderLocator extends AbstractLocator {
38
	private static final String LOCATOR_NAME = "XMLProviderLocator";
39
	/**
40
	 * XMLManager name used by the locator to access the instance
41
	 */
42
	public static final String XML_PROVIDER_MANAGER_NAME = "XMLProviderManager";
43
	private static final String XML_PROVIDER_MANAGER_DESCRIPTION = "XMLProviderManager of gvSIG";
44
	
45
	/**
46
	 * Unique instance.
47
	 */
48
	private static final XmlPullProviderLocator instance = new XmlPullProviderLocator();
49
	
50
	/* (non-Javadoc)
51
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
52
	 */
53
	public String getLocatorName() {
54
		return LOCATOR_NAME;
55
	}
56
	
57
	/**
58
	 * Return a reference to {@link XmlPullProviderManager}.
59
	 *
60
	 * @return a reference to XMLProviderManager
61
	 * @throws LocatorException
62
	 *             if there is no access to the class or the class cannot be
63
	 *             instantiated
64
	 * @see Locator#get(String)
65
	 */
66
	public static XmlPullProviderManager getXMLProviderManager() throws LocatorException {
67
		return (XmlPullProviderManager) getInstance().get(XML_PROVIDER_MANAGER_NAME);
68
	}
69
	
70
	/**
71
	 * Return the singleton instance.
72
	 *
73
	 * @return the singleton instance
74
	 */
75
	public static XmlPullProviderLocator getInstance() {
76
		return instance;
77
	}
78
	
79
	/**
80
	 * Registers the Class implementing the {@link XmlPullProviderManager} interface.
81
	 *
82
	 * @param clazz
83
	 *            implementing the XMLProviderManager interface
84
	 */
85
	public static void registerXMLProviderManager(Class clazz) {
86
		getInstance().register(XML_PROVIDER_MANAGER_NAME, 
87
				XML_PROVIDER_MANAGER_DESCRIPTION,
88
				clazz);
89
	}	
90
}
91

  
92

  
93

  
0 94

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.spi/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.xmlpull.lib.spi</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.xmlpull.lib.spi</name>
8
	<description>XML Pull library SPI</description>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.xmlpull.lib</artifactId>
12
		<version>2.0.11</version>				
13
	</parent>
14
	<dependencies>
15
		<dependency>
16
			<groupId>org.gvsig</groupId>
17
			<artifactId>org.gvsig.xmlpull.lib.api</artifactId>			
18
		</dependency>
19
		<dependency>
20
      		<groupId>org.gvsig</groupId>
21
      		<artifactId>org.gvsig.tools.lib</artifactId>
22
    	</dependency>
23
    	<dependency>
24
      		<groupId>org.gvsig</groupId>
25
      		<artifactId>org.gvsig.tools.lib</artifactId>
26
      		<type>test-jar</type>
27
    	</dependency>  
28
	</dependencies>
29
	<build>
30
		<plugins>
31
			<plugin>
32
				<groupId>org.apache.maven.plugins</groupId>
33
				<artifactId>maven-compiler-plugin</artifactId>
34
				<configuration>
35
					<source>1.4</source>
36
					<target>1.5</target>
37
				</configuration>
38
			</plugin>
39
		</plugins>
40
	</build>
41
	<profiles>
42
		<profile>
43
			<id>cdc</id>
44
			<build>
45
				<plugins>
46
					<plugin>
47
						<groupId>org.apache.maven.plugins</groupId>
48
						<artifactId>maven-compiler-plugin</artifactId>
49
						<configuration>
50
							<source>1.4</source>
51
							<target>1.4</target>
52
						</configuration>
53
					</plugin>
54
				</plugins>
55
			</build>
56
		</profile>
57
	</profiles>
58
</project>
0 59

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.xmlpull.lib.impl.DefaultXmlPullLibrary
2

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/src/main/java/org/gvsig/xmlpull/lib/impl/CreateXmlStreamReaderException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {gvSIG}  {{Task}}
26
 */
27
package org.gvsig.xmlpull.lib.impl;
28

  
29
import org.gvsig.tools.exception.BaseRuntimeException;
30
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader;
31

  
32
/**
33
 * Exception thrown when there is an error creating a new {@link IXmlStreamReader}.
34
 * 
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class CreateXmlStreamReaderException extends
38
	BaseRuntimeException {
39
	private static final long serialVersionUID = -8220667598288924597L;
40

  
41
	private final static String MESSAGE_FORMAT = "Exception creating the xml stream reader with " +
42
			"mimeType '%(mimeType)'.";
43
	private final static String MESSAGE_KEY = "_CreateXMLStreamReaderException";
44
	
45
	public CreateXmlStreamReaderException(String mimeType, Throwable cause){
46
		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
47
		setValue("mimeType", mimeType);
48
	}
49
}
0 50

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/src/main/java/org/gvsig/xmlpull/lib/impl/DefaultXmlPullLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.impl;
29

  
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.xmlpull.lib.api.XmlPullLibrary;
33
import org.gvsig.xmlpull.lib.api.XmlPullLocator;
34
import org.gvsig.xmlpull.lib.spi.XmlPullProviderLocator;
35

  
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
38
 */
39
public class DefaultXmlPullLibrary extends AbstractLibrary {
40
	
41
	public void doRegistration() {
42
		registerAsImplementationOf(XmlPullLibrary.class);
43
	}
44

  
45
	protected void doInitialize() throws LibraryException {       
46
        XmlPullLocator.registerXMLManager(DefaultXmlPullManager.class);
47
        XmlPullProviderLocator.registerXMLProviderManager(DefaultXmlPullProviderManager.class);
48
	}
49

  
50
	protected void doPostInitialize() throws LibraryException {
51
		// Nothing to do
52
	}
53
}
0 54

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/src/main/java/org/gvsig/xmlpull/lib/impl/DefaultXmlPullProviderManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.impl;
29

  
30
import java.io.InputStream;
31
import java.io.OutputStream;
32
import java.util.ArrayList;
33
import java.util.Collections;
34
import java.util.Iterator;
35
import java.util.List;
36

  
37
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader;
38
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReaderFactory;
39
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriter;
40
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriterFactory;
41
import org.gvsig.xmlpull.lib.api.stream.XmlStreamException;
42
import org.gvsig.xmlpull.lib.spi.XmlPullProviderManager;
43

  
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
46
 */
47
public class DefaultXmlPullProviderManager implements XmlPullProviderManager{
48
	private List xmlStreamReaderFactories = Collections.synchronizedList(new ArrayList());
49
	private List xmlStreamWriterFactories = Collections.synchronizedList(new ArrayList());
50
	
51
	public IXmlStreamReader createStreamReader(String mimeType, InputStream is){
52
		Iterator it = xmlStreamReaderFactories.iterator();
53
		while (it.hasNext()){
54
			IXmlStreamReaderFactory xmlStreamReaderFactory = 
55
				(IXmlStreamReaderFactory)it.next();
56
			if (xmlStreamReaderFactory.canParse(mimeType)){
57
				try {
58
					return xmlStreamReaderFactory.createParser(mimeType, is);
59
				} catch (Exception e) {
60
					throw new CreateXmlStreamReaderException(mimeType, e);
61
				}
62
			}
63
		}		
64
		throw new IllegalArgumentException("There is not a " +
65
				"XMLStreamReader for the mimetype " + mimeType);
66
		
67
	}
68
	
69
	public void registerXMLStreamReaderFactory(IXmlStreamReaderFactory xmlStreamReaderFactory)  {
70
		xmlStreamReaderFactories.add(xmlStreamReaderFactory);		
71
	}
72

  
73
	public IXmlStreamWriter createStreamWriter(String mimeType, OutputStream os)
74
			throws XmlStreamException, IllegalArgumentException {
75
		Iterator it = xmlStreamWriterFactories.iterator();
76
		while (it.hasNext()){
77
			IXmlStreamWriterFactory xmlStreamWriterFactory = 
78
				(IXmlStreamWriterFactory)it.next();
79
			if (xmlStreamWriterFactory.canWrite(mimeType)){
80
				try {
81
					return xmlStreamWriterFactory.createWriter(mimeType, os);
82
				} catch (Exception e) {
83
					throw new CreateXmlStreamWriterException(mimeType, e);
84
				}
85
			}
86
		}		
87
		throw new IllegalArgumentException("There is not a " +
88
				"XMLStreamWriter for the mimetype " + mimeType);
89
	}
90

  
91
	public void registerXMLStreamWriterFactory(
92
			IXmlStreamWriterFactory xmlStreamWriterFactory) {
93
		xmlStreamWriterFactories.add(xmlStreamWriterFactory);			
94
	}
95

  
96

  
97
}
98

  
0 99

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/src/main/java/org/gvsig/xmlpull/lib/impl/CreateXmlStreamWriterException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {gvSIG}  {{Task}}
26
 */
27
package org.gvsig.xmlpull.lib.impl;
28

  
29
import org.gvsig.tools.exception.BaseRuntimeException;
30
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader;
31

  
32
/**
33
 * Exception thrown when there is an error creating a new {@link IXmlStreamReader}.
34
 * 
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class CreateXmlStreamWriterException extends
38
	BaseRuntimeException {
39
	private static final long serialVersionUID = 6894668637124114583L;
40
	
41
	private final static String MESSAGE_FORMAT = "Exception creating the xml stream writer with " +
42
			"mimeType '%(mimeType)'.";
43
	private final static String MESSAGE_KEY = "_CreateXMLStreamReaderException";
44
	
45
	public CreateXmlStreamWriterException(String mimeType, Throwable cause){
46
		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
47
		setValue("mimeType", mimeType);
48
	}
49
}
0 50

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/src/main/java/org/gvsig/xmlpull/lib/impl/DefaultXmlPullManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.impl;
29

  
30
import java.io.InputStream;
31
import java.io.OutputStream;
32

  
33
import org.gvsig.xmlpull.lib.api.XmlPullManager;
34
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader;
35
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriter;
36
import org.gvsig.xmlpull.lib.api.stream.XmlStreamException;
37
import org.gvsig.xmlpull.lib.spi.XmlPullProviderLocator;
38
import org.gvsig.xmlpull.lib.spi.XmlPullProviderManager;
39

  
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42
 */
43
public class DefaultXmlPullManager implements XmlPullManager{
44
	private XmlPullProviderManager xmlPullProviderManager = null;
45

  
46
	private XmlPullProviderManager getXmlPullProviderManager() {
47
		if (xmlPullProviderManager == null){
48
			xmlPullProviderManager = XmlPullProviderLocator.getXMLProviderManager();
49
		}
50
		return xmlPullProviderManager;
51
	}
52

  
53
	public IXmlStreamReader createStreamReader(String mimeType, InputStream is)
54
			throws XmlStreamException, IllegalArgumentException {
55
		return getXmlPullProviderManager().createStreamReader(mimeType, is);
56
	}
57

  
58
	public IXmlStreamWriter createStreamWriter(String mimeType, OutputStream os)
59
			throws XmlStreamException, IllegalArgumentException {
60
		return getXmlPullProviderManager().createStreamWriter(mimeType, os);
61
	}
62
	
63
}
64

  
0 65

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.impl/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.xmlpull.lib.impl</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.xmlpull.lib.impl</name>
8
	<description>Default XML Pull library Implementation</description>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.xmlpull.lib</artifactId>	
12
		<version>2.0.11</version>			
13
	</parent>
14
	<dependencies>
15
	
16
		<dependency>
17
      		<groupId>org.gvsig</groupId>
18
      		<artifactId>org.gvsig.tools.lib</artifactId>
19
    	</dependency>
20
    	<dependency>
21
      		<groupId>org.gvsig</groupId>
22
      		<artifactId>org.gvsig.tools.lib</artifactId>
23
      		<type>test-jar</type>
24
    	</dependency>  
25

  
26
		<dependency>
27
			<groupId>org.gvsig</groupId>
28
			<artifactId>org.gvsig.xmlpull.lib.api</artifactId>	
29
		</dependency>
30
		<dependency>
31
			<groupId>org.gvsig</groupId>
32
			<artifactId>org.gvsig.xmlpull.lib.spi</artifactId>			
33
		</dependency>
34
	</dependencies>
35
	<build>
36
		<plugins>
37
			<plugin>
38
				<groupId>org.apache.maven.plugins</groupId>
39
				<artifactId>maven-compiler-plugin</artifactId>
40
				<configuration>
41
					<source>1.4</source>
42
					<target>1.5</target>
43
				</configuration>
44
			</plugin>
45
		</plugins>
46
	</build>
47
	<profiles>
48
		<profile>
49
			<id>cdc</id>
50
			<build>
51
				<plugins>
52
					<plugin>
53
						<groupId>org.apache.maven.plugins</groupId>
54
						<artifactId>maven-compiler-plugin</artifactId>
55
						<configuration>
56
							<source>1.4</source>
57
							<target>1.4</target>
58
						</configuration>
59
					</plugin>
60
				</plugins>
61
			</build>
62
		</profile>
63
	</profiles>
64
</project>
0 65

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.xmlpull.lib</artifactId>
6
	<packaging>pom</packaging>	
7
	<name>org.gvsig.xmlpull.lib</name>
8
	<description>XML Pull library</description>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.xmlpull</artifactId>	
12
		<version>2.0.11</version>	
13
	</parent>
14
	<modules>
15
		<module>org.gvsig.xmlpull.lib.api</module>
16
		<module>org.gvsig.xmlpull.lib.spi</module>
17
		<module>org.gvsig.xmlpull.lib.impl</module>
18
	</modules>
19
</project>
0 20

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.xmlpull.lib.api.XmlPullLibrary
2

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/XmlPullLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.api;
29

  
30
import org.gvsig.tools.locator.AbstractLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

  
34
/**
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class XmlPullLocator extends AbstractLocator {
38
	private static final String LOCATOR_NAME = "XMLLocator";
39
	/**
40
	 * XMLManager name used by the locator to access the instance
41
	 */
42
	public static final String XML_MANAGER_NAME = "XMLManager";
43
	private static final String XML_MANAGER_DESCRIPTION = "XMLManager of gvSIG";
44
	
45
	/**
46
	 * Unique instance.
47
	 */
48
	private static final XmlPullLocator instance = new XmlPullLocator();
49
	
50
	/* (non-Javadoc)
51
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
52
	 */
53
	public String getLocatorName() {
54
		return LOCATOR_NAME;
55
	}
56
	
57
	/**
58
	 * Return a reference to {@link XmlPullManager}.
59
	 *
60
	 * @return a reference to XMLManager
61
	 * @throws LocatorException
62
	 *             if there is no access to the class or the class cannot be
63
	 *             instantiated
64
	 * @see Locator#get(String)
65
	 */
66
	public static XmlPullManager getXMLManager() throws LocatorException {
67
		return (XmlPullManager) getInstance().get(XML_MANAGER_NAME);
68
	}
69
	
70
	/**
71
	 * Return the singleton instance.
72
	 *
73
	 * @return the singleton instance
74
	 */
75
	public static XmlPullLocator getInstance() {
76
		return instance;
77
	}
78
	
79
	/**
80
	 * Registers the Class implementing the {@link XmlPullManager} interface.
81
	 *
82
	 * @param clazz
83
	 *            implementing the XMLManager interface
84
	 */
85
	public static void registerXMLManager(Class clazz) {
86
		getInstance().register(XML_MANAGER_NAME, 
87
				XML_MANAGER_DESCRIPTION,
88
				clazz);
89
	}	
90
}
91

  
92

  
93

  
0 94

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/XmlPullLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.api;
29

  
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32

  
33
/**
34
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
35
 */
36
public class XmlPullLibrary extends AbstractLibrary  {
37
	
38
	public void doRegistration() {
39
		registerAsAPI(XmlPullLibrary.class);
40
	}
41

  
42
	protected void doInitialize() throws LibraryException {
43
		// Nothing to do 
44
	}
45

  
46
	protected void doPostInitialize() throws LibraryException {
47
		// Nothing to do		
48
	}
49
}
50

  
0 51

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/XmlPullManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.xmlpull.lib.api;
29

  
30
import java.io.InputStream;
31
import java.io.OutputStream;
32

  
33
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader;
34
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamWriter;
35
import org.gvsig.xmlpull.lib.api.stream.XmlStreamException;
36

  
37
/**
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
39
 */
40
public interface XmlPullManager {
41

  
42
	public IXmlStreamReader createStreamReader(String mimeType, InputStream is) throws XmlStreamException, IllegalArgumentException;
43
	
44
	public IXmlStreamWriter createStreamWriter(String mimeType, OutputStream os) throws XmlStreamException, IllegalArgumentException;
45

  
46
}
47

  
0 48

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/stream/EventType.java
1
/* gvSIG. Sistem a de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 9638 62 495
28
 *      gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 */
31
package org.gvsig.xmlpull.lib.api.stream;
32

  
33

  
34
/**
35
 * The EventType enum defines the possible parse events a {@link IXmlStreamReader} may return during
36
 * each call to {@code next()}.
37
 * <p>
38
 * These are high level events and may not map one to one to the low level Binary XML format tokens.
39
 * This is so to better reflect the problem domain for this high level API, letting the low level
40
 * treatment of specific bxml tokens to the implementation criteria.
41
 * </p>
42
 * <p>
43
 * In general lines, it could be said that the following EventType to TokenType mappings are
44
 * defined: <table>
45
 * <tr>
46
 * <th>EventType</th>
47
 * <th>TokenType</th>
48
 * </tr>
49
 * <tr>
50
 * <td>NONE</td>
51
 * <td>Header</td>
52
 * </tr>
53
 * <tr>
54
 * <td>START_DOCUMENT</td>
55
 * <td>XmlDeclaration, if present, forced otherwise in order to always return a START_DOCUMENT
56
 * event</td>
57
 * </tr>
58
 * <tr>
59
 * <td>END_DOCUMENT</td>
60
 * <td>Trailer</td>
61
 * </tr>
62
 * <tr>
63
 * <td>START_ELEMENT</td>
64
 * <td>EmptyElement, EmptyAttrElement, ContentElement, ContentAttrElement</td>
65
 * </tr>
66
 * <tr>
67
 * <td>END_ELEMENT</td>
68
 * <td>ElementEnd, or forced when EmptyElement or EmptyAttrElement</td>
69
 * </tr>
70
 * <tr>
71
 * <td>ATTRIBUTE</td>
72
 * <td>AttributeStart, only used for writing</td>
73
 * </tr>
74
 * <tr>
75
 * <td>ATTRIBUTES_END</td>
76
 * <td>AttributeListEnd, only used for writing</td>
77
 * </tr>
78
 * <tr>
79
 * <td>COMMENT</td>
80
 * <td>Comment</td>
81
 * </tr>
82
 * <tr>
83
 * <td>SPACE</td>
84
 * <td>WhiteSpace</td>
85
 * </tr>
86
 * <tr>
87
 * <td>VALUE_STRING, VALUE_BOOL, VALUE_BYTE, VALUE_INT, VALUE_LONG, VALUE_FLOAT, VALUE_DOUBLE</td>
88
 * <td>CharContent token, followed by the specific value type</td>
89
 * </tr>
90
 * </table>
91
 * </p>
92
 * 
93
 * @author Gabriel Roldan (TOPP)
94
 * @version $Id: EventType.java 21945 2008-06-30 14:04:53Z jpiera $
95
 * @since 1.0
96
 */
97
public final class EventType {
98

  
99
    private boolean isValueEvent;
100

  
101
    private int code;
102

  
103
    /**
104
     * Private default constructor inforces the use of this class by its public static members only
105
     */
106
    private EventType(final int code) {
107
        this(code, false);
108
    }
109

  
110
    private EventType(final int code, boolean isValue) {
111
        this.code = code;
112
        this.isValueEvent = isValue;
113
    }
114

  
115
    public static final int NONE_CODE = 0;
116

  
117
    /**
118
     * Null object to indicate either a document has not started being parsed yet, or a document has
119
     * not started being written yet.
120
     */
121
    public static final EventType NONE = new EventType(NONE_CODE);
122

  
123
    public static final int START_DOCUMENT_CODE = 1;
124
    /**
125
     * Indicates the parser is positioned at the start of the document. The next call to
126
     * {@link IXmlStreamReader#next()} shall return either {@link #START_ELEMENT}, {@link #COMMENT}
127
     * or {@link #END_DOCUMENT} if the document is empty.
128
     */
129
    public static final EventType START_DOCUMENT = new EventType(START_DOCUMENT_CODE);
130

  
131
    public static final int END_DOCUMENT_CODE = 2;
132

  
133
    /**
134
     * Indicates the parser has reached the end of the bxml document
135
     */
136
    public static final EventType END_DOCUMENT = new EventType(END_DOCUMENT_CODE);
137

  
138
    public static final int START_ELEMENT_CODE = 3;
139

  
140
    /**
141
     * Signals the opening of an element tag.
142
     */
143
    public static final EventType START_ELEMENT = new EventType(START_ELEMENT_CODE);
144

  
145
    public static final int END_ELEMENT_CODE = 4;
146

  
147
    /**
148
     * Signals the end of the current element. No content elements such as {@code <element/>} and
149
     * {@code <element att="attval"/>} will be notified by an START_ELEMENT and END_ELEMENT event
150
     * with no value event in between, to preserve semantic equivalence with the
151
     * {@code <element></element>} tag sequence.
152
     */
153
    public static final EventType END_ELEMENT = new EventType(END_ELEMENT_CODE);
154

  
155
    public static final int VALUE_BOOL_CODE = 5;
156

  
157
    /**
158
     * Content event that indicates the parser is at a value token whose content is either a Java
159
     * boolean or an array of booleans.
160
     */
161
    public static final EventType VALUE_BOOL = new EventType(VALUE_BOOL_CODE, true);
162

  
163
    public static final int VALUE_BYTE_CODE = 6;
164

  
165
    /**
166
     * Content event that indicates the parser is at a value token whose content is either a Java
167
     * byte or an array of bytes.
168
     */
169
    public static final EventType VALUE_BYTE = new EventType(VALUE_BYTE_CODE, true);
170

  
171
    public static final int VALUE_INT_CODE = 7;
172

  
173
    /**
174
     * Content event that indicates the parser is at a value token whose content is either a Java
175
     * integer or an array of integers. For the sake of simplicity, the low level {@code SmallNum},
176
     * {@code Short}, {@code UShort}, and {@code Int} value types are mapped to this event type.
177
     */
178
    public static final EventType VALUE_INT = new EventType(VALUE_INT_CODE, true);
179

  
180
    public static final int VALUE_LONG_CODE = 8;
181

  
182
    /**
183
     * Content event that indicates the parser is at a value token whose content is either a Java
184
     * long or an array of longs.
185
     */
186
    public static final EventType VALUE_LONG = new EventType(VALUE_LONG_CODE, true);
187

  
188
    public static final int VALUE_FLOAT_CODE = 9;
189

  
190
    /**
191
     * Content event that indicates the parser is at a value token whose content is either a Java
192
     * float or an array of floats.
193
     */
194
    public static final EventType VALUE_FLOAT = new EventType(VALUE_FLOAT_CODE, true);
195

  
196
    public static final int VALUE_DOUBLE_CODE = 10;
197

  
198
    /**
199
     * Content event that indicates the parser is at a value token whose content is either a Java
200
     * double or an array of double.
201
     */
202
    public static final EventType VALUE_DOUBLE = new EventType(VALUE_DOUBLE_CODE, true);
203

  
204
    public static final int VALUE_STRING_CODE = 11;
205
    /**
206
     * Content event that indicates the parser is at a value token whose content is a Java String.
207
     * There are no such a structure as an array of Strings in the BXML spec.
208
     */
209
    public static final EventType VALUE_STRING = new EventType(VALUE_STRING_CODE, true);
210

  
211
    public static final int VALUE_CDATA_CODE = 12;
212

  
213
    /**
214
     * This is event equivalent to the {@code "<![CDATA[content]]>"} structure in textual XML,
215
     * signaled by the CDataSectionToken. This token is essentially equivalent to the
216
     * CharContentToken, except that its use may be regarded as a hint to a translator to regenerate
217
     * a CDATA section in textual XML.
218
     */
219
    public static final EventType VALUE_CDATA = new EventType(VALUE_CDATA_CODE, true);
220

  
221
    public static final int VALUE_SPACE_CODE = 13;
222

  
223
    /**
224
     * Content event that signals the precense of a WhiteSpace token. That is, a potentially
225
     * insignificant sequence of white space or newline characters
226
     */
227
    public static final EventType SPACE = new EventType(VALUE_SPACE_CODE, true);
228

  
229
    public static final int COMMENT_CODE = 14;
230

  
231
    /**
232
     * Indicates the parser is at a XML comment token
233
     */
234
    public static final EventType COMMENT = new EventType(COMMENT_CODE);
235

  
236
    public static final int ATTRIBUTE_CODE = 15;
237

  
238
    /**
239
     * Used only for writing attributes.
240
     * 
241
     * @see IXmlStreamWriter#writeStartAttribute(String, String)
242
     */
243
    public static final EventType ATTRIBUTE = new EventType(ATTRIBUTE_CODE);
244

  
245
    public static final int ATTRIBUTES_END_CODE = 16;
246

  
247
    /**
248
     * Used only for writing attributes.
249
     * 
250
     * @see IXmlStreamWriter#writeEndAttributes()
251
     */
252
    public static final EventType ATTRIBUTES_END = new EventType(ATTRIBUTES_END_CODE);
253

  
254
    public int getCode() {
255
        return code;
256
    }
257

  
258
    /**
259
     * Convenience method that returns whether this EventType represents a value token
260
     * 
261
     * @return {@code true} if {@code eventType} is one of
262
     *         {@code VALUE_BOOL, VALUE_BYTE, VALUE_INT, VALUE_LONG, VALUE_FLOAT, VALUE_DOUBLE,
263
     *         VALUE_STRING, VALUE_CDATA, SPACE}
264
     */
265
    public boolean isValue() {
266
        return isValueEvent;
267
    }
268

  
269
    /**
270
     * Convenience method that returns whether this EventType represents a tag element
271
     * 
272
     * @return {@code true} if {@code eventType} is one of {@code START_ELEMENT, END_ELEMENT}
273
     */
274
    public boolean isTag() {
275
        return START_ELEMENT == this || END_ELEMENT == this;
276
    }
277
}
0 278

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/stream/AbstractXmlStreamReaderWrapper.java
1
/* gvSIG. Sistem a de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 9638 62 495
28
 *      gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 */
31
package org.gvsig.xmlpull.lib.api.stream;
32

  
33
/**
34
 * Plain wrapper for an {@link IXmlStreamReader} aimed at easying the creation of IXmlStreamReader
35
 * decorators.
36
 * <p>
37
 * This class is a pure abstract wrapper, so all methods delegate to the wrapped object.
38
 * </p>
39
 * 
40
 * @author Gabriel Roldan (TOPP)
41
 * @version $Id: AbstractXmlStreamReaderWrapper.java 20425 2008-05-05 14:24:58Z groldan $
42
 */
43
public abstract class AbstractXmlStreamReaderWrapper implements IXmlStreamReader {
44

  
45
    private IXmlStreamReader wrapped;
46

  
47
    protected AbstractXmlStreamReaderWrapper() {
48
        // do nothing
49
    }
50

  
51
    protected AbstractXmlStreamReaderWrapper(IXmlStreamReader wrapped) {
52
        setWrapped(wrapped);
53
    }
54

  
55
    public void setWrapped(IXmlStreamReader wrapped) {
56
        this.wrapped = wrapped;
57
    }
58
    
59
    /**
60
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#getAttributeCount()
61
     */
62
    public int getAttributeCount() throws XmlStreamException {
63
        return wrapped.getAttributeCount();
64
    }
65

  
66
    /**
67
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#getAttributeName(int)
68
     */
69
    public IQName getAttributeName(int i) throws XmlStreamException {
70
        return wrapped.getAttributeName(i);
71
    }
72

  
73
    /**
74
     * @param i
75
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#getAttributeValue(int)
76
     */
77
    public String getAttributeValue(int i) throws XmlStreamException {
78
        return wrapped.getAttributeValue(i);
79
    }
80

  
81
    /**
82
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#getEventType()
83
     */
84
    public int getEventType() throws XmlStreamException {
85
        return wrapped.getEventType();
86
    }
87

  
88
    /**
89
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#getName()
90
     */
91
    public IQName getName() throws XmlStreamException {
92
        return wrapped.getName();
93
    }
94

  
95
    /**
96
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#getText()
97
     */
98
    public String getText() throws XmlStreamException {
99
        return wrapped.getText();
100
    }
101

  
102
    /**
103
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#isWhitespace()
104
     */
105
    public boolean isWhitespace() throws XmlStreamException {
106
        return wrapped.isWhitespace();
107
    }
108

  
109
    /**
110
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#next()
111
     */
112
    public int next() throws XmlStreamException {
113
        return wrapped.next();
114
    }
115

  
116
    /**
117
     * @see org.gvsig.gpe.xml.stream.IXmlStreamReader#nextTag()
118
     */
119
    public int nextTag() throws XmlStreamException {
120
        return wrapped.nextTag();
121
    }
122

  
123
}
0 124

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.11/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/stream/IXmlStreamReader.java
1
package org.gvsig.xmlpull.lib.api.stream;
2

  
3
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
4
 *
5
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
20
 *
21
 * For more information, contact:
22
 *
23
 *  Generalitat Valenciana
24
 *   Conselleria d'Infraestructures i Transport
25
 *   Av. Blasco Ib??ez, 50
26
 *   46010 VALENCIA
27
 *   SPAIN
28
 *
29
 *      +34 963862235
30
 *   gvsig@gva.es
31
 *      www.gvsig.gva.es
32
 *
33
 *    or
34
 *
35
 *   IVER T.I. S.A
36
 *   Salamanca 50
37
 *   46005 Valencia
38
 *   Spain
39
 *
40
 *   +34 963163400
41
 *   dac@iver.es
42
 */
43
/* CVS MESSAGES:
44
 *
45
 * $Id: IXmlStreamReader.java 19593 2008-03-12 17:23:30Z groldan $
46
 * $Log$
47
 */
48

  
49

  
50

  
51
/**
52
 * Represents an abstraction layer over a concrete XML parsing technology.
53
 * <p>
54
 * This interface provides a pull like approach to parsing xml formatted documents for the libGPE
55
 * library, yet allowing to interchange implementations which can be based, for example, in XML SAX,
56
 * XML Pull, Binary XML, etc.
57
 * </p>
58
 * <p>
59
 * Note at this time this interface contract is made just of the methods from XmlPullParser that
60
 * where already used so far in the libGPE-GML and libGPE-KML modules. The intention is to first
61
 * introduce this abstraction layer and then evolve it as needed to support an intermediate level of
62
 * abstraction between actual xml parsing and {@link IGPEContentHandler}, while keeping the unit
63
 * tests passing all the time. So this is work in progress and expected to change dramatically,
64
 * though ensuring no functional breackages in any time.
65
 * </p>
66
 * 
67
 * @author Gabriel Roldan (TOPP)
68
 * @version $Id: IXmlStreamReader.java 19593 2008-03-12 17:23:30Z groldan $
69
 */
70
public interface IXmlStreamReader {
71

  
72
    /**
73
     * Indicates an event is a start element
74
     */
75
    public static final int START_ELEMENT = 1;
76
    /**
77
     * Indicates an event is an end element
78
     */
79
    public static final int END_ELEMENT = 2;
80
    /**
81
     * Indicates an event is a processing instruction
82
     */
83
    public static final int PROCESSING_INSTRUCTION = 3;
84

  
85
    /**
86
     * Indicates an event is characters
87
     */
88
    public static final int CHARACTERS = 4;
89

  
90
    /**
91
     * Indicates an event is a comment
92
     */
93
    public static final int COMMENT = 5;
94

  
95
    /**
96
     * The characters are white space (see [XML], 2.10 "White Space Handling"). Events are only
97
     * reported as SPACE if they are ignorable white space. Otherwise they are reported as
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff