org.eclipse.core.internal.watson
Class ElementTreeWriter

java.lang.Object
  extended by org.eclipse.core.internal.watson.ElementTreeWriter

public class ElementTreeWriter
extends java.lang.Object

ElementTreeWriter flattens an ElementTree onto a data output stream.

This writer generates the most up-to-date format of a saved element tree (cf. readers, which must usually also deal with backward compatibility issues). The flattened representation always includes a format version number.

The writer has an IElementInfoFactory, which it consults for writing element infos.

Element tree writers are thread-safe; several threads may share a single writer.


Field Summary
static int CURRENT_FORMAT
          The current format version number.
static int D_INFINITE
          Constant representing infinite depth
 
Constructor Summary
ElementTreeWriter(IElementInfoFlattener flattener)
          Constructs a new element tree writer that works for the given element info flattener.
 
Method Summary
 void writeDelta(ElementTree olderTree, ElementTree newerTree, org.eclipse.core.runtime.IPath path, int depth, java.io.DataOutput output, IElementComparator comparator)
          Writes the delta describing the changes that have to be made to newerTree to obtain olderTree.
 void writeDeltaChain(ElementTree[] trees, org.eclipse.core.runtime.IPath path, int depth, java.io.DataOutput output, IElementComparator comparator)
          Writes an array of ElementTrees to the given output stream.
 void writeTree(ElementTree tree, org.eclipse.core.runtime.IPath path, int depth, java.io.DataOutput output)
          Writes all or some of an element tree to an output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_FORMAT

public static final int CURRENT_FORMAT
The current format version number.

See Also:
Constant Field Values

D_INFINITE

public static final int D_INFINITE
Constant representing infinite depth

See Also:
Constant Field Values
Constructor Detail

ElementTreeWriter

public ElementTreeWriter(IElementInfoFlattener flattener)
Constructs a new element tree writer that works for the given element info flattener.

Method Detail

writeDelta

public void writeDelta(ElementTree olderTree,
                       ElementTree newerTree,
                       org.eclipse.core.runtime.IPath path,
                       int depth,
                       java.io.DataOutput output,
                       IElementComparator comparator)
                throws java.io.IOException
Writes the delta describing the changes that have to be made to newerTree to obtain olderTree.

Parameters:
path - The path of the subtree to write. All nodes on the path above the subtree are represented as empty nodes.
depth - The depth of the subtree to write. A depth of zero writes a single node, and a depth of D_INFINITE writes the whole subtree.
output - The stream to write the subtree to.
Throws:
java.io.IOException

writeDeltaChain

public void writeDeltaChain(ElementTree[] trees,
                            org.eclipse.core.runtime.IPath path,
                            int depth,
                            java.io.DataOutput output,
                            IElementComparator comparator)
                     throws java.io.IOException
Writes an array of ElementTrees to the given output stream.

Parameters:
trees - A chain of ElementTrees, where on tree in the list is complete, and all other trees are deltas on the previous tree in the list.
path - The path of the subtree to write. All nodes on the path above the subtree are represented as empty nodes.
depth - The depth of the subtree to write. A depth of zero writes a single node, and a depth of D_INFINITE writes the whole subtree.
output - The stream to write the subtree to.
Throws:
java.io.IOException

writeTree

public void writeTree(ElementTree tree,
                      org.eclipse.core.runtime.IPath path,
                      int depth,
                      java.io.DataOutput output)
               throws java.io.IOException
Writes all or some of an element tree to an output stream. This always writes the most current version of the element tree file format, whereas the reader supports multiple versions.

Parameters:
tree - The tree to write
path - The path of the subtree to write. All nodes on the path above the subtree are represented as empty nodes.
depth - The depth of the subtree to write. A depth of zero writes a single node, and a depth of D_INFINITE writes the whole subtree.
output - The stream to write the subtree to.
Throws:
java.io.IOException