You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SttbUtils.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.hwpf.model;
  16. import java.io.IOException;
  17. import java.io.OutputStream;
  18. import org.apache.poi.util.Internal;
  19. /**
  20. * Utils class for storing and reading "STring TaBle stored in File"
  21. */
  22. @Internal
  23. class SttbUtils
  24. {
  25. private static final int CDATA_SIZE_STTB_SAVED_BY = 2; // bytes
  26. private static final int CDATA_SIZE_STTBF_BKMK = 2; // bytes
  27. private static final int CDATA_SIZE_STTBF_R_MARK = 2; // bytes
  28. static String[] readSttbfBkmk( byte[] buffer, int startOffset )
  29. {
  30. return new Sttb( CDATA_SIZE_STTBF_BKMK, buffer, startOffset ).getData();
  31. }
  32. static String[] readSttbfRMark( byte[] buffer, int startOffset )
  33. {
  34. return new Sttb( CDATA_SIZE_STTBF_R_MARK, buffer, startOffset )
  35. .getData();
  36. }
  37. static String[] readSttbSavedBy( byte[] buffer, int startOffset )
  38. {
  39. return new Sttb( CDATA_SIZE_STTB_SAVED_BY, buffer, startOffset )
  40. .getData();
  41. }
  42. static void writeSttbfBkmk( String[] data, OutputStream tableStream )
  43. throws IOException
  44. {
  45. tableStream.write( new Sttb( CDATA_SIZE_STTBF_BKMK, data ).serialize() );
  46. }
  47. static void writeSttbfRMark( String[] data, OutputStream tableStream )
  48. throws IOException
  49. {
  50. tableStream.write( new Sttb( CDATA_SIZE_STTBF_R_MARK, data ).serialize() );
  51. }
  52. static void writeSttbSavedBy( String[] data, OutputStream tableStream )
  53. throws IOException
  54. {
  55. tableStream.write( new Sttb( CDATA_SIZE_STTB_SAVED_BY, data ).serialize() );
  56. }
  57. }