public interface NutDao
This interface abstracts the way you can read and eventually save nuts through a particular protocol.
Modifier and Type | Interface and Description |
---|---|
static class |
NutDao.PathFormat
This enumeration specifies formats of path specified to create
nuts . |
Modifier and Type | Method and Description |
---|---|
List<Nut> |
create(String path,
NutDao.PathFormat format,
ProcessContext processContext)
Creates a list of
nuts thanks to the given path. |
List<Nut> |
create(String path,
ProcessContext processContext)
Creates a list of
nuts thanks to the given path considered as represented in any format. |
Boolean |
exists(String path,
ProcessContext processContext)
Indicates if the given path exists or not.
|
InputStream |
newInputStream(String path,
ProcessContext processContext)
Opens the stream for the given path.
|
void |
observe(String realPath,
NutDaoListener... listeners)
Adds a set of
listeners to be notified when an update has been detected on the nut. |
String |
proxyUriFor(Nut nut)
Returns an URI in a
String representation of a proxy serving the given nut. |
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.
|
void |
shutdown()
Shutdowns this DAO by releasing its resources.
|
NutDao |
withRootPath(String rootPath)
Returns an instance that prefixes any nut name to be created with the given root path.
|
void observe(String realPath, NutDaoListener... listeners) throws IOException
Adds a set of listeners
to be notified when an update has been detected on the nut.
The targeted nut is represented by the specified path.
The listeners will be stored in a weak reference so if no strong reference to them exist, they will be garbage collected.
realPath
- the real path name of the nut.listeners
- some listeners to be notified when an update has been detected on a nutIOException
- if an I/O occurs while retrieving last update of the nutList<Nut> create(String path, ProcessContext processContext) throws IOException
Creates a list of nuts
thanks to the given path considered as represented in any format.
path
- the path representing the location of the nut(s)processContext
- the process context calling this methodIOException
- if an I/O error occurs when creating the nutcreate(String, com.github.wuic.nut.dao.NutDao.PathFormat, com.github.wuic.ProcessContext)
List<Nut> create(String path, NutDao.PathFormat format, ProcessContext processContext) throws IOException
Creates a list of nuts
thanks to the given path.
A NutDao.PathFormat
also gives information on the format used in the string representation of the given path.
path
- the path representing the location of the nut(s)format
- the path formatprocessContext
- the process context calling this methodIOException
- if an I/O error occurs when creating the nutString proxyUriFor(Nut nut)
Returns an URI in a String
representation of a proxy serving the given nut.
If many proxies are defined, proxy URI is selected in a round-robin mode. Each time a proxy is used, it won't be reused until all other proxies have been used too.
nut
- the nutnull
if not proxy is setvoid save(Nut nut)
Saves the give nut. An UnsupportedOperationException
will be thrown if the implementation supports
only nut access.
nut
- the nut to saveBoolean saveSupported()
Indicates if this DAO is able to save a nut, which depends on the underlying protocol.
true
if save(Nut)
is supported, false
otherwisevoid shutdown()
Shutdowns this DAO by releasing its resources.
NutDao withRootPath(String rootPath)
Returns an instance that prefixes any nut name to be created with the given root path.
rootPath
- the root pathInputStream 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 openedBoolean 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 occursCopyright © 2012-2015. All Rights Reserved.