|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.data.shapefile.ShpFiles
public class ShpFiles
The collection of all the files that are the shapefile and its metadata and indices.
This class has methods for performing actions on the files. Currently mainly for obtaining read and write channels and streams. But in the future a move method may be introduced.
Note: The method that require locks (such as getInputStream()) will
automatically acquire locks and the javadocs should document how to release
the lock. Therefore the methods acquireRead(ShpFileType, FileReader)
and acquireWrite(ShpFileType, FileWriter)
svn
Nested Class Summary | |
---|---|
static class |
ShpFiles.State
|
Constructor Summary | |
---|---|
ShpFiles(java.io.File file)
Searches for all the files and adds then to the map of files. |
|
ShpFiles(java.lang.String fileName)
Searches for all the files and adds then to the map of files. |
|
ShpFiles(java.net.URL url)
Searches for all the files and adds then to the map of files. |
Method Summary | |
---|---|
java.net.URL |
acquireRead(ShpFileType type,
FileReader requestor)
Acquire a URL for read only purposes. |
java.io.File |
acquireReadFile(ShpFileType type,
FileReader requestor)
Acquire a File for read only purposes. |
java.net.URL |
acquireWrite(ShpFileType type,
FileWriter requestor)
Acquire a URL for read and write purposes. |
java.io.File |
acquireWriteFile(ShpFileType type,
FileWriter requestor)
Acquire a File for read and write purposes. |
boolean |
delete()
Delete all the shapefile files. |
boolean |
exists(ShpFileType fileType)
Returns true if the file exists. |
protected void |
finalize()
This verifies that this class has been closed correctly (nothing locking) |
java.lang.String |
get(ShpFileType type)
Returns the string form of the url that identifies the file indicated by the type parameter or null if it is known that the file does not exist. |
java.util.Map<ShpFileType,java.lang.String> |
getFileNames()
Returns the URLs (in string form) of all the files for the shapefile datastore. |
java.io.InputStream |
getInputStream(ShpFileType type,
FileReader requestor)
Opens a input stream for the indicated file. |
java.io.OutputStream |
getOutputStream(ShpFileType type,
FileWriter requestor)
Opens a output stream for the indicated file. |
java.nio.channels.ReadableByteChannel |
getReadChannel(ShpFileType type,
FileReader requestor)
Obtain a ReadableByteChannel from the given URL. |
StorageFile |
getStorageFile(ShpFileType type)
Obtains a Storage file for the type indicated. |
java.lang.String |
getTypeName()
|
java.nio.channels.WritableByteChannel |
getWriteChannel(ShpFileType type,
FileWriter requestor)
Obtain a WritableByteChannel from the given URL. |
boolean |
isLocal()
Determine if the location of this shapefile is local or remote. |
void |
logCurrentLockers(java.util.logging.Level logLevel)
Writes to the log all the lockers and when they were constructed. |
int |
numberOfLocks()
Returns the number of locks on the current set of shapefile files. |
Result<java.net.URL,ShpFiles.State> |
tryAcquireRead(ShpFileType type,
FileReader requestor)
Tries to acquire a URL for read only purposes. |
Result<java.net.URL,ShpFiles.State> |
tryAcquireWrite(ShpFileType type,
FileWriter requestor)
Tries to acquire a URL for read/write purposes. |
void |
unlockRead(java.io.File file,
FileReader requestor)
Unlocks a read lock. |
void |
unlockRead(java.net.URL url,
FileReader requestor)
Unlocks a read lock. |
void |
unlockWrite(java.io.File file,
FileWriter requestor)
Unlocks a read lock. |
void |
unlockWrite(java.net.URL url,
FileWriter requestor)
Unlocks a read lock. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ShpFiles(java.lang.String fileName) throws java.net.MalformedURLException
fileName
- the filename or url of any one of the shapefile files
java.net.MalformedURLException
- if it isn't possible to create a URL from string. It will
be used to create a file and create a URL from that if
both fail this exception is thrownpublic ShpFiles(java.io.File file) throws java.net.MalformedURLException
file
- any one of the shapefile files
java.io.FileNotFoundException
- if the shapefile associated with file is not found
java.net.MalformedURLException
public ShpFiles(java.net.URL url) throws java.lang.IllegalArgumentException
file
- any one of the shapefile files
java.lang.IllegalArgumentException
Method Detail |
---|
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void logCurrentLockers(java.util.logging.Level logLevel)
logLevel
- the level at which to log.public java.util.Map<ShpFileType,java.lang.String> getFileNames()
public java.lang.String get(ShpFileType type)
Note: a URL should NOT be constructed from the string instead the URL should be obtained through calling one of the aquireLock methods.
type
- indicates the type of file the caller is interested in.
public int numberOfLocks()
public java.io.File acquireReadFile(ShpFileType type, FileReader requestor)
type
- the type of the file desired.requestor
- the object that is requesting the File. The same object
must release the lock and is also used for debugging.
getInputStream(ShpFileType, FileReader)
,
getReadChannel(ShpFileType, FileReader)
,
#getWriteChannel(ShpFileType, FileReader)
public java.net.URL acquireRead(ShpFileType type, FileReader requestor)
type
- the type of the file desired.requestor
- the object that is requesting the URL. The same object
must release the lock and is also used for debugging.
getInputStream(ShpFileType, FileReader)
,
getReadChannel(ShpFileType, FileReader)
,
#getWriteChannel(ShpFileType, FileReader)
public Result<java.net.URL,ShpFiles.State> tryAcquireRead(ShpFileType type, FileReader requestor)
It is recommended that get*Stream or get*Channel methods are used when reading or writing to the file is desired.
type
- the type of the file desired.requestor
- the object that is requesting the URL. The same object
must release the lock and is also used for debugging.
getInputStream(ShpFileType, FileReader)
,
getReadChannel(ShpFileType, FileReader)
,
#getWriteChannel(ShpFileType, FileReader)
public void unlockRead(java.io.File file, FileReader requestor)
file
- file that was lockedrequestor
- the class that requested the filepublic void unlockRead(java.net.URL url, FileReader requestor)
url
- url that was lockedrequestor
- the class that requested the urlpublic java.io.File acquireWriteFile(ShpFileType type, FileWriter requestor)
It is recommended that get*Stream or get*Channel methods are used when reading or writing to the file is desired.
type
- the type of the file desired.requestor
- the object that is requesting the File. The same object
must release the lock and is also used for debugging.
getInputStream(ShpFileType, FileReader)
,
getReadChannel(ShpFileType, FileReader)
,
#getWriteChannel(ShpFileType, FileReader)
public java.net.URL acquireWrite(ShpFileType type, FileWriter requestor)
It is recommended that get*Stream or get*Channel methods are used when reading or writing to the file is desired.
type
- the type of the file desired.requestor
- the object that is requesting the URL. The same object
must release the lock and is also used for debugging.
getInputStream(ShpFileType, FileReader)
,
getReadChannel(ShpFileType, FileReader)
,
#getWriteChannel(ShpFileType, FileReader)
public Result<java.net.URL,ShpFiles.State> tryAcquireWrite(ShpFileType type, FileWriter requestor)
It is recommended that get*Stream or get*Channel methods are used when reading or writing to the file is desired.
type
- the type of the file desired.requestor
- the object that is requesting the URL. The same object
must release the lock and is also used for debugging.
getInputStream(ShpFileType, FileReader)
,
getReadChannel(ShpFileType, FileReader)
,
#getWriteChannel(ShpFileType, FileReader)
public void unlockWrite(java.io.File file, FileWriter requestor)
file
- file that was lockedrequestor
- the class that requested the filepublic void unlockWrite(java.net.URL url, FileWriter requestor)
url
- url that was lockedrequestor
- the class that requested the urlpublic boolean isLocal()
public boolean delete()
public java.io.InputStream getInputStream(ShpFileType type, FileReader requestor) throws java.io.IOException
type
- the type of file to open the stream to.requestor
- the object requesting the stream
java.io.IOException
- if a problem occurred opening the stream.public java.io.OutputStream getOutputStream(ShpFileType type, FileWriter requestor) throws java.io.IOException
type
- the type of file to open the stream to.requestor
- the object requesting the stream
java.io.IOException
- if a problem occurred opening the stream.public java.nio.channels.ReadableByteChannel getReadChannel(ShpFileType type, FileReader requestor) throws java.io.IOException
A read lock is obtained when this method is called and released when the channel is closed.
type
- the type of file to open the channel to.requestor
- the object requesting the channel
java.io.IOException
public java.nio.channels.WritableByteChannel getWriteChannel(ShpFileType type, FileWriter requestor) throws java.io.IOException
A write lock is obtained when this method is called and released when the channel is closed.
type
- the type of file to open the stream to.requestor
- the object requesting the stream
java.io.IOException
- if there is an error opening the streampublic StorageFile getStorageFile(ShpFileType type) throws java.io.IOException
type
- the type of file to create and return
java.io.IOException
- if temporary files cannot be createdpublic java.lang.String getTypeName()
public boolean exists(ShpFileType fileType) throws java.lang.IllegalArgumentException
fileType
- the type of file to check existance for.
java.lang.IllegalArgumentException
- if the files are not local.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |