Revision 1082

View differences:

org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16</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.16/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.16</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.16/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/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.api</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.xmlpull.lib.api</name>
8
	<description>XML Pull library API</description>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.xmlpull.lib</artifactId>
12
		<version>2.0.16</version>		
13
	</parent>
14
	
15
	<dependencies>
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
	</dependencies>
26
	
27
	<build>
28
		<plugins>
29
			<plugin>
30
				<groupId>org.apache.maven.plugins</groupId>
31
				<artifactId>maven-compiler-plugin</artifactId>
32
				<configuration>
33
					<source>1.4</source>
34
					<target>1.5</target>
35
				</configuration>
36
			</plugin>
37
		</plugins>
38
	</build>
39
	<profiles>
40
		<profile>
41
			<id>cdc</id>
42
			<build>
43
				<plugins>
44
					<plugin>
45
						<groupId>org.apache.maven.plugins</groupId>
46
						<artifactId>maven-compiler-plugin</artifactId>
47
						<configuration>
48
							<source>1.4</source>
49
							<target>1.4</target>
50
						</configuration>
51
					</plugin>
52
				</plugins>
53
			</build>
54
		</profile>
55
	</profiles>
56
</project>
0 57

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.16/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.16/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.16/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/stream/IQName.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.stream;
29
/**
30
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
31
 */
32
public interface IQName {
33

  
34
	public String getLocalPart();
35

  
36
	public String getNamespaceURI();
37

  
38
}
39

  
0 40

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

  
3
import java.io.OutputStream;
4

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

  
46
/**
47
 * 
48
 */
49
public interface IXmlStreamWriterFactory {
50

  
51
    boolean canWrite(final String mimeType);
52

  
53
    IXmlStreamWriter createWriter(final String mimeType, final OutputStream out)
54
            throws XmlStreamException, IllegalArgumentException;
55
}
0 56

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.16/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/stream/XmlStreamException.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: XmlStreamException.java 19593 2008-03-12 17:23:30Z groldan $
46
 * $Log$
47
 */
48

  
49
import java.io.IOException;
50

  
51
/**
52
 * Signals either a parsing or io error ocurred while scanning or writing an xml formatted document.
53
 * 
54
 * @author Gabriel Roldan (TOPP)
55
 * @version $Id: XmlStreamException.java 19593 2008-03-12 17:23:30Z groldan $
56
 */
57
public class XmlStreamException extends IOException {
58

  
59
	private static final long serialVersionUID = 2565360995097194850L;
60

  
61
	public XmlStreamException(String message) {
62
        this(message, null);
63
    }
64

  
65
    public XmlStreamException(String message, Throwable cause) {
66
        super(message);
67
        super.initCause(cause);
68
    }
69

  
70
    public XmlStreamException(Throwable cause) {
71
        this(null, cause);
72
    }
73

  
74
}
0 75

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

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

  
6
class StreamUtils {
7

  
8
    private StreamUtils() {
9
        // do nothing
10
    }
11

  
12
    /**
13
     * @param _is
14
     * @return Returns the encoding or UTF-8 encoding by default.
15
     * @throws IOException
16
     */
17
    public static String getEncoding(final InputStream _is) throws IOException {
18
        String encoding = "UTF-8";
19
        int srcCount = 0;
20
        char[] srcBuf = new char[128];
21

  
22
        // read four bytes
23
        int chk = 0;
24
        try {
25
            while (srcCount < 4) {
26
                int i = _is.read();
27
                if (i == -1)
28
                    break;
29
                chk = (chk << 8) | i;
30
                srcBuf[srcCount++] = (char) i;
31
            }
32

  
33
            if (srcCount == 4) {
34
                switch (chk) {
35
                case 0x00000FEFF:
36
                    encoding = "UTF-32BE";
37
                    srcCount = 0;
38
                    break;
39

  
40
                case 0x0FFFE0000:
41
                    encoding = "UTF-32LE";
42
                    srcCount = 0;
43
                    break;
44

  
45
                case 0x03c:
46
                    encoding = "UTF-32BE";
47
                    srcBuf[0] = '<';
48
                    srcCount = 1;
49
                    break;
50

  
51
                case 0x03c000000:
52
                    encoding = "UTF-32LE";
53
                    srcBuf[0] = '<';
54
                    srcCount = 1;
55
                    break;
56

  
57
                case 0x0003c003f:
58
                    encoding = "UTF-16BE";
59
                    srcBuf[0] = '<';
60
                    srcBuf[1] = '?';
61
                    srcCount = 2;
62
                    break;
63

  
64
                case 0x03c003f00:
65
                    encoding = "UTF-16LE";
66
                    srcBuf[0] = '<';
67
                    srcBuf[1] = '?';
68
                    srcCount = 2;
69
                    break;
70

  
71
                case 0x03c3f786d:
72
                    while (true) {
73
                        int i = _is.read();
74
                        if (i == -1)
75
                            break;
76
                        srcBuf[srcCount++] = (char) i;
77
                        if (i == '>') {
78
                            String s = new String(srcBuf, 0, srcCount);
79
                            int i0 = s.indexOf("encoding");
80
                            if (i0 != -1) {
81
                                while (s.charAt(i0) != '"' && s.charAt(i0) != '\'')
82
                                    i0++;
83
                                char deli = s.charAt(i0++);
84
                                int i1 = s.indexOf(deli, i0);
85
                                encoding = s.substring(i0, i1);
86
                            }
87
                            break;
88
                        }
89
                    }
90

  
91
                default:
92
                    if ((chk & 0x0ffff0000) == 0x0FEFF0000) {
93
                        encoding = "UTF-16BE";
94
                        srcBuf[0] = (char) ((srcBuf[2] << 8) | srcBuf[3]);
95
                        srcCount = 1;
96
                    } else if ((chk & 0x0ffff0000) == 0x0fffe0000) {
97
                        encoding = "UTF-16LE";
98
                        srcBuf[0] = (char) ((srcBuf[3] << 8) | srcBuf[2]);
99
                        srcCount = 1;
100
                    } else if ((chk & 0x0ffffff00) == 0x0EFBBBF00) {
101
                        encoding = "UTF-8";
102
                        srcBuf[0] = srcBuf[3];
103
                        srcCount = 1;
104
                    }
105
                }
106
            }
107
        } catch (IOException ex) {
108
            return null;
109
        }
110
        return encoding;
111
    }
112

  
113
}
0 114

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

  
3
import java.io.InputStream;
4

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

  
46
/**
47
 * 
48
 */
