KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hpsf > wellknown > PropertyIDMap


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.wellknown;
19
20 import java.util.Collections JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Map JavaDoc;
23
24 /**
25  * <p>This is a dictionary which maps property ID values to property
26  * ID strings.</p>
27  *
28  * <p>The methods {@link #getSummaryInformationProperties} and {@link
29  * #getDocumentSummaryInformationProperties} return singleton {@link
30  * PropertyIDMap}s. An application that wants to extend these maps
31  * should treat them as unmodifiable, copy them and modifiy the
32  * copies.</p>
33  *
34  * @author Rainer Klute <a
35  * HREF="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
36  * @version $Id: PropertyIDMap.java,v 1.14 2004/08/15 15:20:08 klute Exp $
37  * @since 2002-02-09
38  */

39 public class PropertyIDMap extends HashMap JavaDoc
40 {
41
42     /*
43      * The following definitions are for property IDs in the first
44      * (and only) section of the Summary Information property set.
45      */

46
47     /** <p>ID of the property that denotes the document's title</p> */
48     public static final int PID_TITLE = 2;
49
50     /** <p>ID of the property that denotes the document's subject</p> */
51     public static final int PID_SUBJECT = 3;
52
53     /** <p>ID of the property that denotes the document's author</p> */
54     public static final int PID_AUTHOR = 4;
55
56     /** <p>ID of the property that denotes the document's keywords</p> */
57     public static final int PID_KEYWORDS = 5;
58
59     /** <p>ID of the property that denotes the document's comments</p> */
60     public static final int PID_COMMENTS = 6;
61
62     /** <p>ID of the property that denotes the document's template</p> */
63     public static final int PID_TEMPLATE = 7;
64
65     /** <p>ID of the property that denotes the document's last author</p> */
66     public static final int PID_LASTAUTHOR = 8;
67
68     /** <p>ID of the property that denotes the document's revision number</p> */
69     public static final int PID_REVNUMBER = 9;
70
71     /** <p>ID of the property that denotes the document's edit time</p> */
72     public static final int PID_EDITTIME = 10;
73
74     /** <p>ID of the property that denotes the date and time the document was
75      * last printed</p> */

76     public static final int PID_LASTPRINTED = 11;
77
78     /** <p>ID of the property that denotes the date and time the document was
79      * created.</p> */

80     public static final int PID_CREATE_DTM = 12;
81
82     /** <p>ID of the property that denotes the date and time the document was
83      * saved</p> */

84     public static final int PID_LASTSAVE_DTM = 13;
85
86     /** <p>ID of the property that denotes the number of pages in the
87      * document</p> */

88     public static final int PID_PAGECOUNT = 14;
89
90     /** <p>ID of the property that denotes the number of words in the
91      * document</p> */

92     public static final int PID_WORDCOUNT = 15;
93
94     /** <p>ID of the property that denotes the number of characters in the
95      * document</p> */

96     public static final int PID_CHARCOUNT = 16;
97
98     /** <p>ID of the property that denotes the document's thumbnail</p> */
99     public static final int PID_THUMBNAIL = 17;
100
101     /** <p>ID of the property that denotes the application that created the
102      * document</p> */

103     public static final int PID_APPNAME = 18;
104
105     /** <p>ID of the property that denotes whether read/write access to the
106      * document is allowed or whether is should be opened as read-only. It can
107      * have the following values:</p>
108      *
109      * <table>
110      * <tbody>
111      * <tr>
112      * <th><p>Value</p></th>
113      * <th><p>Description</p></th>
114      * </tr>
115      * <tr>
116      * <th><p>0</p></th>
117      * <th><p>No restriction</p></th>
118      * </tr>
119      * <tr>
120      * <th><p>2</p></th>
121      * <th><p>Read-only recommended</p></th>
122      * </tr>
123      * <tr>
124      * <th><p>4</p></th>
125      * <th><p>Read-only enforced</p></th>
126      * </tr>
127      * </tbody>
128      * </table>
129      */

130     public static final int PID_SECURITY = 19;
131
132
133
134     /*
135      * The following definitions are for property IDs in the first
136      * section of the Document Summary Information property set.
137      */

138
139     /**
140      * <p>The entry is a dictionary.</p>
141      */

142     public static final int PID_DICTIONARY = 0;
143
144     /**
145      * <p>The entry denotes a code page.</p>
146      */

147     public static final int PID_CODEPAGE = 1;
148
149     /**
150      * <p>The entry is a string denoting the category the file belongs
151      * to, e.g. review, memo, etc. This is useful to find documents of
152      * same type.</p>
153      */

154     public static final int PID_CATEGORY = 2;
155
156     /**
157      * <p>Target format for power point presentation, e.g. 35mm,
158      * printer, video etc.</p>
159      */

160     public static final int PID_PRESFORMAT = 3;
161
162     /**
163      * <p>Number of bytes.</p>
164      */

165     public static final int PID_BYTECOUNT = 4;
166
167     /**
168      * <p>Number of lines.</p>
169      */

170     public static final int PID_LINECOUNT = 5;
171
172     /**
173      * <p>Number of paragraphs.</p>
174      */

175     public static final int PID_PARCOUNT = 6;
176
177     /**
178      * <p>Number of slides in a power point presentation.</p>
179      */

180     public static final int PID_SLIDECOUNT = 7;
181
182     /**
183      * <p>Number of slides with notes.</p>
184      */

185     public static final int PID_NOTECOUNT = 8;
186
187     /**
188      * <p>Number of hidden slides.</p>
189      */

190     public static final int PID_HIDDENCOUNT = 9;
191
192     /**
193      * <p>Number of multimedia clips, e.g. sound or video.</p>
194      */

195     public static final int PID_MMCLIPCOUNT = 10;
196
197     /**
198      * <p>This entry is set to -1 when scaling of the thumbnail is
199      * desired. Otherwise the thumbnail should be cropped.</p>
200      */

201     public static final int PID_SCALE = 11;
202
203     /**
204      * <p>This entry denotes an internally used property. It is a
205      * vector of variants consisting of pairs of a string (VT_LPSTR)
206      * and a number (VT_I4). The string is a heading name, and the
207      * number tells how many document parts are under that
208      * heading.</p>
209      */

210     public static final int PID_HEADINGPAIR = 12;
211
212     /**
213      * <p>This entry contains the names of document parts (word: names
214      * of the documents in the master document, excel: sheet names,
215      * power point: slide titles, binder: document names).</p>
216      */

217     public static final int PID_DOCPARTS = 13;
218
219     /**
220      * <p>This entry contains the name of the project manager.</p>
221      */

222     public static final int PID_MANAGER = 14;
223
224     /**
225      * <p>This entry contains the company name.</p>
226      */

227     public static final int PID_COMPANY = 15;
228
229     /**
230      * <p>If this entry is -1 the links are dirty and should be
231      * re-evaluated.</p>
232      */

233     public static final int PID_LINKSDIRTY = 16;
234
235
236
237     /**
238      * <p>Contains the summary information property ID values and
239      * associated strings. See the overall HPSF documentation for
240      * details!</p>
241      */

242     private static PropertyIDMap summaryInformationProperties;
243
244     /**
245      * <p>Contains the summary information property ID values and
246      * associated strings. See the overall HPSF documentation for
247      * details!</p>
248      */

249     private static PropertyIDMap documentSummaryInformationProperties;
250
251
252
253     /**
254      * <p>Creates a {@link PropertyIDMap}.</p>
255      *
256      * @param initialCapacity The initial capacity as defined for
257      * {@link HashMap}
258      * @param loadFactor The load factor as defined for {@link HashMap}
259      */

260     public PropertyIDMap(final int initialCapacity, final float loadFactor)
261     {
262         super(initialCapacity, loadFactor);
263     }
264
265
266
267     /**
268      * <p>Creates a {@link PropertyIDMap} backed by another map.</p>
269      *
270      * @param map The instance to be created is backed by this map.
271      */

272     public PropertyIDMap(final Map JavaDoc map)
273     {
274         super(map);
275     }
276
277
278
279     /**
280      * <p>Puts a ID string for an ID into the {@link
281      * PropertyIDMap}.</p>
282      *
283      * @param id The ID.
284      * @param idString The ID string.
285      * @return As specified by the {@link java.util.Map} interface, this method
286      * returns the previous value associated with the specified
287      * <var>id</var>, or <code>null</code> if there was no mapping for
288      * key.
289      */

290     public Object JavaDoc put(final long id, final String JavaDoc idString)
291     {
292         return put(new Long JavaDoc(id), idString);
293     }
294
295
296
297     /**
298      * <p>Gets the ID string for an ID from the {@link
299      * PropertyIDMap}.</p>
300      *
301      * @param id The ID.
302      * @return The ID string associated with <var>id</var>.
303      */

304     public Object JavaDoc get(final long id)
305     {
306         return get(new Long JavaDoc(id));
307     }
308
309
310
311     /**
312      * @return the Summary Information properties singleton
313      */

314     public static PropertyIDMap getSummaryInformationProperties()
315     {
316         if (summaryInformationProperties == null)
317         {
318             PropertyIDMap m = new PropertyIDMap(18, (float) 1.0);
319             m.put(PID_TITLE, "PID_TITLE");
320             m.put(PID_SUBJECT, "PID_SUBJECT");
321             m.put(PID_AUTHOR, "PID_AUTHOR");
322             m.put(PID_KEYWORDS, "PID_KEYWORDS");
323             m.put(PID_COMMENTS, "PID_COMMENTS");
324             m.put(PID_TEMPLATE, "PID_TEMPLATE");
325             m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR");
326             m.put(PID_REVNUMBER, "PID_REVNUMBER");
327             m.put(PID_EDITTIME, "PID_EDITTIME");
328             m.put(PID_LASTPRINTED, "PID_LASTPRINTED");
329             m.put(PID_CREATE_DTM, "PID_CREATE_DTM");
330             m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM");
331             m.put(PID_PAGECOUNT, "PID_PAGECOUNT");
332             m.put(PID_WORDCOUNT, "PID_WORDCOUNT");
333             m.put(PID_CHARCOUNT, "PID_CHARCOUNT");
334             m.put(PID_THUMBNAIL, "PID_THUMBNAIL");
335             m.put(PID_APPNAME, "PID_APPNAME");
336             m.put(PID_SECURITY, "PID_SECURITY");
337             summaryInformationProperties =
338                 new PropertyIDMap(Collections.unmodifiableMap(m));
339         }
340         return summaryInformationProperties;
341     }
342
343
344
345     /**
346      * <p>Returns the Document Summary Information properties
347      * singleton.</p>
348      *
349      * @return The Document Summary Information properties singleton.
350      */

351     public static PropertyIDMap getDocumentSummaryInformationProperties()
352     {
353         if (documentSummaryInformationProperties == null)
354         {
355             PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
356             m.put(PID_DICTIONARY, "PID_DICTIONARY");
357             m.put(PID_CODEPAGE, "PID_CODEPAGE");
358             m.put(PID_CATEGORY, "PID_CATEGORY");
359             m.put(PID_PRESFORMAT, "PID_PRESFORMAT");
360             m.put(PID_BYTECOUNT, "PID_BYTECOUNT");
361             m.put(PID_LINECOUNT, "PID_LINECOUNT");
362             m.put(PID_PARCOUNT, "PID_PARCOUNT");
363             m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT");
364             m.put(PID_NOTECOUNT, "PID_NOTECOUNT");
365             m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT");
366             m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT");
367             m.put(PID_SCALE, "PID_SCALE");
368             m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR");
369             m.put(PID_DOCPARTS, "PID_DOCPARTS");
370             m.put(PID_MANAGER, "PID_MANAGER");
371             m.put(PID_COMPANY, "PID_COMPANY");
372             m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY");
373             documentSummaryInformationProperties =
374                 new PropertyIDMap(Collections.unmodifiableMap(m));
375         }
376         return documentSummaryInformationProperties;
377     }
378
379
380
381     /**
382      * <p>For the most basic testing.</p>
383      *
384      * @param args The command-line arguments
385      */

386     public static void main(final String JavaDoc[] args)
387     {
388         PropertyIDMap s1 = getSummaryInformationProperties();
389         PropertyIDMap s2 = getDocumentSummaryInformationProperties();
390         System.out.println("s1: " + s1);
391         System.out.println("s2: " + s2);
392     }
393
394 }
395
Popular Tags