public interface Database<D extends Database<D,G,E,I>,G extends Group<D,G,E,I>,E extends Entry<D,G,E,I>,I extends Icon>
A database is a factory for new Groups and Entries. Groups and entries belonging
to one database cannot in general be added to another database, they need to be
imported using newGroup(Group)
and newEntry(Entry)
, or implicitly
imported using Group.addGroup(Group)
which automatically create Groups and
Entries (as well as importing subgroups and their entries). Group.addEntry(Entry)
allows arbitrary importing from other databases.
Databases may be navigated directly from the root getRootGroup()
,
or using a Visitor
and visit(Visitor)
or visit(Group, Visitor)
to start the visit at a particular group.
A list of entries that match a string or some custom criteria may be obtained using
the findEntries(Entry.Matcher)
and findEntries(String)
methods.
To match (optionally recursively) entries in a Group
use
Group.findEntries(String, boolean)
or Group.findEntries(Entry.Matcher, boolean)
.
All Lists provided returned by methods of all interfaces may be modified by the caller without affecting the underlying database structure, however changes to the Groups and Entries contained in the lists do modify the database.
Modifier and Type | Method and Description |
---|---|
boolean |
deleteEntry(UUID uuid)
Delete an entry with this UUID from anywhere in the database except the recycle bin
if recycle is enabled then the entry is moved to the recycle bin
|
boolean |
deleteGroup(UUID uuid)
Delete a group with this UUID from anywhere in the database except the recycle bin
if recycle is enabled then the group is moved to the recycle bin
|
void |
emptyRecycleBin()
empty the recycle bin whether it is enabled or disabled
|
void |
enableRecycleBin(boolean enable)
change the recycle bin state
|
List<? extends E> |
findEntries(Entry.Matcher matcher)
Find all entries that match the criteria
|
List<? extends E> |
findEntries(String find)
Find all entries that match
Entry.match(String) |
E |
findEntry(UUID uuid)
Find an entry with this UUID anywhere in the database except the recycle bin
|
G |
findGroup(UUID uuid)
Find a group with this UUID anywhere in the database except the recycle bin
|
String |
getDescription()
Gets the database description, if there is one
|
String |
getName()
Gets the name of the database or null if not supported
|
PropertyValue.Strategy |
getPropertyValueStrategy()
Get the default means of storage of unprotected and protected property values
|
G |
getRecycleBin()
If the recycle bin is enabled (or it's disabled but there is a pre-existing
recycle bin), then return the recycle bin, creating one if necessary.
|
G |
getRootGroup()
get the root group for the database
|
<C extends StreamConfiguration> |
getStreamFormat()
Get the format the database was loaded from
|
boolean |
isDirty()
True if database been modified
|
boolean |
isRecycleBinEnabled()
if a database has a recycle bin then it is enabled by default
|
List<String> |
listShouldProtect()
Obtain a list of those properties that should be protected by default
|
E |
newEntry()
Create a new Entry
|
E |
newEntry(Entry<?,?,?,?> entry)
Create a new Entry copying the details of the supplied entry
|
E |
newEntry(String title)
Create a new Entry with a title
|
G |
newGroup()
Create a new Group
|
G |
newGroup(Group<?,?,?,?> group)
Create a new Group copying the details of the supplied group, but not copying its children
|
G |
newGroup(String name)
Create a new named Group
|
I |
newIcon()
Create a new default icon
|
I |
newIcon(Integer i)
Create a new icon with a specified index
|
void |
save(Credentials credentials,
OutputStream outputStream)
Save the database to a stream using default format
|
<C extends StreamConfiguration> |
save(StreamFormat<C> streamFormat,
Credentials credentials,
OutputStream outputStream)
Save the database to a stream
|
void |
setDescription(String description)
Sets the database description if it is supported
|
void |
setName(String name)
Set the name of the database if this is supported
|
void |
setPropertyValueStrategy(PropertyValue.Strategy propertyValueStrategy)
Set the default means of storage of unprotected and protected property values
|
void |
setShouldProtect(String propertyName,
boolean protect)
Property to protect in memory
|
boolean |
shouldProtect(String propertyName)
Property to protect in memory
|
boolean |
supportsBinaryProperties()
returns true if the database supports binary properties
|
boolean |
supportsNonStandardPropertyNames()
returns true if the database supports non-standard property names
|
boolean |
supportsPropertyValueStrategy()
returns true if the implementation supports a PropertyValueStrategy
|
boolean |
supportsRecycleBin()
returns true if the database supports recycle bin
|
void |
visit(G group,
Visitor<D,G,E,I> visitor)
Visit all entries starting from a group
|
void |
visit(Visitor<D,G,E,I> visitor)
Visit all entries
|
G getRootGroup()
G newGroup()
G newGroup(String name)
name
- the name of the groupG newGroup(Group<?,?,?,?> group)
Used for copying a group from one database to another
group
- the group to copyE newEntry()
E newEntry(Entry<?,?,?,?> entry)
Used for copying an entry from one database to another
entry
- the entry to copyI newIcon()
I newIcon(Integer i)
i
- the index of the icon to create@Nullable E findEntry(UUID uuid)
uuid
- the UUIDboolean deleteEntry(UUID uuid)
uuid
- the UUID@Nullable G findGroup(UUID uuid)
uuid
- the UUIDboolean deleteGroup(UUID uuid)
uuid
- the UUIDboolean isRecycleBinEnabled()
void enableRecycleBin(boolean enable)
UnsupportedOperationException
- if recycle bin functions are not supportedsupportsRecycleBin()
@Nullable G getRecycleBin()
supportsRecycleBin()
void emptyRecycleBin()
UnsupportedOperationException
- if recycle bin functions are not supportedsupportsRecycleBin()
void visit(Visitor<D,G,E,I> visitor)
visitor
- the visitor to usevoid visit(G group, Visitor<D,G,E,I> visitor)
group
- the group to start atvisitor
- the visitor to useList<? extends E> findEntries(Entry.Matcher matcher)
matcher
- the matcher to useList<? extends E> findEntries(String find)
Entry.match(String)
find
- string to findString getName()
void setName(String name)
name
- the nameString getDescription()
void setDescription(String description)
description
- a description of the databaseboolean isDirty()
void save(Credentials credentials, OutputStream outputStream) throws IOException
IOException
<C extends StreamConfiguration> void save(StreamFormat<C> streamFormat, Credentials credentials, OutputStream outputStream) throws IOException
IOException
<C extends StreamConfiguration> StreamFormat<C> getStreamFormat()
boolean shouldProtect(String propertyName)
propertyName
- the property of interestvoid setShouldProtect(String propertyName, boolean protect)
propertyName
- the property of interestprotect
- whether to protect by defaultList<String> listShouldProtect()
PropertyValue.Strategy getPropertyValueStrategy()
void setPropertyValueStrategy(PropertyValue.Strategy propertyValueStrategy)
propertyValueStrategy
- a propertyValue strategyboolean supportsNonStandardPropertyNames()
boolean supportsBinaryProperties()
boolean supportsRecycleBin()
boolean supportsPropertyValueStrategy()
Copyright © 2025. All rights reserved.