49
public interface IXmlStreamReaderFactory {
50

  
51
    boolean canParse(String mimeType);
52

  
53
    IXmlStreamReader createParser(String mimeType, InputStream in) throws XmlStreamException,
54
            IllegalArgumentException;
55
}
0 56

  
org.gvsig.xmlpull/library/tags/org.gvsig.xmlpull-2.0.16/org.gvsig.xmlpull.lib/org.gvsig.xmlpull.lib.api/src/main/java/org/gvsig/xmlpull/lib/api/stream/IXmlStreamWriter.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
import java.io.IOException;
34

  
35
/**
36
 * IXmlStreamWriter defines an "XML push" like streaming API for writing XML documents encoded as
37
 * per the OGC Binary XML Best Practices document.
38
 * <p>
39
 * This interface does not defines setter methods to control encoding behavior such as byte order to
40
 * use or character encoding. A IXmlStreamWriter instance is meant to be already configured with the
41
 * desired encoding options when returned from the {@link BxmlOutputFactory}.
42
 * </p>
43
 * <p>
44
 * Sample usage:
45
 * 
46
 * <pre>
47
 * <code>
48
 * BxmlOutputFactory factory = BxmlFactoryFinder.newOutputFactory();
49
 * IXmlStreamWriter writer = factory.createSerializer(inputStream);
50
 * 
51
 * writer.setSchemaLocation("http://www.example.com", "http://www.example.com/schema.xsd");
52
 * 
53
 * writer.writeStartDocument();
54
 * 
55
 * writer.setPrefix("ex", "http://www.example.com")
56
 * writer.setDefaultNamespace("http://www.anotherexample.com");
57
 * 
58
 * writer.writeStartElement("", "root");
59
 * 
60
 * writer.writeStartElement("http://www.example.com", "child");
61
 * 
62
 * //child attributes list...
63
 * writer.writeStartAttribute("http://www.example.com", "att");
64
 * writer.writeValue("attValue");
65
 * writer.writeStartAttribute("http://www.example.com", "emptyAtt");
66
 * writer.writeEndAttributes();
67
 * 
68
 * //child value as a purely streamed int array
69
 * writer.startArray(EventType.VALUE_INT, 10);
70
 * for(int i = 0; i < 10; i++){
71
 *   writer.writeValue(i);
72
 * }
73
 * writer.endArray();
74
 * 
75
 * writer.writeComment("interleaved value type follow");
76
 * 
77
 * writer.writeValue("10 11 12 13");
78
 * 
79
 * writer.writeEndElement(); // child
80
 * writer.writeEndElement(); // root
81
 * writer.writeEndDocument();
82
 * </code>
83
 * </pre>
84
 * 
85
 * </p>
86
 * 
87
 * @author Gabriel Roldan (TOPP)
88
 * @version $Id: IXmlStreamWriter.java 21945 2008-06-30 14:04:53Z jpiera $
89
 * @since 1.0
90
 */
