de.hpi.fgis.dude.util.sorting.sorter
Class SortedDataFile

java.lang.Object
  extended by de.hpi.fgis.dude.util.sorting.sorter.SortedDataFile
All Implemented Interfaces:
Closeable

public class SortedDataFile
extends Object
implements Closeable

SortedDataFile encapsulates the functionality that is needed for the TwoPhaseMultiWayMergeSorter in phase two. It provides a method for removing the file and methods for iterating over the content of the file.

Author:
Matthias Pohl

Constructor Summary
SortedDataFile(FileBasedStorage<DuDeObject> file)
          Initializes a SortedDataFile and loads the first element.
 
Method Summary
 void close()
           
 DuDeObject current()
          Returns the element on which the iterating pointer points right now.
 void deleteFile()
          Deletes the file from the file system and clears the member data of this instance.
 FileBasedStorage<DuDeObject> getDataFile()
          Returns the FileBasedStorage that is encapsulated in this instance.
 boolean hasNext()
          Checks whether the end of the file is reached.
protected  boolean isAccessible()
          Checks whether the file can be accessed.
 DuDeObject next()
          Sets the the iteration pointer to the next element and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedDataFile

public SortedDataFile(FileBasedStorage<DuDeObject> file)
Initializes a SortedDataFile and loads the first element. Therefore calling next() after calling this constructor returns the second element.

Parameters:
file - The FileBasedStorage that is read.
Method Detail

current

public DuDeObject current()
Returns the element on which the iterating pointer points right now.

Returns:
The current element or null, if the end of the file is reached.

deleteFile

public void deleteFile()
Deletes the file from the file system and clears the member data of this instance.


hasNext

public boolean hasNext()
Checks whether the end of the file is reached.

Returns:
true, if this file has still data to read; otherwise false.

next

public DuDeObject next()
Sets the the iteration pointer to the next element and returns it.

Returns:
The next DuDeObject instance in this collection or null, if the end of the file is reached.

isAccessible

protected boolean isAccessible()
Checks whether the file can be accessed.

Returns:
true, if the file can be accessed; otherwise false.

getDataFile

public FileBasedStorage<DuDeObject> getDataFile()
Returns the FileBasedStorage that is encapsulated in this instance.

Returns:
The FileBasedStorage.

close

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


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.