01: /*
02: * File: XMLInputStream.java
03: * Project: jMOS, com.aranova.java.jmos.io
04: * Revision: 0.9 - Inicial
05: * Date: 30-sep-2005 10:15:13
06: *
07: * Copyright (C) Aragón Innovación Tecnológica S.L.L.
08: * All rights reserved.
09: *
10: * This software is distributed under the terms of the Aranova License version 1.0.
11: * See the terms of the Aranova License in the documentation provided with this software.
12: */
13:
14: package com.aranova.java.jmos.io;
15:
16: import java.io.FilterInputStream;
17: import java.io.IOException;
18: import java.io.InputStream;
19:
20: /**
21: * Clase para lectura de XML sobre streams.
22: *
23: * @author <a href="http://www.aranova.net/contactar/">Daniel Sánchez</a>
24: * @version 0.9.1
25: * @since 0.9
26: */
27: public class XMLInputStream extends FilterInputStream {
28: private boolean _marcarFinal = false;
29: private boolean _marcaInicio = true;
30:
31: /**
32: * @param in
33: */
34: public XMLInputStream(final InputStream in) {
35: super (in);
36: }
37:
38: /* (non-Javadoc)
39: * @see java.io.FilterInputStream#read(byte[], int, int)
40: */
41: @Override
42: public int read(final byte[] b, final int off, final int len)
43: throws IOException {
44: int result;
45: if (_marcarFinal) {
46: _marcaInicio = false;
47: result = -1;
48: _marcarFinal = false;
49: } else {
50: _marcaInicio = true;
51: result = super .read(b, off, len);
52: }
53: return result;
54: }
55:
56: /**
57: * Metodo para indicar que se incluya el final de fichero en la proxima lectura.
58: */
59: public void endStream() {
60: _marcarFinal = true;
61: }
62:
63: /**
64: * @return Retorna la marca de inicio de lectura.
65: */
66: public boolean getMarcaInicio() {
67: return _marcaInicio;
68: }
69:
70: /* (non-Javadoc)
71: * @see java.io.FilterInputStream#close()
72: */
73: @Override
74: public void close() throws IOException {
75: }
76: }
|