KickJava   Java API By Example, From Geeks To Geeks.

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


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.HashMap JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import org.apache.poi.hpsf.wellknown.PropertyIDMap;
25
26 /**
27  * <p>Convenience class representing a DocumentSummary Information stream in a
28  * Microsoft Office document.</p>
29  *
30  * @author Rainer Klute <a
31  * HREF="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
32  * @author Drew Varner (Drew.Varner closeTo sc.edu)
33  * @author robert_flaherty@hyperion.com
34  * @see SummaryInformation
35  * @version $Id: DocumentSummaryInformation.java,v 1.14 2004/08/15 15:20:07 klute Exp $
36  * @since 2002-02-09
37  */

38 public class DocumentSummaryInformation extends SpecialPropertySet
39 {
40
41     /**
42      * <p>The document name a document summary information stream
43      * usually has in a POIFS filesystem.</p>
44      */

45     public static final String JavaDoc DEFAULT_STREAM_NAME =
46         "\005DocumentSummaryInformation";
47
48
49
50     /**
51      * <p>Creates a {@link DocumentSummaryInformation} from a given
52      * {@link PropertySet}.</p>
53      *
54      * @param ps A property set which should be created from a
55      * document summary information stream.
56      * @throws UnexpectedPropertySetTypeException if <var>ps</var>
57      * does not contain a document summary information stream.
58      */

59     public DocumentSummaryInformation(final PropertySet ps)
60         throws UnexpectedPropertySetTypeException
61     {
62         super(ps);
63         if (!isDocumentSummaryInformation())
64             throw new UnexpectedPropertySetTypeException
65                 ("Not a " + getClass().getName());
66     }
67
68
69
70     /**
71      * <p>Returns the stream's category (or <code>null</code>).</p>
72      *
73      * @return The category value
74      */

75     public String JavaDoc getCategory()
76     {
77         return (String JavaDoc) getProperty(PropertyIDMap.PID_CATEGORY);
78     }
79
80
81
82     /**
83      * <p>Returns the stream's presentation format (or
84      * <code>null</code>).</p>
85      *
86      * @return The presentationFormat value
87      */

88     public String JavaDoc getPresentationFormat()
89     {
90         return (String JavaDoc) getProperty(PropertyIDMap.PID_PRESFORMAT);
91     }
92
93
94
95     /**
96      * <p>Returns the stream's byte count or 0 if the {@link
97      * DocumentSummaryInformation} does not contain a byte count.</p>
98      *
99      * @return The byteCount value
100      */

101     public int getByteCount()
102     {
103         return getPropertyIntValue(PropertyIDMap.PID_BYTECOUNT);
104     }
105
106
107
108     /**
109      * <p>Returns the stream's line count or 0 if the {@link
110      * DocumentSummaryInformation} does not contain a line count.</p>
111      *
112      * @return The lineCount value
113      */

114     public int getLineCount()
115     {
116         return getPropertyIntValue(PropertyIDMap.PID_LINECOUNT);
117     }
118
119
120
121     /**
122      * <p>Returns the stream's par count or 0 if the {@link
123      * DocumentSummaryInformation} does not contain a par count.</p>
124      *
125      * @return The parCount value
126      */

127     public int getParCount()
128     {
129         return getPropertyIntValue(PropertyIDMap.PID_PARCOUNT);
130     }
131
132
133
134     /**
135      * <p>Returns the stream's slide count or 0 if the {@link
136      * DocumentSummaryInformation} does not contain a slide count.</p>
137      *
138      * @return The slideCount value
139      */

140     public int getSlideCount()
141     {
142         return getPropertyIntValue(PropertyIDMap.PID_SLIDECOUNT);
143     }
144
145
146
147     /**
148      * <p>Returns the stream's note count or 0 if the {@link
149      * DocumentSummaryInformation} does not contain a note count.</p>
150      *
151      * @return The noteCount value
152      */

153     public int getNoteCount()
154     {
155         return getPropertyIntValue(PropertyIDMap.PID_NOTECOUNT);
156     }
157
158
159
160     /**
161      * <p>Returns the stream's hidden count or 0 if the {@link
162      * DocumentSummaryInformation} does not contain a hidden
163      * count.</p>
164      *
165      * @return The hiddenCount value
166      */

167     public int getHiddenCount()
168     {
169         return getPropertyIntValue(PropertyIDMap.PID_HIDDENCOUNT);
170     }
171
172
173
174     /**
175      * <p>Returns the stream's mmclip count or 0 if the {@link
176      * DocumentSummaryInformation} does not contain a mmclip
177      * count.</p>
178      *
179      * @return The mMClipCount value
180      */

181     public int getMMClipCount()
182     {
183         return getPropertyIntValue(PropertyIDMap.PID_MMCLIPCOUNT);
184     }
185
186
187
188     /**
189      * <p>Returns <code>true</code> when scaling of the thumbnail is
190      * desired, <code>false</code> if cropping is desired.</p>
191      *
192      * @return The scale value
193      */

194     public boolean getScale()
195     {
196         return getPropertyBooleanValue(PropertyIDMap.PID_SCALE);
197     }
198
199
200
201     /**
202      * <p>Returns the stream's heading pair (or <code>null</code>)
203      * <strong>when this method is implemented. Please note that the
204      * return type is likely to change!</strong>
205      *
206      * @return The headingPair value
207      */

208     public byte[] getHeadingPair()
209     {
210         if (true)
211             throw new UnsupportedOperationException JavaDoc("FIXME");
212         return (byte[]) getProperty(PropertyIDMap.PID_HEADINGPAIR);
213     }
214
215
216
217     /**
218      * <p>Returns the stream's doc parts (or <code>null</code>)
219      * <strong>when this method is implemented. Please note that the
220      * return type is likely to change!</strong>
221      *
222      * @return The docparts value
223      */

224     public byte[] getDocparts()
225     {
226         if (true)
227             throw new UnsupportedOperationException JavaDoc("FIXME");
228         return (byte[]) getProperty(PropertyIDMap.PID_DOCPARTS);
229     }
230
231
232
233     /**
234      * <p>Returns the stream's manager (or <code>null</code>).</p>
235      *
236      * @return The manager value
237      */

238     public String JavaDoc getManager()
239     {
240         return (String JavaDoc) getProperty(PropertyIDMap.PID_MANAGER);
241     }
242
243
244
245     /**
246      * <p>Returns the stream's company (or <code>null</code>).</p>
247      *
248      * @return The company value
249      */

250     public String JavaDoc getCompany()
251     {
252         return (String JavaDoc) getProperty(PropertyIDMap.PID_COMPANY);
253     }
254
255
256
257     /**
258      * <p>Returns <code>true</code> if the custom links are dirty.</p> <p>
259      *
260      * @return The linksDirty value
261      */

262     public boolean getLinksDirty()
263     {
264         return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY);
265     }
266
267
268
269     /**
270      * <p>Gets the custom properties as a map from the property name to
271      * value.</p>
272      *
273      * @return The custom properties if any exist, <code>null</code> otherwise.
274      * @since 2003-10-22
275      */

276     public Map JavaDoc getCustomProperties()
277     {
278         Map JavaDoc nameToValue = null;
279         if (getSectionCount() >= 2)
280         {
281             final Section section = (Section) getSections().get(1);
282             final Map JavaDoc pidToName =
283                       (Map JavaDoc) section.getProperty(PropertyIDMap.PID_DICTIONARY);
284             if (pidToName != null)
285             {
286                 nameToValue = new HashMap JavaDoc(pidToName.size());
287                 for (Iterator JavaDoc i = pidToName.entrySet().iterator(); i.hasNext();)
288                 {
289                     final Map.Entry JavaDoc e = (Map.Entry JavaDoc) i.next();
290                     final long pid = ((Number JavaDoc) e.getKey()).longValue();
291                     nameToValue.put(e.getValue(), section.getProperty(pid));
292                 }
293             }
294         }
295         return nameToValue;
296     }
297
298 }
299
Popular Tags