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.io.IOException;
021: import java.io.InputStream;
022: import java.io.OutputStream;
023: import java.util.List;
024:
025: import org.apache.poi.poifs.filesystem.DirectoryEntry;
026:
027: /**
028: * <p>Abstract superclass for the convenience classes {@link
029: * SummaryInformation} and {@link DocumentSummaryInformation}.</p>
030: *
031: * <p>The motivation behind this class is quite nasty if you look
032: * behind the scenes, but it serves the application programmer well by
033: * providing him with the easy-to-use {@link SummaryInformation} and
034: * {@link DocumentSummaryInformation} classes. When parsing the data a
035: * property set stream consists of (possibly coming from an {@link
036: * java.io.InputStream}) we want to read and process each byte only
037: * once. Since we don't know in advance which kind of property set we
038: * have, we can expect only the most general {@link
039: * PropertySet}. Creating a special subclass should be as easy as
040: * calling the special subclass' constructor and pass the general
041: * {@link PropertySet} in. To make things easy internally, the special
042: * class just holds a reference to the general {@link PropertySet} and
043: * delegates all method calls to it.</p>
044: *
045: * <p>A cleaner implementation would have been like this: The {@link
046: * PropertySetFactory} parses the stream data into some internal
047: * object first. Then it finds out whether the stream is a {@link
048: * SummaryInformation}, a {@link DocumentSummaryInformation} or a
049: * general {@link PropertySet}. However, the current implementation
050: * went the other way round historically: the convenience classes came
051: * only late to my mind.</p>
052: *
053: * @author Rainer Klute <a
054: * href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
055: * @version $Id: SpecialPropertySet.java 489730 2006-12-22 19:18:16Z bayard $
056: * @since 2002-02-09
057: */
058: public abstract class SpecialPropertySet extends MutablePropertySet {
059:
060: /**
061: * <p>The "real" property set <code>SpecialPropertySet</code>
062: * delegates to.</p>
063: */
064: private MutablePropertySet delegate;
065:
066: /**
067: * <p>Creates a <code>SpecialPropertySet</code>.
068: *
069: * @param ps The property set to be encapsulated by the
070: * <code>SpecialPropertySet</code>
071: */
072: public SpecialPropertySet(final PropertySet ps) {
073: delegate = new MutablePropertySet(ps);
074: }
075:
076: /**
077: * <p>Creates a <code>SpecialPropertySet</code>.
078: *
079: * @param ps The mutable property set to be encapsulated by the
080: * <code>SpecialPropertySet</code>
081: */
082: public SpecialPropertySet(final MutablePropertySet ps) {
083: delegate = ps;
084: }
085:
086: /**
087: * @see PropertySet#getByteOrder
088: */
089: public int getByteOrder() {
090: return delegate.getByteOrder();
091: }
092:
093: /**
094: * @see PropertySet#getFormat
095: */
096: public int getFormat() {
097: return delegate.getFormat();
098: }
099:
100: /**
101: * @see PropertySet#getOSVersion
102: */
103: public int getOSVersion() {
104: return delegate.getOSVersion();
105: }
106:
107: /**
108: * @see PropertySet#getClassID
109: */
110: public ClassID getClassID() {
111: return delegate.getClassID();
112: }
113:
114: /**
115: * @see PropertySet#getSectionCount
116: */
117: public int getSectionCount() {
118: return delegate.getSectionCount();
119: }
120:
121: /**
122: * @see PropertySet#getSections
123: */
124: public List getSections() {
125: return delegate.getSections();
126: }
127:
128: /**
129: * @see PropertySet#isSummaryInformation
130: */
131: public boolean isSummaryInformation() {
132: return delegate.isSummaryInformation();
133: }
134:
135: /**
136: * @see PropertySet#isDocumentSummaryInformation
137: */
138: public boolean isDocumentSummaryInformation() {
139: return delegate.isDocumentSummaryInformation();
140: }
141:
142: /**
143: * @see PropertySet#getSingleSection
144: */
145: public Section getFirstSection() {
146: return delegate.getFirstSection();
147: }
148:
149: /**
150: * @see org.apache.poi.hpsf.MutablePropertySet#addSection(org.apache.poi.hpsf.Section)
151: */
152: public void addSection(final Section section) {
153: delegate.addSection(section);
154: }
155:
156: /**
157: * @see org.apache.poi.hpsf.MutablePropertySet#clearSections()
158: */
159: public void clearSections() {
160: delegate.clearSections();
161: }
162:
163: /**
164: * @see org.apache.poi.hpsf.MutablePropertySet#setByteOrder(int)
165: */
166: public void setByteOrder(final int byteOrder) {
167: delegate.setByteOrder(byteOrder);
168: }
169:
170: /**
171: * @see org.apache.poi.hpsf.MutablePropertySet#setClassID(org.apache.poi.hpsf.ClassID)
172: */
173: public void setClassID(final ClassID classID) {
174: delegate.setClassID(classID);
175: }
176:
177: /**
178: * @see org.apache.poi.hpsf.MutablePropertySet#setFormat(int)
179: */
180: public void setFormat(final int format) {
181: delegate.setFormat(format);
182: }
183:
184: /**
185: * @see org.apache.poi.hpsf.MutablePropertySet#setOSVersion(int)
186: */
187: public void setOSVersion(final int osVersion) {
188: delegate.setOSVersion(osVersion);
189: }
190:
191: /**
192: * @see org.apache.poi.hpsf.MutablePropertySet#toInputStream()
193: */
194: public InputStream toInputStream() throws IOException,
195: WritingNotSupportedException {
196: return delegate.toInputStream();
197: }
198:
199: /**
200: * @see org.apache.poi.hpsf.MutablePropertySet#write(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
201: */
202: public void write(final DirectoryEntry dir, final String name)
203: throws WritingNotSupportedException, IOException {
204: delegate.write(dir, name);
205: }
206:
207: /**
208: * @see org.apache.poi.hpsf.MutablePropertySet#write(java.io.OutputStream)
209: */
210: public void write(final OutputStream out)
211: throws WritingNotSupportedException, IOException {
212: delegate.write(out);
213: }
214:
215: /**
216: * @see org.apache.poi.hpsf.PropertySet#equals(java.lang.Object)
217: */
218: public boolean equals(final Object o) {
219: return delegate.equals(o);
220: }
221:
222: /**
223: * @see org.apache.poi.hpsf.PropertySet#getProperties()
224: */
225: public Property[] getProperties() throws NoSingleSectionException {
226: return delegate.getProperties();
227: }
228:
229: /**
230: * @see org.apache.poi.hpsf.PropertySet#getProperty(int)
231: */
232: protected Object getProperty(final int id)
233: throws NoSingleSectionException {
234: return delegate.getProperty(id);
235: }
236:
237: /**
238: * @see org.apache.poi.hpsf.PropertySet#getPropertyBooleanValue(int)
239: */
240: protected boolean getPropertyBooleanValue(final int id)
241: throws NoSingleSectionException {
242: return delegate.getPropertyBooleanValue(id);
243: }
244:
245: /**
246: * @see org.apache.poi.hpsf.PropertySet#getPropertyIntValue(int)
247: */
248: protected int getPropertyIntValue(final int id)
249: throws NoSingleSectionException {
250: return delegate.getPropertyIntValue(id);
251: }
252:
253: /**
254: * @see org.apache.poi.hpsf.PropertySet#hashCode()
255: */
256: public int hashCode() {
257: return delegate.hashCode();
258: }
259:
260: /**
261: * @see org.apache.poi.hpsf.PropertySet#toString()
262: */
263: public String toString() {
264: return delegate.toString();
265: }
266:
267: /**
268: * @see org.apache.poi.hpsf.PropertySet#wasNull()
269: */
270: public boolean wasNull() throws NoSingleSectionException {
271: return delegate.wasNull();
272: }
273:
274: }
|