org.rhq.common.drift
Class ChangeSetReaderImpl

java.lang.Object
  extended by org.rhq.common.drift.ChangeSetReaderImpl
All Implemented Interfaces:
Iterable<FileEntry>, ChangeSetReader

public class ChangeSetReaderImpl
extends Object
implements ChangeSetReader

Note that this implementation does not do any validation for the most part. It assumes that entries in the change set file contain valid, 64 character SHA-256 hashes. It assumes that all headers are present in the file and in the correct order. It assume that all paths are non-null.

The one thing that the read does check is the drift category code for each file entry. If the code is not valid, an error message is logged and a ChangeSetReaderException is thrown.


Constructor Summary
ChangeSetReaderImpl(File metaDataFile)
           
ChangeSetReaderImpl(Reader metaDataFile)
           
ChangeSetReaderImpl(Reader metaDataFile, boolean closeStream)
          Creates a new change set reader.
 
Method Summary
 void close()
          Closes the reader.
 Headers getHeaders()
          Returns the headers from change set file.
 Iterator<FileEntry> iterator()
           
 FileEntry read()
          Read and return the next file entry or null if the end of the file has been reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeSetReaderImpl

public ChangeSetReaderImpl(File metaDataFile)
                    throws ChangeSetReaderException
Throws:
ChangeSetReaderException

ChangeSetReaderImpl

public ChangeSetReaderImpl(Reader metaDataFile)
                    throws Exception
Throws:
Exception

ChangeSetReaderImpl

public ChangeSetReaderImpl(Reader metaDataFile,
                           boolean closeStream)
                    throws Exception
Creates a new change set reader. This constructor takes a boolean argument that can be used to prevent the reader from closing the stream when using its iterator. Note that calling close() will close the stream regardless of the value of closeStream.

Parameters:
metaDataFile -
closeStream -
Throws:
Exception
Method Detail

getHeaders

public Headers getHeaders()
                   throws ChangeSetReaderException
Description copied from interface: ChangeSetReader
Returns the headers from change set file. This method can be called multiple times. Given a properly formatted change set file, this method should never return null.

Specified by:
getHeaders in interface ChangeSetReader
Returns:
The change set headers
Throws:
ChangeSetReaderException - If an error occurs reading the file or the headers are not formatted correctly.

read

public FileEntry read()
               throws ChangeSetReaderException
Description copied from interface: ChangeSetReader
Read and return the next file entry or null if the end of the file has been reached.

Specified by:
read in interface ChangeSetReader
Returns:
The next file entry
Throws:
ChangeSetReaderException - if an IO error occurs or if the file entry is not properly formatted.

close

public void close()
           throws ChangeSetReaderException
Description copied from interface: ChangeSetReader
Closes the reader.

Specified by:
close in interface ChangeSetReader
Throws:
ChangeSetReaderException - if an IO error occurs

iterator

public Iterator<FileEntry> iterator()
Specified by:
iterator in interface Iterable<FileEntry>


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.