public abstract class PathNutDao extends AbstractNutDao
A NutDao
implementation for accesses based on the path API provided by WUIC.
The class is abstract and asks subclass to define the way the base directory should be defined.
AbstractNutDao.VersionNumberStrategy, AbstractNutDao.WithRootPathNutDao
PollingScheduler.Polling
NutDao.PathFormat
Constructor and Description |
---|
PathNutDao(String base,
Boolean basePathAsSysProp,
String[] proxies,
int pollingSeconds,
Boolean regex,
Boolean wildcard,
AbstractNutDao.VersionNumberStrategy versionNumberStrategy)
Builds a new instance with a base directory.
|
Modifier and Type | Method and Description |
---|---|
Nut |
accessFor(String realPath,
NutType type,
ProcessContext processContext)
Creates an access for the given parameters through a
Nut implementation. |
protected abstract DirectoryPath |
createBaseDirectory()
Creates the
DirectoryPath associated to the AbstractNutDao.basePath . |
Boolean |
exists(String path,
ProcessContext processContext)
Indicates if the given path exists or not.
|
protected Long |
getLastUpdateTimestampFor(String path)
Retrieves a timestamp that indicates the last time this nut has changed.
|
Boolean |
getRegularExpression()
Indicates if paths are a regular expression.
|
Boolean |
getWildcardExpression()
Indicates if paths are a wildcard expression.
|
List<String> |
listNutsPaths(String pattern)
Lists all the nuts path matching the given pattern.
|
InputStream |
newInputStream(String path,
ProcessContext processContext)
Opens the stream for the given path.
|
void |
save(Nut nut)
Saves the give nut.
|
Boolean |
saveSupported()
Indicates if this DAO is able to save a nut, which depends on the underlying protocol.
|
protected List<String> |
skipStartsWith()
Gets the beginning of path to be skipped during research.
|
String |
toString() |
absolutePathOf, computeRealPaths, create, create, getBasePath, getProxyUris, getVersionNumber, getVersionNumberStrategy, proxyUriFor, run, shutdown, withRootPath
getNutObservers, getPollingInterval, observe, setPollingInterval
public PathNutDao(String base, Boolean basePathAsSysProp, String[] proxies, int pollingSeconds, Boolean regex, Boolean wildcard, AbstractNutDao.VersionNumberStrategy versionNumberStrategy)
Builds a new instance with a base directory.
base
- the directory where we have to look upbasePathAsSysProp
- true
if the base path is a system propertypollingSeconds
- the interval for polling operations in seconds (-1 to deactivate)proxies
- the proxies URIs in front of the nutregex
- if the path should be considered as a regex or notwildcard
- if the path should be considered as a wildcard or notversionNumberStrategy
- the version number management strategypublic Boolean getRegularExpression()
Indicates if paths are a regular expression.
true
if regex is used, false
otherwisepublic Boolean getWildcardExpression()
Indicates if paths are a wildcard expression.
true
if wildcard is used, false
otherwiseprotected List<String> skipStartsWith()
Gets the beginning of path to be skipped during research. Should be overridden by subclass.
public List<String> listNutsPaths(String pattern) throws IOException
Lists all the nuts path matching the given pattern.
listNutsPaths
in class AbstractNutDao
pattern
- the patternIOException
- if any I/O error occurs while reading nutspublic Nut accessFor(String realPath, NutType type, ProcessContext processContext) throws IOException
Creates an access for the given parameters through a Nut
implementation.
accessFor
in class AbstractNutDao
realPath
- the real path to use to access the nuttype
- the path's typeprocessContext
- the process contextNut
IOException
- if an I/O error occurs while creating accessprotected Long getLastUpdateTimestampFor(String path) throws IOException
Retrieves a timestamp that indicates the last time this nut has changed.
getLastUpdateTimestampFor
in class PollingScheduler<NutDaoListener>
path
- the real path of the nutIOException
- if any I/O error occurspublic void save(Nut nut)
Saves the give nut. An UnsupportedOperationException
will be thrown if the implementation supports
only nut access.
save
in interface NutDao
save
in class AbstractNutDao
nut
- the nut to savepublic Boolean saveSupported()
Indicates if this DAO is able to save a nut, which depends on the underlying protocol.
saveSupported
in interface NutDao
saveSupported
in class AbstractNutDao
true
if NutDao.save(Nut)
is supported, false
otherwisepublic String toString()
toString
in class AbstractNutDao
public InputStream newInputStream(String path, ProcessContext processContext) throws IOException
Opens the stream for the given path.
path
- the path to accessprocessContext
- the process context calling this methodIOException
- if stream could not be openedpublic Boolean exists(String path, ProcessContext processContext) throws IOException
Indicates if the given path exists or not.
path
- the path the DAO should be able to resolveprocessContext
- the process context calling this methodtrue
if path is resolved, false
otherwiseIOException
- if any I/O error occursprotected abstract DirectoryPath createBaseDirectory() throws IOException
Creates the DirectoryPath
associated to the AbstractNutDao.basePath
.
DirectoryPath
IOException
- if any I/O error occursCopyright © 2012-2015. All Rights Reserved.