KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hpsf > SummaryInformation


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18 package org.apache.poi.hpsf;
19
20 import java.util.Date JavaDoc;
21 import org.apache.poi.hpsf.wellknown.PropertyIDMap;
22
23 /**
24  * <p>Convenience class representing a Summary Information stream in a
25  * Microsoft Office document.</p>
26  *
27  * @author Rainer Klute <a
28  * HREF="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
29  * @see DocumentSummaryInformation
30  * @version $Id: SummaryInformation.java,v 1.17 2004/12/29 21:14:39 klute Exp $
31  * @since 2002-02-09
32  */

33 public class SummaryInformation extends SpecialPropertySet
34 {
35
36     /**
37      * <p>The document name a summary information stream usually has
38      * in a POIFS filesystem.</p>
39      */

40     public static final String JavaDoc DEFAULT_STREAM_NAME = "\005SummaryInformation";
41
42
43
44     /**
45      * <p>Creates a {@link SummaryInformation} from a given {@link
46      * PropertySet}.</p>
47      *
48      * @param ps A property set which should be created from a summary
49      * information stream.
50      * @throws UnexpectedPropertySetTypeException if <var>ps</var>
51      * does not contain a summary information stream.
52      */

53     public SummaryInformation(final PropertySet ps)
54         throws UnexpectedPropertySetTypeException
55     {
56         super(ps);
57         if (!isSummaryInformation())
58             throw new UnexpectedPropertySetTypeException
59                 ("Not a " + getClass().getName());
60     }
61
62
63
64     /**
65      * <p>Returns the stream's title (or <code>null</code>).</p>
66      *
67      * @return The title or <code>null</code>
68      */

69     public String JavaDoc getTitle()
70     {
71         return (String JavaDoc) getProperty(PropertyIDMap.PID_TITLE);
72     }
73
74
75
76     /**
77      * <p>Returns the stream's subject (or <code>null</code>).</p>
78      *
79      * @return The subject or <code>null</code>
80      */

81     public String JavaDoc getSubject()
82     {
83         return (String JavaDoc) getProperty(PropertyIDMap.PID_SUBJECT);
84     }
85
86
87
88     /**
89      * <p>Returns the stream's author (or <code>null</code>).</p>
90      *
91      * @return The author or <code>null</code>
92      */

93     public String JavaDoc getAuthor()
94     {
95         return (String JavaDoc) getProperty(PropertyIDMap.PID_AUTHOR);
96     }
97
98
99
100     /**
101      * <p>Returns the stream's keywords (or <code>null</code>).</p>
102      *
103      * @return The keywords or <code>null</code>
104      */

105     public String JavaDoc getKeywords()
106     {
107         return (String JavaDoc) getProperty(PropertyIDMap.PID_KEYWORDS);
108     }
109
110
111
112     /**
113      * <p>Returns the stream's comments (or <code>null</code>).</p>
114      *
115      * @return The comments or <code>null</code>
116      */

117     public String JavaDoc getComments()
118     {
119         return (String JavaDoc) getProperty(PropertyIDMap.PID_COMMENTS);
120     }
121
122
123
124     /**
125      * <p>Returns the stream's template (or <code>null</code>).</p>
126      *
127      * @return The template or <code>null</code>
128      */

129     public String JavaDoc getTemplate()
130     {
131         return (String JavaDoc) getProperty(PropertyIDMap.PID_TEMPLATE);
132     }
133
134
135
136     /**
137      * <p>Returns the stream's last author (or <code>null</code>).</p>
138      *
139      * @return The last author or <code>null</code>
140      */

141     public String JavaDoc getLastAuthor()
142     {
143         return (String JavaDoc) getProperty(PropertyIDMap.PID_LASTAUTHOR);
144     }
145
146
147
148     /**
149      * <p>Returns the stream's revision number (or
150      * <code>null</code>). </p>
151      *
152      * @return The revision number or <code>null</code>
153      */

154     public String JavaDoc getRevNumber()
155     {
156         return (String JavaDoc) getProperty(PropertyIDMap.PID_REVNUMBER);
157     }
158
159
160
161     /**
162      * <p>Returns the total time spent in editing the document
163      * (or <code>0</code>).</p>
164      *
165      * @return The total time spent in editing the document or 0 if the {@link
166      * SummaryInformation} does not contain this information.
167      */

168     public long getEditTime()
169     {
170         final Date JavaDoc d = (Date JavaDoc) getProperty(PropertyIDMap.PID_EDITTIME);
171         if (d == null)
172             return 0;
173         else
174             return Util.dateToFileTime(d);
175     }
176
177
178
179     /**
180      * <p>Returns the stream's last printed time (or
181      * <code>null</code>).</p>
182      *
183      * @return The last printed time or <code>null</code>
184      */

185     public Date JavaDoc getLastPrinted()
186     {
187         return (Date JavaDoc) getProperty(PropertyIDMap.PID_LASTPRINTED);
188     }
189
190
191
192     /**
193      * <p>Returns the stream's creation time (or
194      * <code>null</code>).</p>
195      *
196      * @return The creation time or <code>null</code>
197      */

198     public Date JavaDoc getCreateDateTime()
199     {
200         return (Date JavaDoc) getProperty(PropertyIDMap.PID_CREATE_DTM);
201     }
202
203
204
205     /**
206      * <p>Returns the stream's last save time (or
207      * <code>null</code>).</p>
208      *
209      * @return The last save time or <code>null</code>
210      */

211     public Date JavaDoc getLastSaveDateTime()
212     {
213         return (Date JavaDoc) getProperty(PropertyIDMap.PID_LASTSAVE_DTM);
214     }
215
216
217
218     /**
219      * <p>Returns the stream's page count or 0 if the {@link
220      * SummaryInformation} does not contain a page count.</p>
221      *
222      * @return The page count or 0 if the {@link SummaryInformation} does not
223      * contain a page count.
224      */

225     public int getPageCount()
226     {
227         return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT);
228     }
229
230
231
232     /**
233      * <p>Returns the stream's word count or 0 if the {@link
234      * SummaryInformation} does not contain a word count.</p>
235      *
236      * @return The word count or <code>null</code>
237      */

