org.geotools.data.shapefile
Class StorageFile

java.lang.Object
  extended by org.geotools.data.shapefile.StorageFile
All Implemented Interfaces:
java.lang.Comparable<StorageFile>, FileReader, FileWriter

public final class StorageFile
extends java.lang.Object
implements java.lang.Comparable<StorageFile>, FileWriter

Encapsulates the idea of a file for writing data to and then later updating the original.

Author:
jesse

Constructor Summary
StorageFile(ShpFiles shpFiles, java.io.File tempFile, ShpFileType type)
           
 
Method Summary
 int compareTo(StorageFile o)
          Just groups together files that have the same ShpFiles instance
 java.io.File getFile()
          Returns the storage file
 java.nio.channels.FileChannel getWriteChannel()
           
 java.lang.String id()
          An id for the writer.
 void replaceOriginal()
          Replaces the file that the temporary file is acting as a transactional type cache for.
static void replaceOriginals(StorageFile... storageFiles)
          Takes a collection of StorageFiles and performs the replace functionality described in replaceOriginal().
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StorageFile

public StorageFile(ShpFiles shpFiles,
                   java.io.File tempFile,
                   ShpFileType type)
Method Detail

getFile

public java.io.File getFile()
Returns the storage file

Returns:
the storage file

getWriteChannel

public java.nio.channels.FileChannel getWriteChannel()
                                              throws java.io.IOException
Throws:
java.io.IOException

replaceOriginal

public void replaceOriginal()
                     throws java.io.IOException
Replaces the file that the temporary file is acting as a transactional type cache for. Acts similar to a commit.

Throws:
java.io.IOException
See Also:
replaceOriginals(StorageFile...)

replaceOriginals

public static void replaceOriginals(StorageFile... storageFiles)
                             throws java.io.IOException
Takes a collection of StorageFiles and performs the replace functionality described in replaceOriginal(). However, all files that are part of the same ShpFiles are done within a lock so all of the updates for all the Files of a Shapefile can be updated within a single lock.

Parameters:
storageFiles - files to execute the replace functionality.
Throws:
java.io.IOException

compareTo

public int compareTo(StorageFile o)
Just groups together files that have the same ShpFiles instance

Specified by:
compareTo in interface java.lang.Comparable<StorageFile>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

id

public java.lang.String id()
Description copied from interface: FileWriter
An id for the writer. This is only used for debugging.

Specified by:
id in interface FileReader
Specified by:
id in interface FileWriter
Returns:
id for the writer.


Copyright © 1996-2010 Geotools. All Rights Reserved.