Search in sources :

Example 1 with Stream

use of org.apache.poi.hdgf.streams.Stream in project poi by apache.

the class HDGFFileHandler method handleFile.

@Override
public void handleFile(InputStream stream, String path) throws IOException {
    POIFSFileSystem poifs = new POIFSFileSystem(stream);
    HDGFDiagram diagram = new HDGFDiagram(poifs);
    Stream[] topLevelStreams = diagram.getTopLevelStreams();
    assertNotNull(topLevelStreams);
    for (Stream str : topLevelStreams) {
        assertTrue(str.getPointer().getLength() >= 0);
    }
    TrailerStream trailerStream = diagram.getTrailerStream();
    assertNotNull(trailerStream);
    assertTrue(trailerStream.getPointer().getLength() >= 0);
    diagram.close();
    poifs.close();
// writing is not yet implemented... handlePOIDocument(diagram);
}
Also used : TrailerStream(org.apache.poi.hdgf.streams.TrailerStream) HDGFDiagram(org.apache.poi.hdgf.HDGFDiagram) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) FileInputStream(java.io.FileInputStream) Stream(org.apache.poi.hdgf.streams.Stream) TrailerStream(org.apache.poi.hdgf.streams.TrailerStream) InputStream(java.io.InputStream)

Example 2 with Stream

use of org.apache.poi.hdgf.streams.Stream in project poi by apache.

the class HDGFDiagram method debug.

/**
	 * Prints out some simple debug on the base contents of the file.
	 * @see org.apache.poi.hdgf.dev.VSDDumper
	 */
public void debug() {
    System.err.println("Trailer is at " + trailerPointer.getOffset());
    System.err.println("Trailer has type " + trailerPointer.getType());
    System.err.println("Trailer has length " + trailerPointer.getLength());
    System.err.println("Trailer has format " + trailerPointer.getFormat());
    for (int i = 0; i < trailer.getPointedToStreams().length; i++) {
        Stream stream = trailer.getPointedToStreams()[i];
        Pointer ptr = stream.getPointer();
        System.err.println("Looking at pointer " + i);
        System.err.println("\tType is " + ptr.getType() + "\t\t" + Integer.toHexString(ptr.getType()));
        System.err.println("\tOffset is " + ptr.getOffset() + "\t\t" + Long.toHexString(ptr.getOffset()));
        System.err.println("\tAddress is " + ptr.getAddress() + "\t" + Long.toHexString(ptr.getAddress()));
        System.err.println("\tLength is " + ptr.getLength() + "\t\t" + Long.toHexString(ptr.getLength()));
        System.err.println("\tFormat is " + ptr.getFormat() + "\t\t" + Long.toHexString(ptr.getFormat()));
        System.err.println("\tCompressed is " + ptr.destinationCompressed());
        System.err.println("\tStream is " + stream.getClass());
        if (stream instanceof PointerContainingStream) {
            PointerContainingStream pcs = (PointerContainingStream) stream;
            if (pcs.getPointedToStreams() != null && pcs.getPointedToStreams().length > 0) {
                System.err.println("\tContains " + pcs.getPointedToStreams().length + " other pointers/streams");
                for (int j = 0; j < pcs.getPointedToStreams().length; j++) {
                    Stream ss = pcs.getPointedToStreams()[j];
                    Pointer sptr = ss.getPointer();
                    System.err.println("\t\t" + j + " - Type is " + sptr.getType() + "\t\t" + Integer.toHexString(sptr.getType()));
                    System.err.println("\t\t" + j + " - Length is " + sptr.getLength() + "\t\t" + Long.toHexString(sptr.getLength()));
                }
            }
        }
        if (stream instanceof StringsStream) {
            System.err.println("\t\t**strings**");
            StringsStream ss = (StringsStream) stream;
            System.err.println("\t\t" + ss._getContentsLength());
        }
    }
}
Also used : TrailerStream(org.apache.poi.hdgf.streams.TrailerStream) PointerContainingStream(org.apache.poi.hdgf.streams.PointerContainingStream) StringsStream(org.apache.poi.hdgf.streams.StringsStream) Stream(org.apache.poi.hdgf.streams.Stream) InputStream(java.io.InputStream) Pointer(org.apache.poi.hdgf.pointers.Pointer) StringsStream(org.apache.poi.hdgf.streams.StringsStream) PointerContainingStream(org.apache.poi.hdgf.streams.PointerContainingStream)

Example 3 with Stream

use of org.apache.poi.hdgf.streams.Stream in project poi by apache.

the class VSDDumper method dumpStream.

private void dumpStream(Stream stream, int indent) {
    Pointer ptr = stream.getPointer();
    dumpVal("Stream at", ptr.getOffset(), indent);
    dumpVal("Type is", ptr.getType(), indent + 1);
    dumpVal("Format is", ptr.getFormat(), indent + 1);
    dumpVal("Length is", ptr.getLength(), indent + 1);
    if (ptr.destinationCompressed()) {
        dumpVal("DC.Length is", stream._getContentsLength(), indent + 1);
    }
    dumpVal("Compressed is", ptr.destinationCompressed(), indent + 1);
    dumpVal("Stream is", stream.getClass().getName(), indent + 1);
    byte[] db = stream._getStore()._getContents();
    String ds = (db.length >= 8) ? Arrays.toString(db) : "[]";
    dumpVal("First few bytes are", ds, indent + 1);
    if (stream instanceof PointerContainingStream) {
        Stream[] streams = ((PointerContainingStream) stream).getPointedToStreams();
        dumpVal("Nbr of children", streams.length, indent + 1);
        for (Stream s : streams) {
            dumpStream(s, indent + 1);
        }
    }
    if (stream instanceof ChunkStream) {
        Chunk[] chunks = ((ChunkStream) stream).getChunks();
        dumpVal("Nbr of chunks", chunks.length, indent + 1);
        for (Chunk chunk : chunks) {
            dumpChunk(chunk, indent + 1);
        }
    }
}
Also used : ChunkStream(org.apache.poi.hdgf.streams.ChunkStream) Pointer(org.apache.poi.hdgf.pointers.Pointer) PrintStream(java.io.PrintStream) PointerContainingStream(org.apache.poi.hdgf.streams.PointerContainingStream) ChunkStream(org.apache.poi.hdgf.streams.ChunkStream) Stream(org.apache.poi.hdgf.streams.Stream) PointerContainingStream(org.apache.poi.hdgf.streams.PointerContainingStream) Chunk(org.apache.poi.hdgf.chunks.Chunk)

Aggregations

Stream (org.apache.poi.hdgf.streams.Stream)3 InputStream (java.io.InputStream)2 Pointer (org.apache.poi.hdgf.pointers.Pointer)2 PointerContainingStream (org.apache.poi.hdgf.streams.PointerContainingStream)2 TrailerStream (org.apache.poi.hdgf.streams.TrailerStream)2 FileInputStream (java.io.FileInputStream)1 PrintStream (java.io.PrintStream)1 HDGFDiagram (org.apache.poi.hdgf.HDGFDiagram)1 Chunk (org.apache.poi.hdgf.chunks.Chunk)1 ChunkStream (org.apache.poi.hdgf.streams.ChunkStream)1 StringsStream (org.apache.poi.hdgf.streams.StringsStream)1 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)1