FileDocCategorySizeDatePackage
POIDocument.javaAPI DocApache Poi 3.0.14980Sun Mar 11 12:59:30 GMT 2007org.apache.poi

POIDocument

public abstract class POIDocument extends Object
This holds the common functionality for all POI Document classes. Currently, this relates to Document Information Properties
author
Nick Burch

Fields Summary
protected SummaryInformation
sInf
Holds metadata on our document
protected DocumentSummaryInformation
dsInf
Holds further metadata on our document
protected POIFSFileSystem
filesystem
The open POIFS FileSystem that contains our document
protected POILogger
logger
For our own logging use
Constructors Summary
Methods Summary
public org.apache.poi.hpsf.DocumentSummaryInformationgetDocumentSummaryInformation()
Fetch the Document Summary Information of the document


	
	         	 
	    return dsInf; 
protected org.apache.poi.hpsf.PropertySetgetPropertySet(java.lang.String setName)
For a given named property entry, either return it or null if if it wasn't found

		DocumentInputStream dis;
		try {
			// Find the entry, and get an input stream for it
			dis = filesystem.createDocumentInputStream(setName);
		} catch(IOException ie) {
			// Oh well, doesn't exist
			System.err.println("Error getting property set with name " + setName + "\n" + ie);
			return null;
		}

		try {
			// Create the Property Set
			PropertySet set = PropertySetFactory.create(dis);
			return set;
		} catch(IOException ie) {
			// Must be corrupt or something like that
			System.err.println("Error creating property set with name " + setName + "\n" + ie);
		} catch(org.apache.poi.hpsf.HPSFException he) {
			// Oh well, doesn't exist
			System.err.println("Error creating property set with name " + setName + "\n" + he);
		}
		return null;
	
public org.apache.poi.hpsf.SummaryInformationgetSummaryInformation()
Fetch the Summary Information of the document

 return sInf; 
protected voidreadProperties()
Find, and create objects for, the standard Documment Information Properties (HPSF)

		// DocumentSummaryInformation
		dsInf = (DocumentSummaryInformation)getPropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

		// SummaryInformation
		sInf = (SummaryInformation)getPropertySet(SummaryInformation.DEFAULT_STREAM_NAME);
	
protected voidwriteProperties(org.apache.poi.poifs.filesystem.POIFSFileSystem outFS)
Writes out the standard Documment Information Properties (HPSF)

param
outFS the POIFSFileSystem to write the properties into

		if(sInf != null) {
			writePropertySet(SummaryInformation.DEFAULT_STREAM_NAME,sInf,outFS);
		}
		if(dsInf != null) {
			writePropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME,dsInf,outFS);
		}
	
protected voidwritePropertySet(java.lang.String name, org.apache.poi.hpsf.PropertySet set, org.apache.poi.poifs.filesystem.POIFSFileSystem outFS)
Writes out a given ProperySet

param
name the (POIFS Level) name of the property to write
param
set the PropertySet to write out
param
outFS the POIFSFileSystem to write the property into

		try {
			MutablePropertySet mSet = new MutablePropertySet(set);
			ByteArrayOutputStream bOut = new ByteArrayOutputStream();

			mSet.write(bOut);
			byte[] data = bOut.toByteArray();
			ByteArrayInputStream bIn = new ByteArrayInputStream(data);
			outFS.createDocument(bIn,name);

			logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
		} catch(org.apache.poi.hpsf.WritingNotSupportedException wnse) {
			System.err.println("Couldn't write property set with name " + name + " as not supported by HPSF yet");
		}