org.tranche.project
Class DiskBackedProjectFilePartSet

java.lang.Object
  extended by org.tranche.project.DiskBackedProjectFilePartSet
All Implemented Interfaces:
java.lang.Iterable<ProjectFilePart>, java.util.Collection<ProjectFilePart>, java.util.Set<ProjectFilePart>

public class DiskBackedProjectFilePartSet
extends java.lang.Object
implements java.util.Set<ProjectFilePart>

A memory sensitive Set implementation for managing ProjectFileParts. If too many parts exist, some are stored to disk. Automatically sorted.

Author:
Jayson Falker - jfalkner@umich.edu

Constructor Summary
DiskBackedProjectFilePartSet()
          Creates a new instance of DiskBackedProjectFilePartSet
 
Method Summary
 boolean add(ProjectFilePart o)
          Adds a project file part set to the list of project file part sets.
 boolean addAll(java.util.Collection<? extends ProjectFilePart> c)
          Throws RuntimeException
 void clear()
          Resets the object.
 boolean contains(java.lang.Object o)
          Throws RuntimeException
 boolean containsAll(java.util.Collection<?> c)
          Throws RuntimeException
 void destroy()
          Explicity destroy the disk-backed collection.
protected  void finalize()
          Help prevent amassing large num.
 int getMaxBufferSize()
          Returns the maximum size.
 boolean isEmpty()
          Returns whether the set does not contain any project file parts.
 java.util.Iterator<ProjectFilePart> iterator()
          Returns an iterator of the set of project file parts.
 boolean remove(java.lang.Object o)
          Throws RuntimeException
 boolean removeAll(java.util.Collection<?> c)
          Throws RuntimeException
 boolean retainAll(java.util.Collection<?> c)
          Throws RuntimeException
 void setMaxBufferSize(int maxBufferSize)
          Sets the maximum buffer size.
 int size()
          Returns the number of project file parts.
 java.lang.Object[] toArray()
          Returns an array of project file parts.
<T> T[]
toArray(T[] a)
          Returns an array of project file parts.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

DiskBackedProjectFilePartSet

public DiskBackedProjectFilePartSet()

Creates a new instance of DiskBackedProjectFilePartSet

Method Detail

finalize

protected void finalize()
Help prevent amassing large num. temp files

Overrides:
finalize in class java.lang.Object

destroy

public void destroy()

Explicity destroy the disk-backed collection. If don't, GC will garbage collect OR temp dir cleaned out when tool reran.


contains

public boolean contains(java.lang.Object o)

Throws RuntimeException

Specified by:
contains in interface java.util.Collection<ProjectFilePart>
Specified by:
contains in interface java.util.Set<ProjectFilePart>
Parameters:
o -
Returns:

remove

public boolean remove(java.lang.Object o)

Throws RuntimeException

Specified by:
remove in interface java.util.Collection<ProjectFilePart>
Specified by:
remove in interface java.util.Set<ProjectFilePart>
Parameters:
o -
Returns:

toArray

public <T> T[] toArray(T[] a)

Returns an array of project file parts.

Specified by:
toArray in interface java.util.Collection<ProjectFilePart>
Specified by:
toArray in interface java.util.Set<ProjectFilePart>
Type Parameters:
T -
Parameters:
a -
Returns:

addAll

public boolean addAll(java.util.Collection<? extends ProjectFilePart> c)

Throws RuntimeException

Specified by:
addAll in interface java.util.Collection<ProjectFilePart>
Specified by:
addAll in interface java.util.Set<ProjectFilePart>
Parameters:
c -
Returns:

add

public boolean add(ProjectFilePart o)

Adds a project file part set to the list of project file part sets.

Specified by:
add in interface java.util.Collection<ProjectFilePart>
Specified by:
add in interface java.util.Set<ProjectFilePart>
Parameters:
o -
Returns:

containsAll

public boolean containsAll(java.util.Collection<?> c)

Throws RuntimeException

Specified by:
containsAll in interface java.util.Collection<ProjectFilePart>
Specified by:
containsAll in interface java.util.Set<ProjectFilePart>
Parameters:
c -
Returns:

removeAll

public boolean removeAll(java.util.Collection<?> c)

Throws RuntimeException

Specified by:
removeAll in interface java.util.Collection<ProjectFilePart>
Specified by:
removeAll in interface java.util.Set<ProjectFilePart>
Parameters:
c -
Returns:

retainAll

public boolean retainAll(java.util.Collection<?> c)

Throws RuntimeException

Specified by:
retainAll in interface java.util.Collection<ProjectFilePart>
Specified by:
retainAll in interface java.util.Set<ProjectFilePart>
Parameters:
c -
Returns:

clear

public void clear()

Resets the object.

Specified by:
clear in interface java.util.Collection<ProjectFilePart>
Specified by:
clear in interface java.util.Set<ProjectFilePart>

isEmpty

public boolean isEmpty()

Returns whether the set does not contain any project file parts.

Specified by:
isEmpty in interface java.util.Collection<ProjectFilePart>
Specified by:
isEmpty in interface java.util.Set<ProjectFilePart>
Returns:

iterator

public java.util.Iterator<ProjectFilePart> iterator()

Returns an iterator of the set of project file parts.

Specified by:
iterator in interface java.lang.Iterable<ProjectFilePart>
Specified by:
iterator in interface java.util.Collection<ProjectFilePart>
Specified by:
iterator in interface java.util.Set<ProjectFilePart>
Returns:

size

public int size()

Returns the number of project file parts.

Specified by:
size in interface java.util.Collection<ProjectFilePart>
Specified by:
size in interface java.util.Set<ProjectFilePart>
Returns:

toArray

public java.lang.Object[] toArray()

Returns an array of project file parts.

Specified by:
toArray in interface java.util.Collection<ProjectFilePart>
Specified by:
toArray in interface java.util.Set<ProjectFilePart>
Returns:

getMaxBufferSize

public int getMaxBufferSize()

Returns the maximum size.

Returns:

setMaxBufferSize

public void setMaxBufferSize(int maxBufferSize)

Sets the maximum buffer size.

Parameters:
maxBufferSize -


This code is free for use both commercially and non-commercially as stated in the project's license