|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.egothor.duplicity.file.DuplicityCheckingFile
public abstract class DuplicityCheckingFile
Ancestor for all the files in org.egothor.duplicity.file package. Provides common data fields with the getters, methods for obtaining String representation, deleting file on filesystem and helper functions for creating temporary and permanent files.
Nested Class Summary | |
---|---|
protected class |
DuplicityCheckingFile.TempFile
|
Field Summary | |
---|---|
protected java.lang.String |
location
Location of the filesystem file. |
protected File |
out
The filesystem file corresponding to this file. |
Constructor Summary | |
---|---|
protected |
DuplicityCheckingFile()
|
Method Summary | |
---|---|
protected abstract void |
createOut()
Sets the out field of the class. |
protected void |
createPermOut()
The implementation of the createOut() method for permanent files. |
protected void |
createTempOut()
The implementation of the createOut() for temporary files. |
void |
delete()
Deletes the file from filesystem. |
protected java.lang.String |
dump(DuplicityCheckingFileElement element)
Dumps the file with its content to String. |
abstract java.lang.String |
getFilename()
Returns the filename corresponding to this file. |
java.lang.String |
getLocation()
|
protected DuplicityCheckingFile.TempFile |
getNewTempFile(java.lang.String filename,
java.lang.String existsMessage)
|
File |
getOut()
|
boolean |
hasTheSameContent(DuplicityCheckingFile file,
DuplicityCheckingFileElement element1,
DuplicityCheckingFileElement element2)
Checks if two files has the same content. |
protected void |
initFromProducer(java.lang.String location,
java.util.List<? extends DuplicityCheckingFileElement> buffer)
Initialializes the file by writing buffer content to disk. |
protected void |
openOut()
Opens the file on filesystem and sets the out field. |
protected void |
remove(DuplicityCheckingFileElement element,
java.util.Set<DocumentUnitID> toRemove)
Removes all occurences of documents given in the set from the file. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected File out
protected java.lang.String location
Constructor Detail |
---|
protected DuplicityCheckingFile()
Method Detail |
---|
public java.lang.String getLocation()
public File getOut()
public void delete()
public java.lang.String toString()
toString
in class java.lang.Object
protected abstract void createOut() throws java.io.IOException
java.io.IOException
public abstract java.lang.String getFilename()
protected void createTempOut() throws java.io.IOException
createOut()
for temporary files.
The location and permID (if present) fields MUST be already set.
Initializes the out field and creates the file on filesystem.
The filename is created in temp directory under the directory given in location field
and is in form returned by getFilename()
.
The temp directory must exist. If the file exists, it will be rewritten.
java.io.IOException
- if the file could not be createdprotected void createPermOut() throws java.io.IOException
createOut()
method for permanent files.
The location and permID (if present) fields MUST be already set.
Initializes the out field and creates the file on filesystem.
The filename is created in directory given in location field
and is in form returned by getFilename()
.
The directory must exist, the file must NOT exist.
java.io.IOException
- if the file already exists or
could not be createdprotected void openOut() throws java.io.FileNotFoundException
java.io.FileNotFoundException
protected java.lang.String dump(DuplicityCheckingFileElement element)
element
- instance of the class from which the file consists
protected DuplicityCheckingFile.TempFile getNewTempFile(java.lang.String filename, java.lang.String existsMessage) throws java.io.IOException
java.io.IOException
protected void initFromProducer(java.lang.String location, java.util.List<? extends DuplicityCheckingFileElement> buffer) throws java.io.IOException
getFilename()
and will be created in the location directory. The directory must exist.
If the existence of the file causes an exception depends on the createOut()
method provided in the child class.
location
- path and name of the directory in which the file will be created,
must end with "/" signbuffer
- buffer of elements to be written to the file
java.io.IOException
- if the file could not be created,
or writing data to the file failedprotected void remove(DuplicityCheckingFileElement element, java.util.Set<DocumentUnitID> toRemove) throws java.io.IOException
element
- instance of the class from which the file consiststoRemove
- set of document ids to remove
java.io.IOException
public boolean hasTheSameContent(DuplicityCheckingFile file, DuplicityCheckingFileElement element1, DuplicityCheckingFileElement element2)
file
- the second file to be testedelement1
- instance of the class from which the file consistselement2
- instance of the class from which the file consists
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |