01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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: package org.apache.poi.hslf.record;
19:
20: import org.apache.poi.util.LittleEndian;
21: import java.io.IOException;
22: import java.io.OutputStream;
23:
24: /**
25: * If we come across a record we know has children of (potential)
26: * interest, but where the record itself is boring, we create one
27: * of these. It allows us to get at the children, but not much else
28: *
29: * @author Nick Burch
30: */
31:
32: public class DummyRecordWithChildren extends RecordContainer {
33: private byte[] _header;
34: private long _type;
35:
36: /**
37: * Create a new holder for a boring record with children
38: */
39: protected DummyRecordWithChildren(byte[] source, int start, int len) {
40: // Just grab the header, not the whole contents
41: _header = new byte[8];
42: System.arraycopy(source, start, _header, 0, 8);
43: _type = LittleEndian.getUShort(_header, 2);
44:
45: // Find our children
46: _children = Record.findChildRecords(source, start + 8, len - 8);
47: }
48:
49: /**
50: * Return the value we were given at creation
51: */
52: public long getRecordType() {
53: return _type;
54: }
55:
56: /**
57: * Write the contents of the record back, so it can be written
58: * to disk
59: */
60: public void writeOut(OutputStream out) throws IOException {
61: writeOut(_header[0], _header[1], _type, _children, out);
62: }
63: }
|