選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

SttbUtils.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
  23. */
  24. @Internal
  25. class SttbUtils
  26. {
  27. private static final int CDATA_SIZE_STTB_SAVED_BY = 2; // bytes
  28. private static final int CDATA_SIZE_STTBF_BKMK = 2; // bytes
  29. private static final int CDATA_SIZE_STTBF_R_MARK = 2; // bytes
  30. static String[] readSttbfBkmk( byte[] buffer, int startOffset )
  31. {
  32. return new Sttb( CDATA_SIZE_STTBF_BKMK, buffer, startOffset ).getData();
  33. }
  34. static String[] readSttbfRMark( byte[] buffer, int startOffset )
  35. {
  36. return new Sttb( CDATA_SIZE_STTBF_R_MARK, buffer, startOffset )
  37. .getData();
  38. }
  39. static String[] readSttbSavedBy( byte[] buffer, int startOffset )
  40. {
  41. return new Sttb( CDATA_SIZE_STTB_SAVED_BY, buffer, startOffset )
  42. .getData();
  43. }
  44. static void writeSttbfBkmk( String[] data, OutputStream tableStream )
  45. throws IOException
  46. {
  47. tableStream.write( new Sttb( CDATA_SIZE_STTBF_BKMK, data ).serialize() );
  48. }
  49. static void writeSttbfRMark( String[] data, OutputStream tableStream )
  50. throws IOException
  51. {
  52. tableStream.write( new Sttb( CDATA_SIZE_STTBF_R_MARK, data ).serialize() );
  53. }
  54. static void writeSttbSavedBy( String[] data, OutputStream tableStream )
  55. throws IOException
  56. {
  57. tableStream.write( new Sttb( CDATA_SIZE_STTB_SAVED_BY, data ).serialize() );
  58. }
  59. }