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.poifs.property;
019:
020: import org.apache.poi.poifs.filesystem.POIFSDocument;
021:
022: /**
023: * Trivial extension of Property for POIFSDocuments
024: *
025: * @author Marc Johnson (mjohnson at apache dot org)
026: */
027:
028: public class DocumentProperty extends Property {
029:
030: // the POIFSDocument this property is associated with
031: private POIFSDocument _document;
032:
033: /**
034: * Constructor
035: *
036: * @param name POIFSDocument name
037: * @param size POIFSDocument size
038: */
039:
040: public DocumentProperty(final String name, final int size) {
041: super ();
042: _document = null;
043: setName(name);
044: setSize(size);
045: setNodeColor(_NODE_BLACK); // simplification
046: setPropertyType(PropertyConstants.DOCUMENT_TYPE);
047: }
048:
049: /**
050: * reader constructor
051: *
052: * @param index index number
053: * @param array byte data
054: * @param offset offset into byte data
055: */
056:
057: protected DocumentProperty(final int index, final byte[] array,
058: final int offset) {
059: super (index, array, offset);
060: _document = null;
061: }
062:
063: /**
064: * set the POIFSDocument
065: *
066: * @param doc the associated POIFSDocument
067: */
068:
069: public void setDocument(POIFSDocument doc) {
070: _document = doc;
071: }
072:
073: /**
074: * get the POIFSDocument
075: *
076: * @return the associated document
077: */
078:
079: public POIFSDocument getDocument() {
080: return _document;
081: }
082:
083: /* ********** START extension of Property ********** */
084:
085: /**
086: * give method more visibility
087: *
088: * @return true if this property should use small blocks
089: */
090:
091: public boolean shouldUseSmallBlocks() {
092: return super .shouldUseSmallBlocks();
093: }
094:
095: /**
096: * @return true if a directory type Property
097: */
098:
099: public boolean isDirectory() {
100: return false;
101: }
102:
103: /**
104: * Perform whatever activities need to be performed prior to
105: * writing
106: */
107:
108: protected void preWrite() {
109:
110: // do nothing
111: }
112:
113: /* ********** END extension of Property ********** */
114: } // end public class DocumentProperty
|