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