org.freehep.util.io
Class XMLSequence

java.lang.Object
  extended by java.io.InputStream
      extended by org.freehep.util.io.XMLSequence
All Implemented Interfaces:
Closeable

public class XMLSequence
extends InputStream

The XMLSequence allows parsing by an XML Parser of concatenated XML segments. Each segment needs to start with " XMLSequence sequence = new XMLSequence(new FileInputStream("file.xml")); SAXParserFactory factory = SAXParserFactory.newInstance(); XMLReader xmlReader = factory.newSAXParser().getXMLReader(); while (sequence.hasNext()) { InputStream input = sequence.next(); InputSource source = new InputSource(input); xmlReader.parse(source); input.close(); } sequence.close(); IMPORTANT: inherits from InputStream rather than FilterInputStream so that the correct read(byte[], int, int) method is used.

Version:
$Id: XMLSequence.java 8584 2006-08-10 23:06:37Z duns $
Author:
Mark Donszelmann

Constructor Summary
XMLSequence(InputStream input)
          Create a XML Sequence.
 
Method Summary
 void close()
           
 boolean hasNext()
          Is another XML segment available.
 void mark(int readLimit)
           
 boolean markSupported()
           
 InputStream next()
          Returns the next XML segment.
 int read()
           
 void reset()
           
 
Methods inherited from class java.io.InputStream
available, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSequence

public XMLSequence(InputStream input)
Create a XML Sequence.

Parameters:
input - stream to read from
Method Detail

hasNext

public boolean hasNext()
Is another XML segment available.

Returns:
true if another XML segment can be read

next

public InputStream next()
                 throws IOException
Returns the next XML segment.

Returns:
stream to read next XML segment from.
Throws:
IOException - if read fails

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

mark

public void mark(int readLimit)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException


Copyright © 2000-2007 FreeHEP. All Rights Reserved.