PageRenderTime 78ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/components/forks/poi/src/loci/poi/poifs/storage/RawDataBlockList.java

http://github.com/openmicroscopy/bioformats
Java | 99 lines | 34 code | 14 blank | 51 comment | 3 complexity | f04d81fb6076689a6e02ea86f898d133 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0, BSD-2-Clause, MPL-2.0-no-copyleft-exception
  1. /*
  2. * #%L
  3. * Fork of Apache Jakarta POI.
  4. * %%
  5. * Copyright (C) 2008 - 2013 Open Microscopy Environment:
  6. * - Board of Regents of the University of Wisconsin-Madison
  7. * - Glencoe Software, Inc.
  8. * - University of Dundee
  9. * %%
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. * #L%
  22. */
  23. /* ====================================================================
  24. Licensed to the Apache Software Foundation (ASF) under one or more
  25. contributor license agreements. See the NOTICE file distributed with
  26. this work for additional information regarding copyright ownership.
  27. The ASF licenses this file to You under the Apache License, Version 2.0
  28. (the "License"); you may not use this file except in compliance with
  29. the License. You may obtain a copy of the License at
  30. http://www.apache.org/licenses/LICENSE-2.0
  31. Unless required by applicable law or agreed to in writing, software
  32. distributed under the License is distributed on an "AS IS" BASIS,
  33. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  34. See the License for the specific language governing permissions and
  35. limitations under the License.
  36. ==================================================================== */
  37. package loci.poi.poifs.storage;
  38. import java.io.*;
  39. import java.util.*;
  40. import loci.common.*;
  41. import loci.poi.util.*;
  42. /**
  43. * A list of RawDataBlocks instances, and methods to manage the list
  44. *
  45. * @author Marc Johnson (mjohnson at apache dot org
  46. */
  47. public class RawDataBlockList
  48. extends BlockListImpl
  49. {
  50. private int bigBlockSize;
  51. /**
  52. * Constructor RawDataBlockList
  53. *
  54. * @param stream the InputStream from which the data will be read
  55. *
  56. * @exception IOException on I/O errors, and if an incomplete
  57. * block is read
  58. */
  59. public RawDataBlockList(final RandomAccessInputStream stream, int size)
  60. throws IOException
  61. {
  62. List blocks = new ArrayList();
  63. bigBlockSize = size;
  64. long pointer = stream.getFilePointer();
  65. while (true)
  66. {
  67. RawDataBlock block = new RawDataBlock(stream, size, pointer);
  68. if (block.eof())
  69. {
  70. break;
  71. }
  72. blocks.add(block);
  73. if (size + pointer > stream.length()) {
  74. break;
  75. }
  76. pointer += size;
  77. }
  78. stream.seek(pointer);
  79. setBlocks(( RawDataBlock [] ) blocks.toArray(new RawDataBlock[ 0 ]));
  80. }
  81. public int getBigBlockSize() { return bigBlockSize; }
  82. public ListManagedBlock[] getBlocks() { return _blocks; }
  83. } // end public class RawDataBlockList