91
public interface IXmlStreamWriter {
92

  
93
    /**
94
     * Returns a safe copy of the encoding options this writer is settled up with.
95
     * <p>
96
     * Modifications to the returned object state does not affect this writer behaviour.
97
     * </p>
98
     * 
99
     * @return an object representing the set of encoding options this writer operates with
100
     */
101
    //public EncodingOptions getEncodingOptions();
102

  
103
    /**
104
     * Returns the event corresponding to the last write call.
105
     * <p>
106
     * For example, if the last write call was
107
     * {@link #writeStartElement(String, String) writeStartElement} it shall return
108
     * {@link EventType#START_ELEMENT START_ELEMENT}, if it was
109
     * {@link #writeStartAttribute(String, String) writeStartAttribute},
110
     * {@link EventType#ATTRIBUTE ATTRIBUTE}, etc.
111
     * </p>
112
     * 
113
     * @post {$return != null}
114
     * @return {@link EventType#NONE} if writing has not yet started (ie, writeStartDocument has not
115
     *         been called), the event for the last write operation otherwise.
116
     */
117
    public EventType getLastEvent();
118

  
119
    /**
120
     * @return {@code null} if no tag event has been written yet, START_ELEMENT or END_ELEMENT
121
     *         otherwise, depending on which of them was lately called
122
     */
123
    public EventType getLastTagEvent();
124

  
125
    /**
126
     * @post {$return >= 0}
127
     * @return how deep is the current element tree
128
     */
129
    public int getTagDeep();
130

  
131
    /**
132
     * Closes this stream writer and releases any system resources associated with it, including the
133
     * underlying output stream or any other output source it may be operating upon.
134
     * <p>
135
     * A call to this method implies a flush of any possible buffered wtrite before closing the
136
     * stream.
137
     * </p>
138
     * <p>
139
     * The first call to this method closes and releases resources. Subsequent calls shall take no
140
     * effect and return quitely. After the first call to this method any non query method (defined
141
     * as metadata retrieval methods in the class' javadoc) shall fail with an io exception.
142
     * </p>
143
     * 
144
     * @throws IOException if an I/O error occurs.
145
     */
146
    public void close() throws IOException;
147

  
148
    /**
149
     * Returns whether this stream writer and its underlying output source are open and able to
150
     * receive more write calls.
151
     * <p>
152
     * A {@code IXmlStreamWriter} should be open since its creation until {@link #close()} is
153
     * explicitly called by client code.
154
     * </p>
155
     * 
156
     * @return {@code true} if this stream is still open, {@code false} otherwise
157
     */
158
    public boolean isOpen();
159

  
160
    /**
161
     * Write any cached data to the underlying output mechanism.
162
     * 
163
     * @throws IOException
164
     */
165
    public void flush() throws IOException;
166

  
167
    /**
168
     * @pre {getLastEvent() == NONE}
169
     * @pre {namespaceUri != null AND schemaLocationUri != null}
170
     * @pre {namespaceUri != ""}
171
     * @param namespaceUri
172
     * @param schemaLocationUri
173
     */
174
    public void setSchemaLocation(String namespaceUri, String schemaLocationUri);
175

  
176
    /**
177
     * Initiates the encoding of an XML formatted document in the BXML encoding.
178
     * <p>
179
     * This should be the first non query method to call after a stream writer is created. The
180
     * implementation will use the call to this method to write down the document header and xml
181
     * declaration.
182
     * </p>
183
     * 
184
     * @pre {getLastEvent() == NONE}
185
     * @post {getLastEvent() == START_DOCUMENT}
186
     * @throws IOException
187
     */
188
    public void writeStartDocument() throws IOException;
189

  
190
    /**
191
     * Finishes up encoding a BXML document.
192
     * <p>
193
     * Implementations shall use this method to write down the document's trailer token.
194
     * </p>
195
     * 
196
     * @pre {getTagDeep() == 0}
197
     * @post {getLastEvent() == END_DOCUMENT}
198
     * @throws IOException
199
     */
200
    public void writeEndDocument() throws IOException;
201

  
202
    /**
203
     * @pre {namespaceUri != null}
204
     * @pre {localName != null}
205
     * @post {getLastEvent() == START_ELEMENT}
206
     * @param namespaceUri the namespace uri for the element
207
     * @param localName the elements non qualified (local) name
208
     * @throws IOException
209
     */
210
    public void writeStartElement(final String namespaceUri, final String localName)
211
            throws IOException;
212

  
213
    /**
214
     * @pre {qname != null}
215
     * @post {getLastEvent() == START_ELEMENT}
216
     * @param qname qualified element name. Only namespace and localName are relevant. Prefix, if
217
     *            present, is ignored. The currently mapped prefix for the namespace will be used in
218
     *            any case.
219
     * @throws IOException
220
     * @see #setPrefix(String, String)
221
     */
222
    public void writeStartElement(final IQName qname) throws IOException;
223

  
224
    /**
225
     * @pre {getTagDeep() > 0}
226
     * @pre { ( getLastEvent().isValue() AND getWrittenValueCount() == getValueLength() ) ||
227
     *      getLastEvent() IN ( START_ELEMENT, END_ELEMENT, ATTRIBUTES_END, COMMENT}
228
     * @post {getLastEvent() == END_ELEMENT}
229
     * @throws IOException
230
     */
231
    public void writeEndElement() throws IOException;
232

  
233
    /**
234
     * Starts writting an xml attribute.
235
     * <p>
236
     * Writting an attribute and its value is split in two parts. This method only stand for the
237
     * attribute declaration. Writting an attribute value is made after calling this method and is
238
     * optional. The attribute value can be done with any of the {@code writeValue} methods, even
239
     * using various {@code writeValue} calls for the same attribute.
240
     * </p>
241
     * <p>
242
     * After the last element attribute has been written, {@link #writeEndAttributes()} shall be
243
     * called to indicate the end of the attribute list.
244
     * </p>
245
     * Sample usage:
246
     * 
247
     * <pre>
248
     * <code>
249
     * <b>writer.startAttribute("", "att1");</b>
250
     * writer.writeValue("value1");
251
     * writer.writeValue(1);
252
     * writer.writeValue(2);
253
     * writer.writeValue(3);
254
     * <b>writer.startAttribute("", "att2");</b>
255
     * writer.writeValue(1.0L);
256
     * ...
257
     * writer.writeEndAttributes();
258
     * </code>
259
     * </pre>
260
     * 
261
     * @pre {getLastEvent() IN (START_ELEMENT, ATTRIBUTE) }
262
     * @pre {namespaceUri != null}
263
     * @pre {localName != null}
264
     * @post {getLastEvent() == ATTRIBUTE}
265
     * @param namespaceUri not null
266
     * @param localName not null
267
     * @throws IOException
268
     * @see #writeEndAttributes()
269
     */
270
    public void writeStartAttribute(final String namespaceUri, final String localName)
271
            throws IOException;
272

  
273
    /**
274
     * Starts writing an xml attribute for the given qualified name.
275
     * 
276
     * @pre {qname != null}
277
     * @param qname a QName where to get the namespace uri and local name for the attribute
278
     * @throws IOException
279
     * @see #writeStartAttribute(String, String)
280
     */
281
    public void writeStartAttribute(final IQName qname) throws IOException;
282

  
283
    /**
284
     * Indicates there are no more element attributes to encode for the current element.
285
     * <p>
286
     * This method is useful for the encoder to recognize (and write down the appropriate tokens)
287
     * the following potential call to some writeValue method corresponds to the element's contents
288
     * and not to the current attribute value.
289
     * </p>
290
     * Sample usage:
291
     * 
292
     * <pre>
293
     * <code>
294
     * writer.startElement("", "element");
295
     * writer.startAttribute("", "att1");
296
     * writer.writeValue("value1");
297
     * writer.startAttribute("", "att2");
298
     * writer.writeValue(1.0L);
299
     * ...
300
     * <b>writer.writeEndAttributes();</b>
301
     * writer.value("element value");
302
     * ...
303
     * </code>
304
     * </pre>
305
     * 
306
     * @pre {getLastTagEvent() == START_ELEMENT}
307
     * @post {getLastEvent() == ATTRIBUTES_END}
308
     * @throws IOException
309
     */
310
    public void writeEndAttributes() throws IOException;
311

  
312
    /**
313
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
314
     *      COMMENT )}
315
     * @post {getLastEvent() == VALUE_STRING}
316
     * @post {getValueLength() == 1}
317
     * @post {getWrittenValueCount() == 1}
318
     * @param value
319
     * @throws IOException
320
     */
321
    public void writeValue(final String value) throws IOException;
322

  
323
    /**
324
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
325
     *      COMMENT )}
326
     * @post {getLastEvent() == VALUE_STRING}
327
     * @param chars
328
     * @param offset
329
     * @param length
330
     * @throws IOException
331
     */
332
    public void writeValue(final char[] chars, final int offset, final int length)
333
            throws IOException;
334

  
335
    /**
336
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
337
     *      COMMENT )}
338
     * @post {getLastEvent() == VALUE_INT}
339
     * @param value
340
     * @throws IOException
341
     */
342
    public void writeValue(final int value) throws IOException;
343

  
344
    /**
345
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
346
     *      COMMENT )}
347
     * @post {getLastEvent() == VALUE_LONG}
348
     * @param value
349
     * @throws IOException
350
     */
351
    public void writeValue(final long value) throws IOException;
352

  
353
    /**
354
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
355
     *      COMMENT )}
356
     * @post {getLastEvent() == VALUE_FLOAT}
357
     * @param value
358
     * @throws IOException
359
     */
360
    public void writeValue(final float value) throws IOException;
361

  
362
    /**
363
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
364
     *      COMMENT )}
365
     * @post {getLastEvent() == VALUE_DOUBLE}
366
     * @param value
367
     * @throws IOException
368
     */
369
    public void writeValue(final double value) throws IOException;
370

  
371
    /**
372
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
373
     *      COMMENT )}
374
     * @post {getLastEvent() == VALUE_BOOL}
375
     * @param value
376
     * @throws IOException
377
     */
378
    public void writeValue(final boolean value) throws IOException;
379

  
380
    /**
381
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
382
     *      COMMENT )}
383
     * @post {getLastEvent() == VALUE_BOOL}
384
     * @param value
385
     * @param offset
386
     * @param length
387
     * @throws IOException
388
     */
389
    public void writeValue(final boolean[] value, final int offset, final int length)
390
            throws IOException;
391

  
392
    /**
393
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
394
     *      COMMENT )}
395
     * @post {getLastEvent() == VALUE_INT}
396
     * @param value
397
     * @param offset
398
     * @param length
399
     * @throws IOException
400
     */
401
    public void writeValue(final int[] value, final int offset, final int length)
402
            throws IOException;
403

  
404
    /**
405
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
406
     *      COMMENT )}
407
     * @post {getLastEvent() == VALUE_LONG}
408
     * @param value
409
     * @param offset
410
     * @param length
411
     * @throws IOException
412
     */
413
    public void writeValue(final long[] value, final int offset, final int length)
414
            throws IOException;
415

  
416
    /**
417
     * @pre {getLastEvent().isValue() == true || getLastEvent() IN (START_ELEMENT, ATTRIBUTE,
418
     *      COMMENT )}
419
     * @post {getLastEvent() == VALUE_FLOAT}
420
     * @param value
421
     * @param offset
422
     * @param length
423
     * @throws IOException
424
     */
425
    public void writeValue(final float[] value, final int offset, final int length)
426
            throws IOException;
427

  
428
    /**
429
     * Writes a value section defined by the
430
     * 
431
     * @pre {getLastEvent() IN ( START_ELEMENT START_ELEMENT, ATTRIBUTE ATTRIBUTE )}
432
     * @post {getLastEvent() == VALUE_DOUBLE}
433
     * @param value
434
     * @param offset
435
     * @param length
436
     * @throws IOException
437
     */
438
    public void writeValue(final double[] value, int offset, int length) throws IOException;
439

  
440
    /**
441
     * Writes a comments block
442
     * <p>
443
     * The provided {@code commentContent} is the coalesced value of the equivalent XML comment
444
     * block (enclosed between {@code <!--} and {@code -->} tags.
445
     * </p>
446
     * 
447
     * @post {getLastEvent() == COMMENT}
448
     * @param commentContent the coallesced value of the comment section
449
     * @throws IOException
450
     */
451
    public void writeComment(String commentContent) throws IOException;
452

  
453
    /**
454
     * @pre {valueType != null}
455
     * @pre {valueType.isValue() == true}
456
     * @pre {valueType != VALUE_STRING}
457
     * @pre {arrayLength >= 0}
458
     * @post {getLastEvent() == valueType}
459
     * @post {getWrittenValueCount() == 0}
460
     * @post {getValueLength() == arrayLength}
461
     * @param valueType
462
     * @param arrayLength
463
     * @throws IOException
464
     */
465
    public void startArray(EventType valueType, int arrayLength) throws IOException;
466

  
467
    /**
468
     * Needs to be called when done with startArray
469
     * 
470
     * @pre {getWrittenValueCount() == getValueLength()}
471
     * @throws IOException
472
     */
473
    public void endArray() throws IOException;
474

  
475
    /**
476
     * Binds a URI to the default namespace for the current context.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff