1    /*
2     *  ====================================================================
3     *  The Apache Software License, Version 1.1
4     *
5     *  Copyright (c) 2000 The Apache Software Foundation.  All rights
6     *  reserved.
7     *
8     *  Redistribution and use in source and binary forms, with or without
9     *  modification, are permitted provided that the following conditions
10    *  are met:
11    *
12    *  1. Redistributions of source code must retain the above copyright
13    *  notice, this list of conditions and the following disclaimer.
14    *
15    *  2. Redistributions in binary form must reproduce the above copyright
16    *  notice, this list of conditions and the following disclaimer in
17    *  the documentation and/or other materials provided with the
18    *  distribution.
19    *
20    *  3. The end-user documentation included with the redistribution,
21    *  if any, must include the following acknowledgment:
22    *  "This product includes software developed by the
23    *  Apache Software Foundation (http://www.apache.org/)."
24    *  Alternately, this acknowledgment may appear in the software itself,
25    *  if and wherever such third-party acknowledgments normally appear.
26    *
27    *  4. The names "Apache" and "Apache Software Foundation" must
28    *  not be used to endorse or promote products derived from this
29    *  software without prior written permission. For written
30    *  permission, please contact apache@apache.org.
31    *
32    *  5. Products derived from this software may not be called "Apache",
33    *  nor may "Apache" appear in their name, without prior written
34    *  permission of the Apache Software Foundation.
35    *
36    *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37    *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38    *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39    *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40    *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43    *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44    *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45    *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46    *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47    *  SUCH DAMAGE.
48    *  ====================================================================
49    *
50    *  This software consists of voluntary contributions made by many
51    *  individuals on behalf of the Apache Software Foundation.  For more
52    *  information on the Apache Software Foundation, please see
53    *  <http://www.apache.org/>.
54    */
55   package org.apache.poi.hpsf.wellknown;
56   
57   import java.util.*;
58   
59   /**
60    *  <p>
61    *
62    *  This is a dictionary mapping property IDs to property ID strings.</p> <p>
63    *
64    *  The methods {@link #getSummaryInformationProperties} and {@link
65    *  #getDocumentSummaryInformationProperties} return singleton {@link
66    *  PropertyIDMap}s. An application that wants to extend these maps should treat
67    *  them as unmodifiable, copy them and modifiy the copies.</p> <p>
68    *
69    *  <strong>FIXME:</strong> Make the singletons unmodifiable. However, since
70    *  this requires use a {@link HashMap} delegate instead of extending {@link
71    *  HashMap} and would require a lot of stupid typing, I won't do it for the
72    *  time being.</p>
73    *
74    *@author     Rainer Klute (klute@rainer-klute.de)
75    *@created    May 10, 2002
76    *@version    $Id: PropertyIDMap.java,v 1.4 2002/05/11 14:47:24 acoliver Exp $
77    *@since      2002-02-09
78    */
79   public class PropertyIDMap extends HashMap {
80   
81       /*
82        *  The following definitions are for the Summary Information.
83        */
84       /**
85        *  Description of the Field
86        */
87       public final static int PID_TITLE = 2;
88       /**
89        *  Description of the Field
90        */
91       public final static int PID_SUBJECT = 3;
92       /**
93        *  Description of the Field
94        */
95       public final static int PID_AUTHOR = 4;
96       /**
97        *  Description of the Field
98        */
99       public final static int PID_KEYWORDS = 5;
100      /**
101       *  Description of the Field
102       */
103      public final static int PID_COMMENTS = 6;
104      /**
105       *  Description of the Field
106       */
107      public final static int PID_TEMPLATE = 7;
108      /**
109       *  Description of the Field
110       */
111      public final static int PID_LASTAUTHOR = 8;
112      /**
113       *  Description of the Field
114       */
115      public final static int PID_REVNUMBER = 9;
116      /**
117       *  Description of the Field
118       */
119      public final static int PID_EDITTIME = 10;
120      /**
121       *  Description of the Field
122       */
123      public final static int PID_LASTPRINTED = 11;
124      /**
125       *  Description of the Field
126       */
127      public final static int PID_CREATE_DTM = 12;
128      /**
129       *  Description of the Field
130       */
131      public final static int PID_LASTSAVE_DTM = 13;
132      /**
133       *  Description of the Field
134       */
135      public final static int PID_PAGECOUNT = 14;
136      /**
137       *  Description of the Field
138       */
139      public final static int PID_WORDCOUNT = 15;
140      /**
141       *  Description of the Field
142       */
143      public final static int PID_CHARCOUNT = 16;
144      /**
145       *  Description of the Field
146       */
147      public final static int PID_THUMBNAIL = 17;
148      /**
149       *  Description of the Field
150       */
151      public final static int PID_APPNAME = 18;
152      /**
153       *  Description of the Field
154       */
155      public final static int PID_SECURITY = 19;
156  
157      /*
158       *  The following definitions are for the Document Summary Information.
159       */
160      /**
161       *  Description of the Field
162       */
163      public final static int PID_CATEGORY = 2;
164      /**
165       *  Description of the Field
166       */
167      public final static int PID_PRESFORMAT = 3;
168      /**
169       *  Description of the Field
170       */
171      public final static int PID_BYTECOUNT = 4;
172      /**
173       *  Description of the Field
174       */
175      public final static int PID_LINECOUNT = 5;
176      /**
177       *  Description of the Field
178       */
179      public final static int PID_PARCOUNT = 6;
180      /**
181       *  Description of the Field
182       */
183      public final static int PID_SLIDECOUNT = 7;
184      /**
185       *  Description of the Field
186       */
187      public final static int PID_NOTECOUNT = 8;
188      /**
189       *  Description of the Field
190       */
191      public final static int PID_HIDDENCOUNT = 9;
192      /**
193       *  Description of the Field
194       */
195      public final static int PID_MMCLIPCOUNT = 10;
196      /**
197       *  Description of the Field
198       */
199      public final static int PID_SCALE = 11;
200      /**
201       *  Description of the Field
202       */
203      public final static int PID_HEADINGPAIR = 12;
204      /**
205       *  Description of the Field
206       */
207      public final static int PID_DOCPARTS = 13;
208      /**
209       *  Description of the Field
210       */
211      public final static int PID_MANAGER = 14;
212      /**
213       *  Description of the Field
214       */
215      public final static int PID_COMPANY = 15;
216      /**
217       *  Description of the Field
218       */
219      public final static int PID_LINKSDIRTY = 16;
220  
221      private static PropertyIDMap summaryInformationProperties;
222      private static PropertyIDMap documentSummaryInformationProperties;
223  
224  
225  
226      /**
227       *  Constructor for the PropertyIDMap object
228       *
229       *@param  initialCapacity  Description of the Parameter
230       *@param  loadFactor       Description of the Parameter
231       */
232      public PropertyIDMap(int initialCapacity, float loadFactor) {
233          super(initialCapacity, loadFactor);
234      }
235  
236  
237  
238      /**
239       *  <p>
240       *
241       *  Puts a ID string for an ID into the {@link PropertyIDMap}.</p>
242       *
243       *@param  id        The ID.
244       *@param  idString  The ID string.
245       *@return           Description of the Return Value
246       */
247      public Object put(int id, String idString) {
248          return put(new Integer(id), idString);
249      }
250  
251  
252  
253      /**
254       *  <p>
255       *
256       *  Gets the ID string for an ID from the {@link PropertyIDMap}.</p>
257       *
258       *@param  id  The ID.
259       *@return     Description of the Return Value
260       */
261      public Object get(int id) {
262          return get(new Integer(id));
263      }
264  
265  
266  
267      /**
268       *  <p>
269       *
270       *  Returns the Summary Information properties singleton.</p>
271       *
272       *@return    The summaryInformationProperties value
273       */
274      public static PropertyIDMap getSummaryInformationProperties() {
275          if (summaryInformationProperties == null) {
276              PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
277              m.put(PID_TITLE, "PID_TITLE");
278              m.put(PID_SUBJECT, "PID_SUBJECT");
279              m.put(PID_AUTHOR, "PID_AUTHOR");
280              m.put(PID_KEYWORDS, "PID_KEYWORDS");
281              m.put(PID_COMMENTS, "PID_COMMENTS");
282              m.put(PID_TEMPLATE, "PID_TEMPLATE");
283              m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR");
284              m.put(PID_REVNUMBER, "PID_REVNUMBER");
285              m.put(PID_EDITTIME, "PID_EDITTIME");
286              m.put(PID_LASTPRINTED, "PID_LASTPRINTED");
287              m.put(PID_CREATE_DTM, "PID_CREATE_DTM");
288              m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM");
289              m.put(PID_PAGECOUNT, "PID_PAGECOUNT");
290              m.put(PID_WORDCOUNT, "PID_WORDCOUNT");
291              m.put(PID_CHARCOUNT, "PID_CHARCOUNT");
292              m.put(PID_THUMBNAIL, "PID_THUMBNAIL");
293              m.put(PID_APPNAME, "PID_APPNAME");
294              m.put(PID_SECURITY, "PID_SECURITY");
295              summaryInformationProperties = m;
296          }
297          return summaryInformationProperties;
298      }
299  
300  
301  
302      /**
303       *  <p>
304       *
305       *  Returns the Summary Information properties singleton.</p>
306       *
307       *@return    The documentSummaryInformationProperties value
308       */
309      public static PropertyIDMap getDocumentSummaryInformationProperties() {
310          if (documentSummaryInformationProperties == null) {
311              PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
312              m.put(PID_CATEGORY, "PID_CATEGORY");
313              m.put(PID_PRESFORMAT, "PID_PRESFORMAT");
314              m.put(PID_BYTECOUNT, "PID_BYTECOUNT");
315              m.put(PID_LINECOUNT, "PID_LINECOUNT");
316              m.put(PID_PARCOUNT, "PID_PARCOUNT");
317              m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT");
318              m.put(PID_NOTECOUNT, "PID_NOTECOUNT");
319              m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT");
320              m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT");
321              m.put(PID_SCALE, "PID_SCALE");
322              m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR");
323              m.put(PID_DOCPARTS, "PID_DOCPARTS");
324              m.put(PID_MANAGER, "PID_MANAGER");
325              m.put(PID_COMPANY, "PID_COMPANY");
326              m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY");
327              documentSummaryInformationProperties = m;
328          }
329          return documentSummaryInformationProperties;
330      }
331  
332  
333  
334      /**
335       *  Description of the Method
336       *
337       *@param  args  Description of the Parameter
338       */
339      public static void main(String args[]) {
340          PropertyIDMap s1 = getSummaryInformationProperties();
341          PropertyIDMap s2 = getDocumentSummaryInformationProperties();
342          System.out.println("s1: " + s1);
343          System.out.println("s2: " + s2);
344      }
345  
346  }
347