238     public int getWordCount()
239     {
240         return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT);
241     }
242
243
244
245     /**
246      * <p>Returns the stream's character count or 0 if the {@link
247      * SummaryInformation} does not contain a char count.</p>
248      *
249      * @return The character count or <code>null</code>
250      */

251     public int getCharCount()
252     {
253         return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);
254     }
255
256
257
258     /**
259      * <p>Returns the stream's thumbnail (or <code>null</code>)
260      * <strong>when this method is implemented. Please note that the
261      * return type is likely to change!</strong></p>
262      *
263      * <p><strong>Hint to developers:</strong> Drew Varner &lt;Drew.Varner -at-
264      * sc.edu&gt; said that this is an image in WMF or Clipboard (BMP?) format.
265      * However, we won't do any conversion into any image type but instead just
266      * return a byte array.</p>
267      *
268      * @return The thumbnail or <code>null</code>
269      */

270     public byte[] getThumbnail()
271     {
272         return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL);
273     }
274
275
276
277     /**
278      * <p>Returns the stream's application name (or
279      * <code>null</code>).</p>
280      *
281      * @return The application name or <code>null</code>
282      */

283     public String JavaDoc getApplicationName()
284     {
285         return (String JavaDoc) getProperty(PropertyIDMap.PID_APPNAME);
286     }
287
288
289
290     /**
291      * <p>Returns a security code which is one of the following
292      * values:</p>
293      *
294      * <ul>
295      * <li>
296      * <p>0 if the {@link SummaryInformation} does not contain a
297      * security field or if there is no security on the
298      * document. Use {@link #wasNull} to distinguish between the
299      * two cases!</p>
300      * </li>
301      *
302      * <li>
303      * <p>1 if the document is password protected</p>
304      * </li>
305      *
306      * <li>
307      * <p>2 if the document is read-only recommended</p>
308      * </li>
309      *
310      * <li>
311      * <p>4 if the document is read-only enforced</p>
312      * </li>
313      *
314      * <li>
315      * <p>8 if the document is locked for annotations</p>
316      * </li>
317      *
318      * </ul>
319      *
320      * @return The security code or <code>null</code>
321      */

322     public int getSecurity()
323     {
324         return getPropertyIntValue(PropertyIDMap.PID_SECURITY);
325     }
326
327 }
328
Popular Tags