org.apache.poi
Class POIDocument

java.lang.Object
  extended by org.apache.poi.POIDocument
Direct Known Subclasses:
HDGFDiagram, HPBFDocument, HPSFPropertiesOnlyDocument, HSLFSlideShowImpl, HSSFWorkbook, HWPFDocumentCore, MAPIMessage

public abstract class POIDocument
extends java.lang.Object

This holds the common functionality for all POI Document classes. Currently, this relates to Document Information Properties


Field Summary
protected  DirectoryNode directory
          The directory that our document lives in
 
Constructor Summary
protected POIDocument(DirectoryNode dir)
          Constructs a POIDocument with the given directory node.
protected POIDocument(NPOIFSFileSystem fs)
          Constructs from an old-style OPOIFS
protected POIDocument(OPOIFSFileSystem fs)
          Constructs from an old-style OPOIFS
protected POIDocument(POIFSFileSystem fs)
          Constructs from the default POIFS
 
Method Summary
 void createInformationProperties()
          Will create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document.
 DirectoryNode getDirectory()
           
 DocumentSummaryInformation getDocumentSummaryInformation()
          Fetch the Document Summary Information of the document
protected  PropertySet getPropertySet(java.lang.String setName)
          For a given named property entry, either return it or null if if it wasn't found
protected  PropertySet getPropertySet(java.lang.String setName, EncryptionInfo encryptionInfo)
          For a given named property entry, either return it or null if if it wasn't found
 SummaryInformation getSummaryInformation()
          Fetch the Summary Information of the document
protected  void readProperties()
          Find, and create objects for, the standard Document Information Properties (HPSF).
abstract  void write(java.io.OutputStream out)
          Writes the document out to the specified output stream.
protected  void writeProperties()
          Writes out the updated standard Document Information Properties (HPSF) into the currently open NPOIFSFileSystem TODO Implement in-place update
protected  void writeProperties(NPOIFSFileSystem outFS)
          Writes out the standard Document Information Properties (HPSF)
protected  void writeProperties(NPOIFSFileSystem outFS, java.util.List<java.lang.String> writtenEntries)
          Writes out the standard Document Information Properties (HPSF)
protected  void writePropertySet(java.lang.String name, PropertySet set, NPOIFSFileSystem outFS)
          Writes out a given ProperySet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

directory

protected DirectoryNode directory
The directory that our document lives in

Constructor Detail

POIDocument

protected POIDocument(DirectoryNode dir)
Constructs a POIDocument with the given directory node.

Parameters:
dir - The DirectoryNode where information is read from.

POIDocument

protected POIDocument(OPOIFSFileSystem fs)
Constructs from an old-style OPOIFS


POIDocument

protected POIDocument(NPOIFSFileSystem fs)
Constructs from an old-style OPOIFS


POIDocument

protected POIDocument(POIFSFileSystem fs)
Constructs from the default POIFS

Method Detail

getDocumentSummaryInformation

public DocumentSummaryInformation getDocumentSummaryInformation()
Fetch the Document Summary Information of the document

Returns:
The Document Summary Information or null if it could not be read for this document.

getSummaryInformation

public SummaryInformation getSummaryInformation()
Fetch the Summary Information of the document

Returns:
The Summary information for the document or null if it could not be read for this document.

createInformationProperties

public void createInformationProperties()
Will create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document. This is normally useful when creating a new document from scratch. If the information properties are already there, then nothing will happen.


readProperties

protected void readProperties()
Find, and create objects for, the standard Document Information Properties (HPSF). If a given property set is missing or corrupt, it will remain null;


getPropertySet

protected PropertySet getPropertySet(java.lang.String setName)
For a given named property entry, either return it or null if if it wasn't found

Parameters:
setName - The property to read
Returns:
The value of the given property or null if it wasn't found.

getPropertySet

protected PropertySet getPropertySet(java.lang.String setName,
                                     EncryptionInfo encryptionInfo)
For a given named property entry, either return it or null if if it wasn't found

Parameters:
setName - The property to read
encryptionInfo - the encryption descriptor in case of cryptoAPI encryption
Returns:
The value of the given property or null if it wasn't found.

writeProperties

protected void writeProperties()
                        throws java.io.IOException
Writes out the updated standard Document Information Properties (HPSF) into the currently open NPOIFSFileSystem TODO Implement in-place update

Throws:
java.io.IOException - if an error when writing to the open NPOIFSFileSystem occurs TODO throws exception if open from stream not file

writeProperties

protected void writeProperties(NPOIFSFileSystem outFS)
                        throws java.io.IOException
Writes out the standard Document Information Properties (HPSF)

Parameters:
outFS - the POIFSFileSystem to write the properties into
Throws:
java.io.IOException - if an error when writing to the NPOIFSFileSystem occurs

writeProperties

protected void writeProperties(NPOIFSFileSystem outFS,
                               java.util.List<java.lang.String> writtenEntries)
                        throws java.io.IOException
Writes out the standard Document Information Properties (HPSF)

Parameters:
outFS - the NPOIFSFileSystem to write the properties into
writtenEntries - a list of POIFS entries to add the property names too
Throws:
java.io.IOException - if an error when writing to the NPOIFSFileSystem occurs

writePropertySet

protected void writePropertySet(java.lang.String name,
                                PropertySet set,
                                NPOIFSFileSystem outFS)
                         throws java.io.IOException
Writes out a given ProperySet

Parameters:
name - the (POIFS Level) name of the property to write
set - the PropertySet to write out
outFS - the NPOIFSFileSystem to write the property into
Throws:
java.io.IOException - if an error when writing to the NPOIFSFileSystem occurs

write

public abstract void write(java.io.OutputStream out)
                    throws java.io.IOException
Writes the document out to the specified output stream. The stream is not closed as part of this operation. Note - if the Document was opened from a File rather than an InputStream, you must write out to a different file, overwriting via an OutputStream isn't possible.

Parameters:
out - The stream to write to.
Throws:
java.io.IOException - thrown on errors writing to the stream

getDirectory

@Internal
public DirectoryNode getDirectory()


Copyright 2016 The Apache Software Foundation or its licensors, as applicable.