public class MemoryHashLoginInfoStore extends Object implements LoginInfoStore
LoginInfoStore that reads the information from the default file ".gfclient/pass"
and stores it as a map in the memory. It is not guaranteed that the concurrent
modifications will yield consistent results. This class is not thread safe. The
serial access has to be ensured by the callers.| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_STORE_NAME |
| Constructor and Description |
|---|
MemoryHashLoginInfoStore()
Creates a new instance of MemoryHashLoginInfoStore.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
exists(String host,
int port)
Checks whether a LoginInfo for given host and port exists in this store.
|
String |
getName()
Returns the name of the store.
|
Collection<LoginInfo> |
list()
A convenience method that returns the Collection of LoginInfo instances stored in this store.
|
LoginInfo |
read(String host,
int port)
Returns a
LoginInfo corresponding to the given host and port, from this store. |
void |
remove(String host,
int port)
Removes the
LoginInfo corresponding to the given host and port, from this store. |
int |
size()
A convenience method that returns the number of LoginInfo instances stored in this store.
|
void |
store(LoginInfo login)
Stores the given LoginInfo in this store.
|
void |
store(LoginInfo login,
boolean overwrite)
Stores the given LoginInfo in this store.
|
public static final String DEFAULT_STORE_NAME
public MemoryHashLoginInfoStore()
throws StoreException
StoreExceptionpublic void store(LoginInfo login) throws StoreException
LoginInfoStorestore in interface LoginInfoStorelogin - a LoginInfo that needs to be storedStoreException - if there's any problem or if there is already a LoginInfo
with given host and portpublic void store(LoginInfo login, boolean overwrite) throws StoreException
LoginInfoStorestore in interface LoginInfoStorelogin - a LoginInfo that needs to be storedStoreException - if there's any problem in storing or if overwrite is false and
the LoginInfo with given host and port already existspublic void remove(String host, int port)
LoginInfoStoreLoginInfo corresponding to the given host and port, from this store.
The host may not be null. If no such LoginInfo exists, StoreException results.
The caller thus must ensure if such a LoginInfo exists before calling this method.
Upon successful return, size of this store decreases by one.remove in interface LoginInfoStorehost - a non null String representing host nameport - an integer specifying the port numberpublic LoginInfo read(String host, int port)
LoginInfoStoreLoginInfo corresponding to the given host and port, from this store.
The host may not be null. For a given host and port, there can be at most
one LoginInfo in this store.read in interface LoginInfoStorehost - a non null String representing host nameport - an integer specifying the port numberpublic boolean exists(String host, int port)
LoginInfoStoreexists in interface LoginInfoStorehost - a non null String representing host nameport - an integer specifying the port numberpublic int size()
LoginInfoStoresize in interface LoginInfoStorepublic Collection<LoginInfo> list()
LoginInfoStorelist in interface LoginInfoStorepublic String getName()
LoginInfoStoregetName in interface LoginInfoStoreCopyright © 2017–2020 Eclipse Foundation. All rights reserved.