bibliothek.gui.dock.layout
Class PropertyTransformer

java.lang.Object
  extended by bibliothek.gui.dock.layout.PropertyTransformer

public class PropertyTransformer
extends Object

A PropertTransformer can read and write instances of DockableProperty , assuming that a factory is installed for the property.

Author:
Benjamin Sigg

Constructor Summary
PropertyTransformer()
          Creates a new transformer, the factories for all DockablePropertys implemented by this framework are installed.
PropertyTransformer(DockablePropertyFactory... factories)
          Creates a new transformer and installs factories.
 
Method Summary
 void addFactory(DockablePropertyFactory factory)
          Installs a factory
 DockableProperty read(DataInputStream in)
          Reads a property which was earlier stored.
 DockableProperty readXML(XElement element)
          Reads a DockableProperty and its successors from an xml element.
 void write(DockableProperty property, DataOutputStream out)
          Writes property and all its successors into out .
 void writeXML(DockableProperty property, XElement element)
          Writes property and all its successors into element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyTransformer

public PropertyTransformer()
Creates a new transformer, the factories for all DockablePropertys implemented by this framework are installed.


PropertyTransformer

public PropertyTransformer(DockablePropertyFactory... factories)
Creates a new transformer and installs factories.

Parameters:
factories - a list of factories to install
Method Detail

addFactory

public void addFactory(DockablePropertyFactory factory)
Installs a factory

Parameters:
factory - the new factory

write

public void write(DockableProperty property,
                  DataOutputStream out)
           throws IOException
Writes property and all its successors into out .

Parameters:
property - the property to write
out - a stream to write into
Throws:
IOException - if the stream throws an exception

read

public DockableProperty read(DataInputStream in)
                      throws IOException
Reads a property which was earlier stored. If the property had any successors, then they are read as well.

Parameters:
in - a stream to read from
Returns:
the properties
Throws:
IOException - if the property can't be read

writeXML

public void writeXML(DockableProperty property,
                     XElement element)
Writes property and all its successors into element.

Parameters:
property - the property to write
element - an xml element to which this method will add some children

readXML

public DockableProperty readXML(XElement element)
Reads a DockableProperty and its successors from an xml element.

Parameters:
element - the element to read from
Returns:
the property or null if element is empty
Throws:
IllegalArgumentException - if a DockablePropertyFactory is missing.