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.

FixedField.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.util;
  16. import org.apache.poi.util.LittleEndian.BufferUnderrunException;
  17. import java.io.*;
  18. /**
  19. * behavior of a field at a fixed location within a byte array
  20. */
  21. public interface FixedField
  22. {
  23. /**
  24. * set the value from its offset into an array of bytes
  25. *
  26. * @param data the byte array from which the value is to be read
  27. *
  28. * @throws ArrayIndexOutOfBoundsException if the offset is out
  29. * of the array's valid index range
  30. */
  31. void readFromBytes(byte [] data)
  32. throws ArrayIndexOutOfBoundsException;
  33. /**
  34. * set the value from an InputStream
  35. *
  36. * @param stream the InputStream from which the value is to be
  37. * read
  38. *
  39. * @throws BufferUnderrunException if there is not enough data
  40. * available from the InputStream
  41. * @throws IOException if an IOException is thrown from reading
  42. * the InputStream
  43. */
  44. void readFromStream(InputStream stream)
  45. throws IOException;
  46. /**
  47. * write the value out to an array of bytes at the appropriate
  48. * offset
  49. *
  50. * @param data the array of bytes to which the value is to be
  51. * written
  52. *
  53. * @throws ArrayIndexOutOfBoundsException if the offset is out
  54. * of the array's valid index range
  55. */
  56. void writeToBytes(byte [] data)
  57. throws ArrayIndexOutOfBoundsException;
  58. /**
  59. * return the value as a String
  60. *
  61. * @return the value as a String
  62. */
  63. String toString();
  64. } // end public interface FixedField