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   
55   package org.apache.poi.hpsf.wellknown;
56   
57   import java.util.*;
58   
59   /**
60    * <p>This is a dictionary mapping property IDs to property ID
61    * strings.</p>
62    *
63    * <p>The methods {@link #getSummaryInformationProperties} and {@link
64    * #getDocumentSummaryInformationProperties} return singleton {@link
65    * PropertyIDMap}s. An application that wants to extend these maps
66    * should treat them as unmodifiable, copy them and modifiy the
67    * copies.</p>
68    *
69    * <p><strong>FIXME:</strong> Make the singletons
70    * unmodifiable. However, since this requires use a {@link HashMap}
71    * delegate instead of extending {@link HashMap} and would require a
72    * lot of stupid typing, I won't do it for the time being.</p>
73    *
74    * @author Rainer Klute (klute@rainer-klute.de)
75    * @version $Id: PropertyIDMap.java,v 1.3 2002/05/01 09:31:52 klute Exp $
76    * @since 2002-02-09
77    */
78   public class PropertyIDMap extends HashMap
79   {
80   
81       /* The following definitions are for the Summary Information. */
82       public static final int PID_TITLE = 2;
83       public static final int PID_SUBJECT = 3;
84       public static final int PID_AUTHOR = 4;
85       public static final int PID_KEYWORDS = 5;
86       public static final int PID_COMMENTS = 6;
87       public static final int PID_TEMPLATE = 7;
88       public static final int PID_LASTAUTHOR = 8;
89       public static final int PID_REVNUMBER = 9;
90       public static final int PID_EDITTIME = 10;
91       public static final int PID_LASTPRINTED = 11;
92       public static final int PID_CREATE_DTM = 12;
93       public static final int PID_LASTSAVE_DTM = 13;
94       public static final int PID_PAGECOUNT = 14;
95       public static final int PID_WORDCOUNT = 15;
96       public static final int PID_CHARCOUNT = 16;
97       public static final int PID_THUMBNAIL = 17;
98       public static final int PID_APPNAME = 18;
99       public static final int PID_SECURITY = 19;
100  
101      /* The following definitions are for the Document Summary Information. */
102      public static final int PID_CATEGORY = 2;
103      public static final int PID_PRESFORMAT = 3;
104      public static final int PID_BYTECOUNT = 4;
105      public static final int PID_LINECOUNT = 5;
106      public static final int PID_PARCOUNT = 6;
107      public static final int PID_SLIDECOUNT = 7;
108      public static final int PID_NOTECOUNT = 8;
109      public static final int PID_HIDDENCOUNT = 9;
110      public static final int PID_MMCLIPCOUNT = 10;
111      public static final int PID_SCALE = 11;
112      public static final int PID_HEADINGPAIR = 12;
113      public static final int PID_DOCPARTS = 13;
114      public static final int PID_MANAGER = 14;
115      public static final int PID_COMPANY = 15;
116      public static final int PID_LINKSDIRTY = 16;
117  
118      private static PropertyIDMap summaryInformationProperties;
119      private static PropertyIDMap documentSummaryInformationProperties;
120  
121  
122  
123      public PropertyIDMap(int initialCapacity, float loadFactor)
124      {
125  	super(initialCapacity, loadFactor);
126      }
127  
128  
129  
130      /**
131       * <p>Puts a ID string for an ID into the {@link
132       * PropertyIDMap}.</p>
133       *
134       * @param id The ID.
135       *
136       * @param idString The ID string.
137       */
138      public Object put(int id, String idString)
139      {
140  	return put(new Integer(id), idString);
141      }
142  
143  
144  
145      /**
146       * <p>Gets the ID string for an ID from the {@link
147       * PropertyIDMap}.</p>
148       *
149       * @param id The ID.
150       */
151      public Object get(int id)
152      {
153  	return get(new Integer(id));
154      }
155  
156  
157  
158      /**
159       * <p>Returns the Summary Information properties singleton.</p>
160       */
161      public static PropertyIDMap getSummaryInformationProperties()
162      {
163  	if (summaryInformationProperties == null)
164  	{
165  	    PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
166  	    m.put(PID_TITLE, "PID_TITLE");
167  	    m.put(PID_SUBJECT, "PID_SUBJECT");
168  	    m.put(PID_AUTHOR, "PID_AUTHOR");
169  	    m.put(PID_KEYWORDS, "PID_KEYWORDS");
170  	    m.put(PID_COMMENTS, "PID_COMMENTS");
171  	    m.put(PID_TEMPLATE, "PID_TEMPLATE");
172  	    m.put(PID_LASTAUTHOR, "PID_LASTAUTHOR");
173  	    m.put(PID_REVNUMBER, "PID_REVNUMBER");
174  	    m.put(PID_EDITTIME, "PID_EDITTIME");
175  	    m.put(PID_LASTPRINTED, "PID_LASTPRINTED");
176  	    m.put(PID_CREATE_DTM, "PID_CREATE_DTM");
177  	    m.put(PID_LASTSAVE_DTM, "PID_LASTSAVE_DTM");
178  	    m.put(PID_PAGECOUNT, "PID_PAGECOUNT");
179  	    m.put(PID_WORDCOUNT, "PID_WORDCOUNT");
180  	    m.put(PID_CHARCOUNT, "PID_CHARCOUNT");
181  	    m.put(PID_THUMBNAIL, "PID_THUMBNAIL");
182  	    m.put(PID_APPNAME, "PID_APPNAME");
183  	    m.put(PID_SECURITY, "PID_SECURITY");
184  	    summaryInformationProperties = m;
185  	}
186  	return summaryInformationProperties;
187      }
188  
189  
190  
191      /**
192       * <p>Returns the Summary Information properties singleton.</p>
193       */
194      public static PropertyIDMap getDocumentSummaryInformationProperties()
195      {
196  	if (documentSummaryInformationProperties == null)
197  	{
198  	    PropertyIDMap m = new PropertyIDMap(17, (float) 1.0);
199  	    m.put(PID_CATEGORY, "PID_CATEGORY");
200  	    m.put(PID_PRESFORMAT, "PID_PRESFORMAT");
201  	    m.put(PID_BYTECOUNT, "PID_BYTECOUNT");
202  	    m.put(PID_LINECOUNT, "PID_LINECOUNT");
203  	    m.put(PID_PARCOUNT, "PID_PARCOUNT");
204  	    m.put(PID_SLIDECOUNT, "PID_SLIDECOUNT");
205  	    m.put(PID_NOTECOUNT, "PID_NOTECOUNT");
206  	    m.put(PID_HIDDENCOUNT, "PID_HIDDENCOUNT");
207  	    m.put(PID_MMCLIPCOUNT, "PID_MMCLIPCOUNT");
208  	    m.put(PID_SCALE, "PID_SCALE");
209  	    m.put(PID_HEADINGPAIR, "PID_HEADINGPAIR");
210  	    m.put(PID_DOCPARTS, "PID_DOCPARTS");
211  	    m.put(PID_MANAGER, "PID_MANAGER");
212  	    m.put(PID_COMPANY, "PID_COMPANY");
213  	    m.put(PID_LINKSDIRTY, "PID_LINKSDIRTY");
214  	    documentSummaryInformationProperties = m;
215  	}
216  	return documentSummaryInformationProperties;
217  
218      }
219  
220  
221  
222      public static void main(String args[])
223      {
224  	PropertyIDMap s1 = getSummaryInformationProperties();
225  	PropertyIDMap s2 = getDocumentSummaryInformationProperties();
226  	System.out.println("s1: " + s1);
227  	System.out.println("s2: " + s2);
228      }
229  
230  }
231