Package org.ringojs.repository
Class ZipRepository
- java.lang.Object
-
- org.ringojs.repository.AbstractRepository
-
- org.ringojs.repository.ZipRepository
-
- All Implemented Interfaces:
java.io.Serializable
,Repository
,Trackable
public final class ZipRepository extends AbstractRepository
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.ringojs.repository.Repository
SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description ZipRepository(java.io.File file)
Constructs a ZipRespository using the given zip file.ZipRepository(java.lang.String path)
Constructs a ZipRespository using the given zip file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AbstractRepository
createChildRepository(java.lang.String name)
Create a new child reposiotory with the given name.boolean
equals(java.lang.Object obj)
boolean
exists()
Checks wether this resource actually (still) existslong
getChecksum()
Checksum of the resource content.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.protected java.util.zip.ZipFile
getZipFile()
Returns a java.util.zip.ZipFile for this repository.int
hashCode()
long
lastModified()
Returns the date the resource was last modifiedprotected Resource
lookupResource(java.lang.String name)
Called to create a child resource for this repository.java.lang.String
toString()
Returns the repositories full path as string representation.-
Methods inherited from class org.ringojs.repository.AbstractRepository
getChildRepository, getModuleName, getName, getParentRepository, getPath, getRelativePath, getResource, getResources, getResources, getResources, getRootRepository, isAbsolute, lookupRepository, resolve, setAbsolute, setRoot
-
-
-
-
Constructor Detail
-
ZipRepository
public ZipRepository(java.lang.String path) throws java.util.zip.ZipException, java.io.IOException
Constructs a ZipRespository using the given zip file.- Parameters:
path
- path to zip file- Throws:
java.util.zip.ZipException
- a zip encoding related error occurredjava.io.IOException
- an I/O error occurred
-
ZipRepository
public ZipRepository(java.io.File file) throws java.util.zip.ZipException, java.io.IOException
Constructs a ZipRespository using the given zip file.- Parameters:
file
- zip file- Throws:
java.util.zip.ZipException
- a zip encoding related error occurredjava.io.IOException
- an I/O error occurred
-
-
Method Detail
-
getZipFile
protected java.util.zip.ZipFile getZipFile() throws java.io.IOException
Returns a java.util.zip.ZipFile for this repository.- Returns:
- a ZipFile for reading
- Throws:
java.io.IOException
- an I/O related error occurred
-
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
-
exists
public boolean exists() throws java.io.IOException
Checks wether this resource actually (still) exists- Returns:
- true if the resource exists
- Throws:
java.io.IOException
-
createChildRepository
protected AbstractRepository createChildRepository(java.lang.String name) throws java.io.IOException
Description copied from class:AbstractRepository
Create a new child reposiotory with the given name.- Specified by:
createChildRepository
in classAbstractRepository
- Parameters:
name
- the name- Returns:
- the new child repository
- 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
-
lastModified
public long lastModified()
Description copied from interface:Trackable
Returns the date the resource was last modified- Returns:
- last modified date
-
getChecksum
public long getChecksum()
Description copied from interface:Trackable
Checksum of the resource content. Implementations should make sure to return a different checksum if the resource's content has changed.- Returns:
- checksum
-
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()
-
-