Package org.ringojs.repository
Class FileRepository
- java.lang.Object
-
- org.ringojs.repository.AbstractRepository
-
- org.ringojs.repository.FileRepository
-
- All Implemented Interfaces:
java.io.Serializable
,Repository
,Trackable
public class FileRepository extends AbstractRepository
Repository implementation for directories providing file resources- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.File
directory
protected long
lastChecksum
protected long
lastChecksumTime
protected long
lastModified
-
Fields inherited from interface org.ringojs.repository.Repository
SEPARATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description FileRepository(java.io.File dir)
Constructs a FileRepository using the given directory as top-level repositoryprotected
FileRepository(java.io.File dir, FileRepository parent)
Constructs a FileRepository using the given directory and top-level repositoryFileRepository(java.lang.String path)
Constructs a FileRepository using the given argument
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractRepository
createChildRepository(java.lang.String name)
Create a child repository with the given nameboolean
equals(java.lang.Object obj)
boolean
exists()
Check whether the repository exists.long
getChecksum()
Checksum of the repository and all its contained resources.AbstractRepository
getParentRepository()
Get this repository's parent repository.Repository[]
getRepositories()
Returns this repository's direct child repositoriesprotected void
getResources(java.util.List<Resource> list, boolean recursive)
Add the repository's resources into the list, optionally descending into nested repositories.java.net.URL
getUrl()
Returns an url to the resource if the repository of this resource is able to provide urls.int
hashCode()
long
lastModified()
Returns the date the repository was last modified.protected Resource
lookupResource(java.lang.String name)
Called to create a child resource for this repositoryjava.lang.String
toString()
Returns the repositories full path as string representation.-
Methods inherited from class org.ringojs.repository.AbstractRepository
getChildRepository, getModuleName, getName, getPath, getRelativePath, getResource, getResources, getResources, getResources, getRootRepository, isAbsolute, lookupRepository, resolve, setAbsolute, setRoot
-
-
-
-
Constructor Detail
-
FileRepository
public FileRepository(java.lang.String path) throws java.io.IOException
Constructs a FileRepository using the given argument- Parameters:
path
- absolute path to the directory- Throws:
java.io.IOException
- if canonical path couldn't be resolved
-
FileRepository
public FileRepository(java.io.File dir) throws java.io.IOException
Constructs a FileRepository using the given directory as top-level repository- Parameters:
dir
- directory- Throws:
java.io.IOException
- if canonical path couldn't be resolved
-
FileRepository
protected FileRepository(java.io.File dir, FileRepository parent) throws java.io.IOException
Constructs a FileRepository using the given directory and top-level repository- Parameters:
dir
- directoryparent
- top-level repository- Throws:
java.io.IOException
- if canonical path couldn't be resolved
-
-
Method Detail
-
exists
public boolean exists()
Check whether the repository exists.- Returns:
- true if the repository exists.
-
createChildRepository
public AbstractRepository createChildRepository(java.lang.String name) throws java.io.IOException
Create a child repository with the given name- Specified by:
createChildRepository
in classAbstractRepository
- Parameters:
name
- the name of the repository- Returns:
- the child repository
- Throws:
java.io.IOException
- an I/O error occurred
-
getParentRepository
public AbstractRepository getParentRepository()
Get this repository's parent repository.- Specified by:
getParentRepository
in interfaceTrackable
- Overrides:
getParentRepository
in classAbstractRepository
- Returns:
- parent repository
-
lastModified
public long lastModified()
Returns the date the repository was last modified.- Returns:
- last modified date
-
getChecksum
public long getChecksum() throws java.io.IOException
Checksum of the repository and all its contained resources. Implementations should make sure to return a different checksum if any contained resource has changed.- Returns:
- checksum
- Throws:
java.io.IOException
-
lookupResource
protected Resource lookupResource(java.lang.String name) throws java.io.IOException
Called to create a child resource for this repository- Specified by:
lookupResource
in classAbstractRepository
- Parameters:
name
- the name of the child resource- Returns:
- the child resource, or null if no resource with the given name exists
- Throws:
java.io.IOException
- an I/O error occurred
-
getResources
protected void getResources(java.util.List<Resource> list, boolean recursive) throws java.io.IOException
Description copied from class:AbstractRepository
Add the repository's resources into the list, optionally descending into nested repositories.- Specified by:
getResources
in classAbstractRepository
- Parameters:
list
- the list to add the resources torecursive
- whether to descend into nested repositories- Throws:
java.io.IOException
- an I/O related error occurred
-
getRepositories
public Repository[] getRepositories() throws java.io.IOException
Description copied from interface:Repository
Returns this repository's direct child repositories- Returns:
- direct repositories
- Throws:
java.io.IOException
- an I/O error occurred
-
getUrl
public java.net.URL getUrl() throws java.net.MalformedURLException
Description copied from interface:Trackable
Returns an url to the resource if the repository of this resource is able to provide urls.- Returns:
- url to the resource
- Throws:
java.net.MalformedURLException
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
Description copied from class:AbstractRepository
Returns the repositories full path as string representation.- Overrides:
toString
in classAbstractRepository
- See Also:
AbstractRepository.getPath()
-
-