Package org.apache.maven.index.reader
Class IndexReader
- java.lang.Object
-
- org.apache.maven.index.reader.IndexReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Iterable<ChunkReader>
public class IndexReader extends java.lang.Object implements java.lang.Iterable<ChunkReader>, java.io.Closeable
Maven 2 Index reader that handles incremental updates if possible and provides one or moreChunkReaders, to read all the required records.- Since:
- 5.1.2
-
-
Constructor Summary
Constructors Constructor Description IndexReader(WritableResourceHandler local, ResourceHandler remote)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlyingResourceHandlers.java.util.List<java.lang.String>getChunkNames()Returns unmodifiable list of actual chunks that needs to be pulled from remoteResourceHandler.java.lang.StringgetIndexId()Returns the index context ID that published index has set.java.util.DategetPublishedTimestamp()Returns theDatewhen remote index was last published.booleanisIncremental()Returnstrueif incremental update is about to happen.java.util.Iterator<ChunkReader>iterator()Returns anIteratorofChunkReaders, that if read in sequence, provide all the (incremental) updates from the index.
-
-
-
Constructor Detail
-
IndexReader
public IndexReader(WritableResourceHandler local, ResourceHandler remote) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getIndexId
public java.lang.String getIndexId()
Returns the index context ID that published index has set. Usually it is equal to "repository ID" used inRecord.Type.DESCRIPTORbut does not have to be.
-
getPublishedTimestamp
public java.util.Date getPublishedTimestamp()
Returns theDatewhen remote index was last published.
-
isIncremental
public boolean isIncremental()
Returnstrueif incremental update is about to happen. If incremental update, theiterator()will return only the diff from the last update.
-
getChunkNames
public java.util.List<java.lang.String> getChunkNames()
Returns unmodifiable list of actual chunks that needs to be pulled from remoteResourceHandler. Those are incremental chunks or the big main file, depending on result ofisIncremental(). Empty list means local index is up to date, anditerator()will return empty iterator.
-
close
public void close() throws java.io.IOExceptionCloses the underlyingResourceHandlers. In case of incremental update use, it also assumes that user consumed all the iterator and integrated it, hence, it will update theWritableResourceHandlercontents to prepare it for future incremental update. If this is not desired (ie. due to aborted update), then this method should NOT be invoked, but rather theResourceHandlers that caller provided in constructor of this class should be closed manually.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
iterator
public java.util.Iterator<ChunkReader> iterator()
Returns anIteratorofChunkReaders, that if read in sequence, provide all the (incremental) updates from the index. It is caller responsibility to either consume fully this iterator, or to close currentChunkReaderif aborting.- Specified by:
iteratorin interfacejava.lang.Iterable<ChunkReader>
-
-