public class MemoryUserDatabase extends Object implements UserDatabase
Concrete implementation of UserDatabase
for an in-memory
database backed by an XML data file.
Constructor and Description |
---|
MemoryUserDatabase() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Finalize access to the underlying persistence layer.
|
User |
createUser(String username)
Create and return a new
User defined in this user database. |
User |
findUser(String username)
Return the existing
User with the specified username,
if any; otherwise return null . |
User[] |
findUsers()
Return the set of
User s defined in this user database. |
String |
getPathname() |
boolean |
isOpen()
Return true if open() has been called.
|
void |
open()
Initiate access to the underlying persistence layer.
|
void |
removeUser(User user)
Remove the specified
User from this database. |
void |
save()
Save any pending changes to the underlying persistence layer.
|
void |
setPathname(String pathname) |
public String getPathname()
public void setPathname(String pathname)
public void close() throws Exception
UserDatabase
Finalize access to the underlying persistence layer.
close
in interface UserDatabase
Exception
- if a database access error occurspublic User createUser(String username)
UserDatabase
Create and return a new User
defined in this user database.
createUser
in interface UserDatabase
username
- Username of the new userpublic User findUser(String username)
UserDatabase
Return the existing User
with the specified username,
if any; otherwise return null
.
findUser
in interface UserDatabase
username
- Username of the user to retrievepublic User[] findUsers()
UserDatabase
Return the set of User
s defined in this user database.
findUsers
in interface UserDatabase
public void open() throws Exception
UserDatabase
Initiate access to the underlying persistence layer.
open
in interface UserDatabase
Exception
- if a database access error occurspublic void removeUser(User user)
UserDatabase
User
from this database.removeUser
in interface UserDatabase
user
- User to be removedpublic void save() throws Exception
UserDatabase
Save any pending changes to the underlying persistence layer.
save
in interface UserDatabase
Exception
- if a database access error occurspublic boolean isOpen()
UserDatabase
Return true if open() has been called.
isOpen
in interface UserDatabase
Copyright © 2000–2017 Apache Software Foundation. All rights reserved.