bibliothek.gui.dock
Interface DockFactory<D extends DockElement>

Type Parameters:
D - the type of element which can be written and read by this factory
All Known Implementing Classes:
DefaultDockableFactory, FlapDockStationFactory, PredefinedDockSituation.PreloadFactory, ScreenDockStationFactory, SecureFlapDockStationFactory, SecureScreenDockStationFactory, SplitDockStationFactory, StackDockStationFactory

public interface DockFactory<D extends DockElement>

A DockFactory has the ability to store and load instances of one subtype of DockElement.

Author:
Benjamin Sigg

Method Summary
 java.lang.String getID()
          Gets the unique name of this factory.
 D read(java.util.Map<java.lang.Integer,Dockable> children, boolean ignoreChildren, java.io.DataInputStream in)
          Reads a DockElement which was earlier stored by a DockFactoy of the same type.
 void read(java.util.Map<java.lang.Integer,Dockable> children, boolean ignoreChildren, D preloaded, java.io.DataInputStream in)
          Reads a DockElement which was earlier stored by a DockFactory of the same type.
 void write(D element, java.util.Map<Dockable,java.lang.Integer> children, java.io.DataOutputStream out)
          Saves the properties of a DockElement.
 

Method Detail

getID

java.lang.String getID()
Gets the unique name of this factory.

Returns:
the id

write

void write(D element,
           java.util.Map<Dockable,java.lang.Integer> children,
           java.io.DataOutputStream out)
           throws java.io.IOException
Saves the properties of a DockElement. If the element is a DockStation, then the factory has to store the location of the children. The factory can use the unique ids of the children which are stored in the map children. The factory don't have to store any information about the children itself.
If element is a Dockable, no information about the parent has to be stored.

Parameters:
element - the element to save
children - a list of unique names for each child of element, may be null if element is not a DockStation.
out - a stream to write information
Throws:
java.io.IOException - if the element can't be saved

read

D read(java.util.Map<java.lang.Integer,Dockable> children,
       boolean ignoreChildren,
       java.io.DataInputStream in)
                           throws java.io.IOException
Reads a DockElement which was earlier stored by a DockFactoy of the same type.

Parameters:
children - the known children of the element that is read. It's possible that not all children that were stored last time could be read again. In this case the map will contain no or a null entry.
ignoreChildren - true if the layout of the current children should not be changed. The map children is empty if ignoreChildren is true.
in - the stream to read from. The number of bytes read don't have to be the same number as the bytes that were written.
Returns:
the element that was read, null is a valid result and indicates that an element is no longer available.
Throws:
java.io.IOException - if the element can't be read from the stream

read

void read(java.util.Map<java.lang.Integer,Dockable> children,
          boolean ignoreChildren,
          D preloaded,
          java.io.DataInputStream in)
          throws java.io.IOException
Reads a DockElement which was earlier stored by a DockFactory of the same type. The contents have to be written into an already existing element.

Parameters:
children - the known children of the element that is read. It's possible that not all children that were stored last time could be read again. In this case the map will contain no or a null entry.
ignoreChildren - true if the layout of the current children should not be changed. The map children is empty if ignoreChildren is true.
preloaded - an element which was created elsewhere and now has to be set up correctly by this factory
in - the stream to read from. The number of bytes read don't have to be the same number as the bytes that were written.
Throws:
java.io.IOException - if the element can't be read from the stream