public class DefaultFrontendPerspectiveCache extends java.lang.Object implements FrontendPerspectiveCache
FrontendPerspectiveCache
assumes that the information clients
gave to a DockFrontend
is enough and use only the default PerspectiveElement
s. This cache
handles only the default implementation of the DockStation
s and of DefaultDockable
. Using any
other DockElement
will result in exceptions.DefaultDockable
s are represented by FrontendDockablePerspective
s.PerspectiveElement
that were ever created are stored in a cache. Clients should make sure to
use a new cache every time the access a Perspective
, this way the old cache can be cleaned up by the
garbage collector.Dockable
s is read from the DockFrontend
, this cache has no way
to know the identifiers of unregistered elements. These elements will be ignored and thrown away when reading the layout.Modifier and Type | Field and Description |
---|---|
static Path |
CACHE_EXTENSION
Unique identifier to load extensions of type
FrontendPerspectiveCacheExtension |
Constructor and Description |
---|
DefaultFrontendPerspectiveCache(DockFrontend frontend)
Creates a new cache
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
get(PerspectiveElement element)
Gets the unique identifier of
element . |
PerspectiveElement |
get(java.lang.String id,
boolean rootStation)
Called to convert
id to a PerspectiveElement . |
PerspectiveElement |
get(java.lang.String id,
DockElement element,
boolean isRootStation)
Given an
element that was earlier created by the client and added to a
DockFrontend , this method converts element to a PerspectiveElement .When called multiple times with the same arguments, then this method is free to either return different objects or to always return the same object. |
boolean |
isRootStation(PerspectiveStation station)
Tells whether
station is supposed to be a root-station. |
protected void |
put(PerspectiveElement element,
java.lang.String id)
Makes an association that the identifier
id is used for element . |
public static final Path CACHE_EXTENSION
FrontendPerspectiveCacheExtension
public DefaultFrontendPerspectiveCache(DockFrontend frontend)
frontend
- the frontend to query for information about DockElement
s.public PerspectiveElement get(java.lang.String id, DockElement element, boolean isRootStation)
FrontendPerspectiveCache
element
that was earlier created by the client and added to a
DockFrontend
, this method converts element
to a PerspectiveElement
.get
in interface FrontendPerspectiveCache
id
- the unique identifier under which element
is known to the DockFrontend
element
- the element whose perspective must be createdisRootStation
- whether element
is registered as root-station at the DockFrontend
or as Dockable
null
protected void put(PerspectiveElement element, java.lang.String id)
id
is used for element
.element
- the element whose identifier is stored, not null
id
- the identifier to store, not null
public PerspectiveElement get(java.lang.String id, boolean rootStation)
FrontendPerspectiveCache
id
to a PerspectiveElement
. This method will only be called
with identifiers that were not used for FrontendPerspectiveCache.get(String, DockElement, boolean)
.get
in interface FrontendPerspectiveCache
id
- the identifier of some elementrootStation
- whether id
represents a root-station or notnull
public java.lang.String get(PerspectiveElement element)
FrontendPerspectiveCache
element
.get
in interface FrontendPerspectiveCache
element
- some element, can be either a dockable or a root-stationnull
if this cache is unable to associate element
with an identifier. Should not be null
for elements that were created by
FrontendPerspectiveCache.get(String, boolean)
or FrontendPerspectiveCache.get(String, DockElement, boolean)
.public boolean isRootStation(PerspectiveStation station)
FrontendPerspectiveCache
station
is supposed to be a root-station.isRootStation
in interface FrontendPerspectiveCache
station
- the element which may be a root-stationtrue
if station
should be treated as root-station