FileDocCategorySizeDatePackage
PropertySetFactory.javaAPI DocApache Poi 3.0.14546Mon Jan 01 12:39:34 GMT 2007org.apache.poi.hpsf

PropertySetFactory

public class PropertySetFactory extends Object

Factory class to create instances of {@link SummaryInformation}, {@link DocumentSummaryInformation} and {@link PropertySet}.

author
Rainer Klute <klute@rainer-klute.de>
version
$Id: PropertySetFactory.java 489730 2006-12-22 19:18:16Z bayard $
since
2002-02-09

Fields Summary
Constructors Summary
Methods Summary
public static org.apache.poi.hpsf.PropertySetcreate(java.io.InputStream stream)

Creates the most specific {@link PropertySet} from an {@link InputStream}. This is preferrably a {@link DocumentSummaryInformation} or a {@link SummaryInformation}. If the specified {@link InputStream} does not contain a property set stream, an exception is thrown and the {@link InputStream} is repositioned at its beginning.

param
stream Contains the property set stream's data.
return
The created {@link PropertySet}.
throws
NoPropertySetStreamException if the stream does not contain a property set.
throws
MarkUnsupportedException if the stream does not support the mark operation.
throws
IOException if some I/O problem occurs.
exception
UnsupportedEncodingException if the specified codepage is not supported.

        final PropertySet ps = new PropertySet(stream);
        try
        {
            if (ps.isSummaryInformation())
                return new SummaryInformation(ps);
            else if (ps.isDocumentSummaryInformation())
                return new DocumentSummaryInformation(ps);
            else
                return ps;
        }
        catch (UnexpectedPropertySetTypeException ex)
        {
            /* This exception will never be throws because we already checked
             * explicitly for this case above. */
            throw new UnexpectedException(ex.toString());
        }
    
public static org.apache.poi.hpsf.DocumentSummaryInformationnewDocumentSummaryInformation()

Creates a new document summary information.

return
the new document summary information.

        final MutablePropertySet ps = new MutablePropertySet();
        final MutableSection s = (MutableSection) ps.getFirstSection();
        s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
        try
        {
            return new DocumentSummaryInformation(ps);
        }
        catch (UnexpectedPropertySetTypeException ex)
        {
            /* This should never happen. */
            throw new HPSFRuntimeException(ex);
        }
    
public static org.apache.poi.hpsf.SummaryInformationnewSummaryInformation()

Creates a new summary information.

return
the new summary information.

        final MutablePropertySet ps = new MutablePropertySet();
        final MutableSection s = (MutableSection) ps.getFirstSection();
        s.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
        try
        {
            return new SummaryInformation(ps);
        }
        catch (UnexpectedPropertySetTypeException ex)
        {
            /* This should never happen. */
            throw new HPSFRuntimeException(ex);
        }