Source Code Cross Referenced for DocumentSummaryInformation.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hpsf » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hpsf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:           Licensed to the Apache Software Foundation (ASF) under one or more
003:           contributor license agreements.  See the NOTICE file distributed with
004:           this work for additional information regarding copyright ownership.
005:           The ASF licenses this file to You under the Apache License, Version 2.0
006:           (the "License"); you may not use this file except in compliance with
007:           the License.  You may obtain a copy of the License at
008:
009:               http://www.apache.org/licenses/LICENSE-2.0
010:
011:           Unless required by applicable law or agreed to in writing, software
012:           distributed under the License is distributed on an "AS IS" BASIS,
013:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:           See the License for the specific language governing permissions and
015:           limitations under the License.
016:        ==================================================================== */
017:
018:        package org.apache.poi.hpsf;
019:
020:        import java.util.Iterator;
021:        import java.util.Map;
022:
023:        import org.apache.poi.hpsf.wellknown.PropertyIDMap;
024:        import org.apache.poi.hpsf.wellknown.SectionIDMap;
025:
026:        /**
027:         * <p>Convenience class representing a DocumentSummary Information stream in a
028:         * Microsoft Office document.</p>
029:         *
030:         * @author Rainer Klute <a
031:         * href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
032:         * @author Drew Varner (Drew.Varner closeTo sc.edu)
033:         * @author robert_flaherty@hyperion.com
034:         * @see SummaryInformation
035:         * @version $Id: DocumentSummaryInformation.java 489730 2006-12-22 19:18:16Z bayard $
036:         * @since 2002-02-09
037:         */
038:        public class DocumentSummaryInformation extends SpecialPropertySet {
039:
040:            /**
041:             * <p>The document name a document summary information stream
042:             * usually has in a POIFS filesystem.</p>
043:             */
044:            public static final String DEFAULT_STREAM_NAME = "\005DocumentSummaryInformation";
045:
046:            /**
047:             * <p>Creates a {@link DocumentSummaryInformation} from a given
048:             * {@link PropertySet}.</p>
049:             *
050:             * @param ps A property set which should be created from a
051:             * document summary information stream.
052:             * @throws UnexpectedPropertySetTypeException if <var>ps</var>
053:             * does not contain a document summary information stream.
054:             */
055:            public DocumentSummaryInformation(final PropertySet ps)
056:                    throws UnexpectedPropertySetTypeException {
057:                super (ps);
058:                if (!isDocumentSummaryInformation())
059:                    throw new UnexpectedPropertySetTypeException("Not a "
060:                            + getClass().getName());
061:            }
062:
063:            /**
064:             * <p>Returns the category (or <code>null</code>).</p>
065:             *
066:             * @return The category value
067:             */
068:            public String getCategory() {
069:                return (String) getProperty(PropertyIDMap.PID_CATEGORY);
070:            }
071:
072:            /**
073:             * <p>Sets the category.</p>
074:             *
075:             * @param category The category to set.
076:             */
077:            public void setCategory(final String category) {
078:                final MutableSection s = (MutableSection) getFirstSection();
079:                s.setProperty(PropertyIDMap.PID_CATEGORY, category);
080:            }
081:
082:            /**
083:             * <p>Removes the category.</p>
084:             */
085:            public void removeCategory() {
086:                final MutableSection s = (MutableSection) getFirstSection();
087:                s.removeProperty(PropertyIDMap.PID_CATEGORY);
088:            }
089:
090:            /**
091:             * <p>Returns the presentation format (or
092:             * <code>null</code>).</p>
093:             *
094:             * @return The presentation format value
095:             */
096:            public String getPresentationFormat() {
097:                return (String) getProperty(PropertyIDMap.PID_PRESFORMAT);
098:            }
099:
100:            /**
101:             * <p>Sets the presentation format.</p>
102:             *
103:             * @param presentationFormat The presentation format to set.
104:             */
105:            public void setPresentationFormat(final String presentationFormat) {
106:                final MutableSection s = (MutableSection) getFirstSection();
107:                s.setProperty(PropertyIDMap.PID_PRESFORMAT, presentationFormat);
108:            }
109:
110:            /**
111:             * <p>Removes the presentation format.</p>
112:             */
113:            public void removePresentationFormat() {
114:                final MutableSection s = (MutableSection) getFirstSection();
115:                s.removeProperty(PropertyIDMap.PID_PRESFORMAT);
116:            }
117:
118:            /**
119:             * <p>Returns the byte count or 0 if the {@link
120:             * DocumentSummaryInformation} does not contain a byte count.</p>
121:             *
122:             * @return The byteCount value
123:             */
124:            public int getByteCount() {
125:                return getPropertyIntValue(PropertyIDMap.PID_BYTECOUNT);
126:            }
127:
128:            /**
129:             * <p>Sets the byte count.</p>
130:             *
131:             * @param byteCount The byte count to set.
132:             */
133:            public void setByteCount(final int byteCount) {
134:                final MutableSection s = (MutableSection) getFirstSection();
135:                s.setProperty(PropertyIDMap.PID_BYTECOUNT, byteCount);
136:            }
137:
138:            /**
139:             * <p>Removes the byte count.</p>
140:             */
141:            public void removeByteCount() {
142:                final MutableSection s = (MutableSection) getFirstSection();
143:                s.removeProperty(PropertyIDMap.PID_BYTECOUNT);
144:            }
145:
146:            /**
147:             * <p>Returns the line count or 0 if the {@link
148:             * DocumentSummaryInformation} does not contain a line count.</p>
149:             *
150:             * @return The line count value
151:             */
152:            public int getLineCount() {
153:                return getPropertyIntValue(PropertyIDMap.PID_LINECOUNT);
154:            }
155:
156:            /**
157:             * <p>Sets the line count.</p>
158:             *
159:             * @param lineCount The line count to set.
160:             */
161:            public void setLineCount(final int lineCount) {
162:                final MutableSection s = (MutableSection) getFirstSection();
163:                s.setProperty(PropertyIDMap.PID_LINECOUNT, lineCount);
164:            }
165:
166:            /**
167:             * <p>Removes the line count.</p>
168:             */
169:            public void removeLineCount() {
170:                final MutableSection s = (MutableSection) getFirstSection();
171:                s.removeProperty(PropertyIDMap.PID_LINECOUNT);
172:            }
173:
174:            /**
175:             * <p>Returns the par count or 0 if the {@link
176:             * DocumentSummaryInformation} does not contain a par count.</p>
177:             *
178:             * @return The par count value
179:             */
180:            public int getParCount() {
181:                return getPropertyIntValue(PropertyIDMap.PID_PARCOUNT);
182:            }
183:
184:            /**
185:             * <p>Sets the par count.</p>
186:             *
187:             * @param parCount The par count to set.
188:             */
189:            public void setParCount(final int parCount) {
190:                final MutableSection s = (MutableSection) getFirstSection();
191:                s.setProperty(PropertyIDMap.PID_PARCOUNT, parCount);
192:            }
193:
194:            /**
195:             * <p>Removes the par count.</p>
196:             */
197:            public void removeParCount() {
198:                final MutableSection s = (MutableSection) getFirstSection();
199:                s.removeProperty(PropertyIDMap.PID_PARCOUNT);
200:            }
201:
202:            /**
203:             * <p>Returns the slide count or 0 if the {@link
204:             * DocumentSummaryInformation} does not contain a slide count.</p>
205:             *
206:             * @return The slide count value
207:             */
208:            public int getSlideCount() {
209:                return getPropertyIntValue(PropertyIDMap.PID_SLIDECOUNT);
210:            }
211:
212:            /**
213:             * <p>Sets the slideCount.</p>
214:             *
215:             * @param slideCount The slide count to set.
216:             */
217:            public void setSlideCount(final int slideCount) {
218:                final MutableSection s = (MutableSection) getFirstSection();
219:                s.setProperty(PropertyIDMap.PID_SLIDECOUNT, slideCount);
220:            }
221:
222:            /**
223:             * <p>Removes the slide count.</p>
224:             */
225:            public void removeSlideCount() {
226:                final MutableSection s = (MutableSection) getFirstSection();
227:                s.removeProperty(PropertyIDMap.PID_SLIDECOUNT);
228:            }
229:
230:            /**
231:             * <p>Returns the note count or 0 if the {@link
232:             * DocumentSummaryInformation} does not contain a note count.</p>
233:             *
234:             * @return The note count value
235:             */
236:            public int getNoteCount() {
237:                return getPropertyIntValue(PropertyIDMap.PID_NOTECOUNT);
238:            }
239:
240:            /**
241:             * <p>Sets the note count.</p>
242:             *
243:             * @param noteCount The note count to set.
244:             */
245:            public void setNoteCount(final int noteCount) {
246:                final MutableSection s = (MutableSection) getFirstSection();
247:                s.setProperty(PropertyIDMap.PID_NOTECOUNT, noteCount);
248:            }
249:
250:            /**
251:             * <p>Removes the noteCount.</p>
252:             */
253:            public void removeNoteCount() {
254:                final MutableSection s = (MutableSection) getFirstSection();
255:                s.removeProperty(PropertyIDMap.PID_NOTECOUNT);
256:            }
257:
258:            /**
259:             * <p>Returns the hidden count or 0 if the {@link
260:             * DocumentSummaryInformation} does not contain a hidden
261:             * count.</p>
262:             *
263:             * @return The hidden count value
264:             */
265:            public int getHiddenCount() {
266:                return getPropertyIntValue(PropertyIDMap.PID_HIDDENCOUNT);
267:            }
268:
269:            /**
270:             * <p>Sets the hidden count.</p>
271:             *
272:             * @param hiddenCount The hidden count to set.
273:             */
274:            public void setHiddenCount(final int hiddenCount) {
275:                final MutableSection s = (MutableSection) getSections().get(0);
276:                s.setProperty(PropertyIDMap.PID_HIDDENCOUNT, hiddenCount);
277:            }
278:
279:            /**
280:             * <p>Removes the hidden count.</p>
281:             */
282:            public void removeHiddenCount() {
283:                final MutableSection s = (MutableSection) getFirstSection();
284:                s.removeProperty(PropertyIDMap.PID_HIDDENCOUNT);
285:            }
286:
287:            /**
288:             * <p>Returns the mmclip count or 0 if the {@link
289:             * DocumentSummaryInformation} does not contain a mmclip
290:             * count.</p>
291:             *
292:             * @return The mmclip count value
293:             */
294:            public int getMMClipCount() {
295:                return getPropertyIntValue(PropertyIDMap.PID_MMCLIPCOUNT);
296:            }
297:
298:            /**
299:             * <p>Sets the mmclip count.</p>
300:             *
301:             * @param mmClipCount The mmclip count to set.
302:             */
303:            public void setMMClipCount(final int mmClipCount) {
304:                final MutableSection s = (MutableSection) getFirstSection();
305:                s.setProperty(PropertyIDMap.PID_MMCLIPCOUNT, mmClipCount);
306:            }
307:
308:            /**
309:             * <p>Removes the mmclip count.</p>
310:             */
311:            public void removeMMClipCount() {
312:                final MutableSection s = (MutableSection) getFirstSection();
313:                s.removeProperty(PropertyIDMap.PID_MMCLIPCOUNT);
314:            }
315:
316:            /**
317:             * <p>Returns <code>true</code> when scaling of the thumbnail is
318:             * desired, <code>false</code> if cropping is desired.</p>
319:             *
320:             * @return The scale value
321:             */
322:            public boolean getScale() {
323:                return getPropertyBooleanValue(PropertyIDMap.PID_SCALE);
324:            }
325:
326:            /**
327:             * <p>Sets the scale.</p>
328:             *
329:             * @param scale The scale to set.
330:             */
331:            public void setScale(final boolean scale) {
332:                final MutableSection s = (MutableSection) getFirstSection();
333:                s.setProperty(PropertyIDMap.PID_SCALE, scale);
334:            }
335:
336:            /**
337:             * <p>Removes the scale.</p>
338:             */
339:            public void removeScale() {
340:                final MutableSection s = (MutableSection) getFirstSection();
341:                s.removeProperty(PropertyIDMap.PID_SCALE);
342:            }
343:
344:            /**
345:             * <p>Returns the heading pair (or <code>null</code>)
346:             * <strong>when this method is implemented. Please note that the
347:             * return type is likely to change!</strong>
348:             *
349:             * @return The heading pair value
350:             */
351:            public byte[] getHeadingPair() {
352:                notYetImplemented("Reading byte arrays ");
353:                return (byte[]) getProperty(PropertyIDMap.PID_HEADINGPAIR);
354:            }
355:
356:            /**
357:             * <p>Sets the heading pair.</p>
358:             *
359:             * @param headingPair The heading pair to set.
360:             */
361:            public void setHeadingPair(final byte[] headingPair) {
362:                notYetImplemented("Writing byte arrays ");
363:            }
364:
365:            /**
366:             * <p>Removes the heading pair.</p>
367:             */
368:            public void removeHeadingPair() {
369:                final MutableSection s = (MutableSection) getFirstSection();
370:                s.removeProperty(PropertyIDMap.PID_HEADINGPAIR);
371:            }
372:
373:            /**
374:             * <p>Returns the doc parts (or <code>null</code>)
375:             * <strong>when this method is implemented. Please note that the
376:             * return type is likely to change!</strong>
377:             *
378:             * @return The doc parts value
379:             */
380:            public byte[] getDocparts() {
381:                notYetImplemented("Reading byte arrays");
382:                return (byte[]) getProperty(PropertyIDMap.PID_DOCPARTS);
383:            }
384:
385:            /**
386:             * <p>Sets the doc parts.</p>
387:             *
388:             * @param docparts The doc parts to set.
389:             */
390:            public void setDocparts(final byte[] docparts) {
391:                notYetImplemented("Writing byte arrays");
392:            }
393:
394:            /**
395:             * <p>Removes the doc parts.</p>
396:             */
397:            public void removeDocparts() {
398:                final MutableSection s = (MutableSection) getFirstSection();
399:                s.removeProperty(PropertyIDMap.PID_DOCPARTS);
400:            }
401:
402:            /**
403:             * <p>Returns the manager (or <code>null</code>).</p>
404:             *
405:             * @return The manager value
406:             */
407:            public String getManager() {
408:                return (String) getProperty(PropertyIDMap.PID_MANAGER);
409:            }
410:
411:            /**
412:             * <p>Sets the manager.</p>
413:             *
414:             * @param manager The manager to set.
415:             */
416:            public void setManager(final String manager) {
417:                final MutableSection s = (MutableSection) getFirstSection();
418:                s.setProperty(PropertyIDMap.PID_MANAGER, manager);
419:            }
420:
421:            /**
422:             * <p>Removes the manager.</p>
423:             */
424:            public void removeManager() {
425:                final MutableSection s = (MutableSection) getFirstSection();
426:                s.removeProperty(PropertyIDMap.PID_MANAGER);
427:            }
428:
429:            /**
430:             * <p>Returns the company (or <code>null</code>).</p>
431:             *
432:             * @return The company value
433:             */
434:            public String getCompany() {
435:                return (String) getProperty(PropertyIDMap.PID_COMPANY);
436:            }
437:
438:            /**
439:             * <p>Sets the company.</p>
440:             *
441:             * @param company The company to set.
442:             */
443:            public void setCompany(final String company) {
444:                final MutableSection s = (MutableSection) getFirstSection();
445:                s.setProperty(PropertyIDMap.PID_COMPANY, company);
446:            }
447:
448:            /**
449:             * <p>Removes the company.</p>
450:             */
451:            public void removeCompany() {
452:                final MutableSection s = (MutableSection) getFirstSection();
453:                s.removeProperty(PropertyIDMap.PID_COMPANY);
454:            }
455:
456:            /**
457:             * <p>Returns <code>true</code> if the custom links are dirty.</p> <p>
458:             *
459:             * @return The links dirty value
460:             */
461:            public boolean getLinksDirty() {
462:                return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY);
463:            }
464:
465:            /**
466:             * <p>Sets the linksDirty.</p>
467:             *
468:             * @param linksDirty The links dirty value to set.
469:             */
470:            public void setLinksDirty(final boolean linksDirty) {
471:                final MutableSection s = (MutableSection) getFirstSection();
472:                s.setProperty(PropertyIDMap.PID_LINKSDIRTY, linksDirty);
473:            }
474:
475:            /**
476:             * <p>Removes the links dirty.</p>
477:             */
478:            public void removeLinksDirty() {
479:                final MutableSection s = (MutableSection) getFirstSection();
480:                s.removeProperty(PropertyIDMap.PID_LINKSDIRTY);
481:            }
482:
483:            /**
484:             * <p>Gets the custom properties.</p>
485:             * 
486:             * @return The custom properties.
487:             * @since 2006-02-09
488:             */
489:            public CustomProperties getCustomProperties() {
490:                CustomProperties cps = null;
491:                if (getSectionCount() >= 2) {
492:                    cps = new CustomProperties();
493:                    final Section section = (Section) getSections().get(1);
494:                    final Map dictionary = section.getDictionary();
495:                    final Property[] properties = section.getProperties();
496:                    int propertyCount = 0;
497:                    for (int i = 0; i < properties.length; i++) {
498:                        final Property p = properties[i];
499:                        final long id = p.getID();
500:                        if (id != 0 && id != 1) {
501:                            propertyCount++;
502:                            final CustomProperty cp = new CustomProperty(p,
503:                                    (String) dictionary.get(new Long(id)));
504:                            cps.put(cp.getName(), cp);
505:                        }
506:                    }
507:                    if (cps.size() != propertyCount)
508:                        cps.setPure(false);
509:                }
510:                return cps;
511:            }
512:
513:            /**
514:             * <p>Sets the custom properties.</p>
515:             * 
516:             * @param customProperties The custom properties
517:             * @since 2006-02-07
518:             */
519:            public void setCustomProperties(
520:                    final CustomProperties customProperties) {
521:                ensureSection2();
522:                final MutableSection section = (MutableSection) getSections()
523:                        .get(1);
524:                final Map dictionary = customProperties.getDictionary();
525:                section.clear();
526:
527:                /* Set the codepage. If both custom properties and section have a
528:                 * codepage, the codepage from the custom properties wins, else take the
529:                 * one that is defined. If none is defined, take Unicode. */
530:                int cpCodepage = customProperties.getCodepage();
531:                if (cpCodepage < 0)
532:                    cpCodepage = section.getCodepage();
533:                if (cpCodepage < 0)
534:                    cpCodepage = Constants.CP_UNICODE;
535:                customProperties.setCodepage(cpCodepage);
536:                section.setCodepage(cpCodepage);
537:                section.setDictionary(dictionary);
538:                for (final Iterator i = customProperties.values().iterator(); i
539:                        .hasNext();) {
540:                    final Property p = (Property) i.next();
541:                    section.setProperty(p);
542:                }
543:            }
544:
545:            /**
546:             * <p>Creates section 2 if it is not already present.</p>
547:             *
548:             */
549:            private void ensureSection2() {
550:                if (getSectionCount() < 2) {
551:                    MutableSection s2 = new MutableSection();
552:                    s2
553:                            .setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);
554:                    addSection(s2);
555:                }
556:            }
557:
558:            /**
559:             * <p>Removes the custom properties.</p>
560:             * 
561:             * @since 2006-02-08
562:             */
563:            public void removeCustomProperties() {
564:                if (getSectionCount() >= 2)
565:                    getSections().remove(1);
566:                else
567:                    throw new HPSFRuntimeException(
568:                            "Illegal internal format of Document SummaryInformation stream: second section is missing.");
569:            }
570:
571:            /**
572:             * <p>Throws an {@link UnsupportedOperationException} with a message text
573:             * telling which functionality is not yet implemented.</p>
574:             *
575:             * @param msg text telling was leaves to be implemented, e.g.
576:             * "Reading byte arrays".
577:             */
578:            private void notYetImplemented(final String msg) {
579:                throw new UnsupportedOperationException(msg
580:                        + " is not yet implemented.");
581:            }
582:
583:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.