1    /* ====================================================================
2     * The Apache Software License, Version 1.1
3     *
4     * Copyright (c) 2000 The Apache Software Foundation.  All rights
5     * reserved.
6     *
7     * Redistribution and use in source and binary forms, with or without
8     * modification, are permitted provided that the following conditions
9     * are met:
10    *
11    * 1. Redistributions of source code must retain the above copyright
12    *    notice, this list of conditions and the following disclaimer.
13    *
14    * 2. Redistributions in binary form must reproduce the above copyright
15    *    notice, this list of conditions and the following disclaimer in
16    *    the documentation and/or other materials provided with the
17    *    distribution.
18    *
19    * 3. The end-user documentation included with the redistribution,
20    *    if any, must include the following acknowledgment:
21    *       "This product includes software developed by the
22    *        Apache Software Foundation (http://www.apache.org/)."
23    *    Alternately, this acknowledgment may appear in the software itself,
24    *    if and wherever such third-party acknowledgments normally appear.
25    *
26    * 4. The names "Apache" and "Apache Software Foundation" must
27    *    not be used to endorse or promote products derived from this
28    *    software without prior written permission. For written
29    *    permission, please contact apache@apache.org.
30    *
31    * 5. Products derived from this software may not be called "Apache",
32    *    nor may "Apache" appear in their name, without prior written
33    *    permission of the Apache Software Foundation.
34    *
35    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46    * SUCH DAMAGE.
47    * ====================================================================
48    *
49    * This software consists of voluntary contributions made by many
50    * individuals on behalf of the Apache Software Foundation.  For more
51    * information on the Apache Software Foundation, please see
52    * <http://www.apache.org/>.
53    *
54    * Portions of this software are based upon public domain software
55    * originally written at the National Center for Supercomputing Applications,
56    * University of Illinois, Urbana-Champaign.
57    */
58   
59   package org.apache.poi.hpsf;
60   
61   import java.io.*;
62   import java.util.*;
63   import org.apache.poi.hpsf.wellknown.*;
64   
65   /**
66    * <p>Convenience class representing a Summary Information stream in a
67    * Microsoft Office document.</p>
68    *
69    * @see DocumentSummaryInformation
70    *
71    * @author Rainer Klute (klute@rainer-klute.de)
72    * @version $Id: SummaryInformation.java,v 1.1 2002/02/14 04:00:59 mjohnson Exp $
73    * @since 2002-02-09
74    */
75   public class SummaryInformation extends SpecialPropertySet
76   {
77   
78       /**
79        * <p>Creates a {@link SummaryInformation} from a given {@link
80        * PropertySet}.</p>
81        *
82        * @param ps A property set which should be created from a summary
83        * information stream.
84        *
85        * @throws UnexpectedPropertySetTypeException if <var>ps</var>
86        * does not contain a summary information stream.
87        */
88       public SummaryInformation(final PropertySet ps)
89           throws UnexpectedPropertySetTypeException
90       {
91           super(ps);
92           if (!isSummaryInformation())
93               throw new UnexpectedPropertySetTypeException
94                   ("Not a " + getClass().getName());
95       }
96   
97   
98   
99       /**
100       * <p>Returns the stream's title (or <code>null</code>).</p>
101       */
102      public String getTitle()
103      {
104          return (String) getProperty(PropertyIDMap.PID_TITLE);
105      }
106  
107  
108  
109      /**
110       * <p>Returns the stream's subject (or <code>null</code>).</p>
111       */
112      public String getSubject()
113      {
114          return (String) getProperty(PropertyIDMap.PID_SUBJECT);
115      }
116  
117  
118  
119      /**
120       * <p>Returns the stream's author (or <code>null</code>).</p>
121       */
122      public String getAuthor()
123      {
124          return (String) getProperty(PropertyIDMap.PID_AUTHOR);
125      }
126  
127  
128  
129      /**
130       * <p>Returns the stream's keywords (or <code>null</code>).</p>
131       */
132      public String getKeywords()
133      {
134          return (String) getProperty(PropertyIDMap.PID_KEYWORDS);
135      }
136  
137  
138  
139      /**
140       * <p>Returns the stream's comments (or <code>null</code>).</p>
141       */
142      public String getComments()
143      {
144          return (String) getProperty(PropertyIDMap.PID_COMMENTS);
145      }
146  
147  
148  
149      /**
150       * <p>Returns the stream's template (or <code>null</code>).</p>
151       */
152      public String getTemplate()
153      {
154          return (String) getProperty(PropertyIDMap.PID_TEMPLATE);
155      }
156  
157  
158  
159      /**
160       * <p>Returns the stream's last author (or <code>null</code>).</p>
161       */
162      public String getLastAuthor()
163      {
164          return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR);
165      }
166  
167  
168  
169      /**
170       * <p>Returns the stream's revision number (or
171       * <code>null</code>).
172       </p> */
173      public String getRevNumber()
174      {
175          return (String) getProperty(PropertyIDMap.PID_REVNUMBER);
176      }
177  
178  
179  
180      /**
181       * <p>Returns the stream's edit time (or <code>null</code>).</p>
182       */
183      public Date getEditTime()
184      {
185          return (Date) getProperty(PropertyIDMap.PID_EDITTIME);
186      }
187  
188  
189  
190      /**
191       * <p>Returns the stream's last printed time (or
192       * <code>null</code>).</p>
193       */
194      public Date getLastPrinted()
195      {
196          return (Date) getProperty(PropertyIDMap.PID_LASTPRINTED);
197      }
198  
199  
200  
201      /**
202       * <p>Returns the stream's creation time (or
203       * <code>null</code>).</p>
204       */
205      public Date getCreateDateTime()
206      {
207          return (Date) getProperty(PropertyIDMap.PID_CREATE_DTM);
208      }
209  
210  
211  
212      /**
213       * <p>Returns the stream's last save time (or
214       * <code>null</code>).</p>
215       */
216      public Date getLastSaveDateTime()
217      {
218          return (Date) getProperty(PropertyIDMap.PID_LASTSAVE_DTM);
219      }
220  
221  
222  
223      /**
224       * <p>Returns the stream's page count or 0 if the {@link
225       * SummaryInformation} does not contain a page count.</p>
226       */
227      public int getPageCount()
228      {
229          return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT);
230      }
231  
232  
233  
234      /**
235       * <p>Returns the stream's word count or 0 if the {@link
236       * SummaryInformation} does not contain a word count.</p>
237       */
238      public int getWordCount()
239      {
240          return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT);
241      }
242  
243  
244  
245      /**
246       * <p>Returns the stream's char count or 0 if the {@link
247       * SummaryInformation} does not contain a char count.</p>
248       */
249      public int getCharCount()
250      {
251          return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);
252      }
253  
254  
255  
256      /**
257       * <p>Returns the stream's thumbnail (or <code>null</code>)
258       * <strong>when this method is implemented. Please note that the
259       * return type is likely to change!</strong>
260       */
261      public byte[] getThumbnail()
262      {
263          if (true)
264              throw new UnsupportedOperationException("FIXME");
265          return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL);
266      }
267  
268  
269  
270      /**
271       * <p>Returns the stream's application name (or
272       * <code>null</code>).</p>
273       */
274      public String getApplicationName()
275      {
276          return (String) getProperty(PropertyIDMap.PID_APPNAME);
277      }
278  
279  
280  
281      /**
282       * <p>Returns the stream's security field or 0 if the {@link
283       * SummaryInformation} does not contain a security field.</p>
284       */
285      public int getSecurity()
286      {
287          return getPropertyIntValue(PropertyIDMap.PID_SECURITY);
288      }
289  
290  }
291