FileDocCategorySizeDatePackage
PointerContainingStream.javaAPI DocApache Poi 3.0.13702Tue Jun 19 23:30:00 BST 2007org.apache.poi.hdgf.streams

PointerContainingStream

public class PointerContainingStream extends Stream
A stream that holds pointers, possibly in addition to some other data too.

Fields Summary
private Pointer[]
childPointers
private Stream[]
childStreams
private ChunkFactory
chunkFactory
private PointerFactory
pointerFactory
private int
numPointersLocalOffset
Constructors Summary
protected PointerContainingStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory, PointerFactory pointerFactory)

		super(pointer, store);
		this.chunkFactory = chunkFactory;
		this.pointerFactory = pointerFactory;
		
		// Find the offset to the number of child pointers we have
		// This ought to be the first thing stored in us
		numPointersLocalOffset = (int)LittleEndian.getUInt(
				store.getContents(), 0
		);
		
		// Generate the objects for the pointers we contain
		int numPointers = (int)LittleEndian.getUInt(
				store.getContents(), numPointersLocalOffset
		);
		childPointers = new Pointer[numPointers];
		
		// After the number of pointers is another (unknown)
		//  4 byte value
		int pos = numPointersLocalOffset + 4 + 4;
		
		// Now create the pointer objects
		for(int i=0; i<numPointers; i++) {
			childPointers[i] = pointerFactory.createPointer(
					store.getContents(), pos
			);
			pos += childPointers[i].getSizeInBytes();
		}
	
Methods Summary
public voidfindChildren(byte[] documentData)
Performs a recursive search, identifying the pointers we contain, creating the Streams for where they point to, then searching those if appropriate.

		// For each pointer, generate the Stream it points to
		childStreams = new Stream[childPointers.length];
		for(int i=0; i<childPointers.length; i++) {
			Pointer ptr = childPointers[i];
			childStreams[i] = Stream.createStream(ptr, documentData, chunkFactory, pointerFactory);
			
			// Process chunk streams into their chunks
			if(childStreams[i] instanceof ChunkStream) {
				ChunkStream child = (ChunkStream)childStreams[i];
				child.findChunks();
			}
			
			// Recurse into pointer containing streams
			if(childStreams[i] instanceof PointerContainingStream) {
				PointerContainingStream child = 
					(PointerContainingStream)childStreams[i];
				child.findChildren(documentData);
			}
		}
	
protected org.apache.poi.hdgf.pointers.Pointer[]getChildPointers()
Returns all the pointers that we contain

 return childPointers; 
public org.apache.poi.hdgf.streams.Stream[]getPointedToStreams()
Returns all the "child" streams. These are all the streams pointed to by the pointers that we contain.

 return childStreams;