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 don't know about, we create one of
26: * these. It allows us to keep track of what it contains, so we can
27: * write it back out to disk unchanged
28: *
29: * @author Nick Burch
30: */
31:
32: public class UnknownRecordPlaceholder extends RecordAtom {
33: private byte[] _contents;
34: private long _type;
35:
36: /**
37: * Create a new holder for a record we don't grok
38: */
39: protected UnknownRecordPlaceholder(byte[] source, int start, int len) {
40: // Sanity Checking - including whole header, so treat
41: // length as based of 0, not 8 (including header size based)
42: if (len < 0) {
43: len = 0;
44: }
45:
46: // Treat as an atom, grab and hold everything
47: _contents = new byte[len];
48: System.arraycopy(source, start, _contents, 0, len);
49: _type = LittleEndian.getUShort(_contents, 2);
50: }
51:
52: /**
53: * Return the value we were given at creation
54: */
55: public long getRecordType() {
56: return _type;
57: }
58:
59: /**
60: * Write the contents of the record back, so it can be written
61: * to disk
62: */
63: public void writeOut(OutputStream out) throws IOException {
64: out.write(_contents);
65: }
66: }
|