1 /* ====================================================================
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================== */
18 package org.apache.poi.hslf.record;
20 import java.io.IOException;
21 import java.io.OutputStream;
22 import java.util.Arrays;
24 import org.apache.poi.util.LittleEndian;
27 * If we come across a record we know has children of (potential)
28 * interest, but where the record itself is boring, but where other
29 * records may care about where this one lives, we create one
30 * of these. It allows us to get at the children, and track where on
31 * disk this is, but not much else.
32 * Anything done using this should quite quickly be transitioned to its
33 * own proper record class!
38 public final class DummyPositionSensitiveRecordWithChildren extends PositionDependentRecordContainer
40 private byte[] _header;
44 * Create a new holder for a boring record with children, but with
45 * position dependent characteristics
47 protected DummyPositionSensitiveRecordWithChildren(byte[] source, int start, int len) {
48 // Just grab the header, not the whole contents
49 _header = Arrays.copyOfRange(source,start,start+8);
50 _type = LittleEndian.getUShort(_header,2);
53 _children = Record.findChildRecords(source,start+8,len-8);
57 * Return the value we were given at creation
59 public long getRecordType() { return _type; }
62 * Write the contents of the record back, so it can be written
65 public void writeOut(OutputStream out) throws IOException {
66 writeOut(_header[0],_header[1],_type,_children,out);