Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

BinaryTagDataBlob.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hslf.record;
  16. import org.apache.poi.util.LittleEndian;
  17. import java.io.IOException;
  18. import java.io.OutputStream;
  19. /**
  20. * If we come across a record we know has children of (potential)
  21. * interest, but where the record itself is boring, but where other
  22. * records may care about where this one lives, we create one
  23. * of these. It allows us to get at the children, and track where on
  24. * disk this is, but not much else.
  25. * Anything done using this should quite quickly be transitioned to its
  26. * own proper record class!
  27. *
  28. * @author Nick Burch
  29. */
  30. public final class BinaryTagDataBlob extends PositionDependentRecordContainer
  31. {
  32. private byte[] _header;
  33. private long _type;
  34. /**
  35. * Create a new holder for a boring record with children, but with
  36. * position dependent characteristics
  37. */
  38. protected BinaryTagDataBlob(byte[] source, int start, int len) {
  39. // Just grab the header, not the whole contents
  40. _header = new byte[8];
  41. System.arraycopy(source,start,_header,0,8);
  42. _type = LittleEndian.getUShort(_header,2);
  43. // Find our children
  44. _children = Record.findChildRecords(source,start+8,len-8);
  45. }
  46. /**
  47. * Return the value we were given at creation
  48. */
  49. public long getRecordType() { return _type; }
  50. /**
  51. * Write the contents of the record back, so it can be written
  52. * to disk
  53. */
  54. public void writeOut(OutputStream out) throws IOException {
  55. writeOut(_header[0],_header[1],_type,_children,out);
  56. }
  57. }