|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbibliothek.gui.dock.DockSituation
public class DockSituation
A DockSituation is a converter: the relationship of
DockStations
and Dockables
,
the position of Dockables and other information are converted into a
stream of bytes. The other direction, read a stream
and create Dockables and DockStations, is also possible.
Field Summary | |
---|---|
private java.util.Map<java.lang.String,DockFactory<?>> |
factories
the factories used to create new elements |
private DockSituationIgnore |
ignore
a filter for elements which should be ignored |
Constructor Summary | |
---|---|
DockSituation()
Constructs a new DockSituation. |
|
DockSituation(DockFactory<?>... factories)
Constructs a new DockSituation and sets some factories which are used to create new DockElements |
Method Summary | |
---|---|
void |
add(DockFactory<?> factory)
Adds a factory |
protected DockFactory<? extends DockElement> |
getFactory(java.lang.String id)
Gets the factory which has the given id . |
protected java.lang.String |
getID(DockElement dockable)
Gets the id of the factory which is needed to write (and later read) the element dockable . |
protected java.lang.String |
getID(DockFactory<?> factory)
Gets the id of factory . |
DockSituationIgnore |
getIgnore()
Gets the filter which decides, which elements are stored. |
protected boolean |
ignoreChildren(DockStation station)
Tells whether to ignore the children of the station when saving or not. |
protected boolean |
ignoreElement(DockElement element)
Tells whether to ignore this element when saving. |
java.util.Map<java.lang.String,DockStation> |
read(byte[] data)
Reads data as stream and returns the roots of the
DockElements which were found. |
java.util.Map<java.lang.String,DockStation> |
read(java.io.DataInputStream in)
Reads in and returns the roots of the
DockElements which were found. |
private java.util.Map<java.lang.Integer,Dockable> |
readDockables(java.io.DataInputStream in)
Reads the next list of Dockables . |
private DockElement |
readElement(java.io.DataInputStream in)
Reads the contents of one DockElement . |
void |
setIgnore(DockSituationIgnore ignore)
Sets a filter which decides, which elements (stations and dockables) are stored. |
byte[] |
write(java.util.Map<java.lang.String,DockStation> stations)
Writes all locations and relationships of the DockStations
stations and their children into an array of bytes. |
void |
write(java.util.Map<java.lang.String,DockStation> stations,
java.io.DataOutputStream out)
Writes all locations and relationships of the DockStations
stations and their children into the stream out . |
private void |
writeElement(DockElement element,
java.io.DataOutputStream out)
Writes the contents of element into out . |
private java.util.Map<Dockable,java.lang.Integer> |
writeStation(DockStation station,
boolean ignoreChildren,
java.io.DataOutputStream out)
Writes the children of station and returns a map which
contains all children and a unique id for each child. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map<java.lang.String,DockFactory<?>> factories
elements
private DockSituationIgnore ignore
Constructor Detail |
---|
public DockSituation(DockFactory<?>... factories)
DockElements
factories
- the factoriespublic DockSituation()
DefaultDockable
,
SplitDockStation
, StackDockStation
and
FlapDockStation
will be preinstalled.
Method Detail |
---|
public void setIgnore(DockSituationIgnore ignore)
ignore
- the filter or null
public DockSituationIgnore getIgnore()
null
public void add(DockFactory<?> factory)
factory
- the additional factorypublic byte[] write(java.util.Map<java.lang.String,DockStation> stations) throws java.io.IOException
DockStations
stations
and their children into an array of bytes.
stations
- The stations to store, a call to read(byte[])
would return the same map. Only the roots are needed.
java.io.IOException
- if the information can't be writtenpublic void write(java.util.Map<java.lang.String,DockStation> stations, java.io.DataOutputStream out) throws java.io.IOException
DockStations
stations
and their children into the stream out
.
stations
- The stations to store, only the roots are needed.out
- the stream to write in
java.io.IOException
- if the stream throws an exceptionprivate java.util.Map<Dockable,java.lang.Integer> writeStation(DockStation station, boolean ignoreChildren, java.io.DataOutputStream out) throws java.io.IOException
station
and returns a map which
contains all children and a unique id for each child.
station
- the station whose children are writtenignoreChildren
- true
if no information about the
children should be saved.out
- the stream to write into
station
java.io.IOException
- if the stream throws an exceptionprivate void writeElement(DockElement element, java.io.DataOutputStream out) throws java.io.IOException
element
into out
.
element
- the element to storeout
- the stream to write into
java.io.IOException
- if the stream throws an exception or the
element
can't be convertedpublic java.util.Map<java.lang.String,DockStation> read(byte[] data) throws java.io.IOException
data
as stream and returns the roots of the
DockElements
which were found.
data
- the array to read
java.io.IOException
- if data
can't be readpublic java.util.Map<java.lang.String,DockStation> read(java.io.DataInputStream in) throws java.io.IOException
in
and returns the roots of the
DockElements
which were found.
in
- the stream to read
java.io.IOException
- if the stream can't be readprivate DockElement readElement(java.io.DataInputStream in) throws java.io.IOException
DockElement
. Note if there
is a DockFactory
missing, null
will be returned.
in
- the stream to read
null
java.io.IOException
- if the element can't be read because of a
malfunction of in
private java.util.Map<java.lang.Integer,Dockable> readDockables(java.io.DataInputStream in) throws java.io.IOException
Dockables
.
in
- the stream to read
Dockable
java.io.IOException
- if the stream throws an exceptionprotected boolean ignoreElement(DockElement element)
DockSituationIgnore
of this situation.
element
- the element which might not be saved
true
if the element should not be savedprotected boolean ignoreChildren(DockStation station)
DockSituationIgnore
of this situation.
station
- the station whose children might be ignored
true
if the station is saved as having no childrenprotected java.lang.String getID(DockElement dockable)
dockable
.
dockable
- the dockable to write
getID(DockFactory)
,
getFactory(String)
protected java.lang.String getID(DockFactory<?> factory)
factory
. The default behavior is just to
return DockFactory.getID()
. Note that this method should be
a bijection to getFactory(String)
.
factory
- the factory whose id is needed
protected DockFactory<? extends DockElement> getFactory(java.lang.String id)
id
. Note that this
method should be a bijection to getID(DockFactory)
. The
default behavior compares id
with the
getID(DockFactory)
.
id
- the name of the factory
null
if no factory has this id
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |