KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > poifs > property > DocumentProperty


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
19 package org.apache.poi.poifs.property;
20
21 import org.apache.poi.poifs.filesystem.POIFSDocument;
22
23 /**
24  * Trivial extension of Property for POIFSDocuments
25  *
26  * @author Marc Johnson (mjohnson at apache dot org)
27  */

28
29 public class DocumentProperty
30     extends Property
31 {
32
33     // the POIFSDocument this property is associated with
34
private POIFSDocument _document;
35
36     /**
37      * Constructor
38      *
39      * @param name POIFSDocument name
40      * @param size POIFSDocument size
41      */

42
43     public DocumentProperty(final String JavaDoc name, final int size)
44     {
45         super();
46         _document = null;
47         setName(name);
48         setSize(size);
49         setNodeColor(_NODE_BLACK); // simplification
50
setPropertyType(PropertyConstants.DOCUMENT_TYPE);
51     }
52
53     /**
54      * reader constructor
55      *
56      * @param index index number
57      * @param array byte data
58      * @param offset offset into byte data
59      */

60
61     protected DocumentProperty(final int index, final byte [] array,
62                                final int offset)
63     {
64         super(index, array, offset);
65         _document = null;
66     }
67
68     /**
69      * set the POIFSDocument
70      *
71      * @param doc the associated POIFSDocument
72      */

73
74     public void setDocument(POIFSDocument doc)
75     {
76         _document = doc;
77     }
78
79     /**
80      * get the POIFSDocument
81      *
82      * @return the associated document
83      */

84
85     public POIFSDocument getDocument()
86     {
87         return _document;
88     }
89
90     /* ********** START extension of Property ********** */
91
92     /**
93      * give method more visibility
94      *
95      * @return true if this property should use small blocks
96      */

97
98     public boolean shouldUseSmallBlocks()
99     {
100         return super.shouldUseSmallBlocks();
101     }
102
103     /**
104      * @return true if a directory type Property
105      */

106
107     public boolean isDirectory()
108     {
109         return false;
110     }
111
112     /**
113      * Perform whatever activities need to be performed prior to
114      * writing
115      */

116
117     protected void preWrite()
118     {
119
120         // do nothing
121
}
122
123     /* ********** END extension of Property ********** */
124 } // end public class DocumentProperty
125

126
Popular Tags