Package com.twelvemonkeys.io.ole2
Class CompoundDocument
- java.lang.Object
-
- com.twelvemonkeys.io.ole2.CompoundDocument
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class CompoundDocument extends java.lang.Object implements java.lang.AutoCloseable
Represents a read-only OLE2 compound document.NOTE: This class is not synchronized. Accessing the document or its entries from different threads, will need synchronization on the document instance.
- Version:
- $Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/ole2/CompoundDocument.java#4 $
- Author:
- Harald Kuhr, last modified by $Author: haku $
-
-
Field Summary
Fields Modifier and Type Field Description static long
EPOCH_OFFSET
The epoch offset of CompoundDocument time stampsstatic int
HEADER_SIZE
-
Constructor Summary
Constructors Constructor Description CompoundDocument(java.io.File file)
Creates a (for now) read onlyCompoundDocument
.CompoundDocument(java.io.InputStream pInput)
Creates a read onlyCompoundDocument
.CompoundDocument(javax.imageio.stream.ImageInputStream input)
Creates a read onlyCompoundDocument
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
canRead(java.io.DataInput pInput)
void
close()
This method will close the underlyingRandomAccessFile
if any, but will leave any stream created outside the document open.Entry
getRootEntry()
static long
toJavaTimeInMillis(long pMSTime)
Converts the given time stamp to standard Java time representation, milliseconds since January 1, 1970.java.lang.String
toString()
-
-
-
Field Detail
-
HEADER_SIZE
public static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
EPOCH_OFFSET
public static final long EPOCH_OFFSET
The epoch offset of CompoundDocument time stamps- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompoundDocument
public CompoundDocument(java.io.File file) throws java.io.IOException
Creates a (for now) read onlyCompoundDocument
.Warning! You must invoke
close()
on the compound document created from this constructor when done, to avoid leaking file descriptors.- Parameters:
file
- the file to read from- Throws:
java.io.IOException
- if an I/O exception occurs while reading the header
-
CompoundDocument
public CompoundDocument(java.io.InputStream pInput) throws java.io.IOException
Creates a read onlyCompoundDocument
.- Parameters:
pInput
- the input to read from.- Throws:
java.io.IOException
- if an I/O exception occurs while reading the header
-
CompoundDocument
public CompoundDocument(javax.imageio.stream.ImageInputStream input) throws java.io.IOException
Creates a read onlyCompoundDocument
.- Parameters:
input
- the input to read from- Throws:
java.io.IOException
- if an I/O exception occurs while reading the header
-
-
Method Detail
-
close
public void close() throws java.io.IOException
This method will close the underlyingRandomAccessFile
if any, but will leave any stream created outside the document open.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.io.IOException
- if an I/O error occurs.- See Also:
CompoundDocument(File)
,RandomAccessFile.close()
-
canRead
public static boolean canRead(java.io.DataInput pInput)
-
getRootEntry
public Entry getRootEntry() throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toJavaTimeInMillis
public static long toJavaTimeInMillis(long pMSTime)
Converts the given time stamp to standard Java time representation, milliseconds since January 1, 1970. The time stamp parameter is assumed to be in units of 100 nano seconds since January 1, 1601.If the timestamp is
0L
(meaning not specified), no conversion is done, to behave likejava.io.File
.- Parameters:
pMSTime
- an unsigned long value representing the time stamp (in units of 100 nano seconds since January 1, 1601).- Returns:
- the time stamp converted to Java time stamp in milliseconds,
or
0L
ifpMSTime == 0L
-
-